GroupsController.cs 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153
  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. ///
  128. /// 岗位ID
  129. /// 24 机票
  130. /// 25 酒店
  131. /// 26 签证
  132. /// 27 商邀
  133. /// 28 OP
  134. ///
  135. /// 费用类型ID
  136. /// 76 酒店预订
  137. /// 79 车/导游地接
  138. /// 80 签证
  139. /// 81 邀请/公务活动
  140. /// 82 团组客户保险
  141. /// 85 机票预订
  142. /// 98 其他款项
  143. /// </summary>
  144. private readonly Dictionary<int, List<int>> _dataInit = new() {
  145. { 24, new List<int> { 85 } }, // 机票 -> 机票预订
  146. { 25, new List<int> { 76 } }, // 酒店 -> 酒店预订
  147. { 26, new List<int> { 80, 82 } }, // 签证 -> 签证, 团组客户保险
  148. { 27, new List<int> { 81 } }, // 地接专员 -> 邀请/公务活动
  149. { 28, new List<int> { 79 } } // 商邀 -> 车/导游地接
  150. };
  151. /// <summary>
  152. /// 构造函数
  153. /// </summary>
  154. /// <param name="logger"></param>
  155. /// <param name="eec_textLogger"></param>
  156. /// <param name="groupTextLogger"></param>
  157. /// <param name="mapper"></param>
  158. /// <param name="hubContext"></param>
  159. /// <param name="sqlSugar"></param>
  160. /// <param name="grpScheduleRep"></param>
  161. /// <param name="groupRepository"></param>
  162. /// <param name="taskAssignmentRep"></param>
  163. /// <param name="airTicketResRep"></param>
  164. /// <param name="decreasePaymentsRep"></param>
  165. /// <param name="InvitationOfficialActivitiesRep"></param>
  166. /// <param name="delegationEnDataRep"></param>
  167. /// <param name="enterExitCostRep"></param>
  168. /// <param name="delegationVisaRep"></param>
  169. /// <param name="message"></param>
  170. /// <param name="visaPriceRep"></param>
  171. /// <param name="carTouristGuideGroundRep"></param>
  172. /// <param name="checkBoxs"></param>
  173. /// <param name="GroupCostRepository"></param>
  174. /// <param name="CostTypeHotelNumberRepository"></param>
  175. /// <param name="GroupCostParameterRepository"></param>
  176. /// <param name="hotelPriceRep"></param>
  177. /// <param name="customersRep"></param>
  178. /// <param name="setDataRep"></param>
  179. /// <param name="tourClientListRep"></param>
  180. /// <param name="teamRateRep"></param>
  181. /// <param name="usersRep"></param>
  182. /// <param name="juHeApi"></param>
  183. /// <param name="invertedListRep"></param>
  184. /// <param name="visaFeeInfoRep"></param>
  185. /// <param name="ticketBlackCodeRep"></param>
  186. /// <param name="hotelInquiryRep"></param>
  187. /// <param name="threeCodeRepository"></param>
  188. /// <param name="feeAuditRep"></param>
  189. /// <param name="visaCommissionRep"></param>
  190. /// <param name="ffrRep"></param>
  191. /// <param name="opinionaireRep"></param>
  192. /// <param name="tableorRep"></param>
  193. /// <param name="enterExitCostDraftRep"></param>
  194. /// <param name="restaurantRep"></param>
  195. /// <param name="enterExitCostQuoteRep"></param>
  196. /// <param name="grpOrderPreInfoRep"></param>
  197. /// <param name="visaProcessRep"></param>
  198. /// <param name="processOverviewRep"></param>
  199. public GroupsController(
  200. ILogger<GroupsController> logger,
  201. ITextFileLogger eec_textLogger,
  202. IGroupTextFileLogger groupTextLogger,
  203. IMapper mapper,
  204. IHubContext<ChatHub, IChatClient> hubContext,
  205. SqlSugarClient sqlSugar,
  206. GrpScheduleRepository grpScheduleRep,
  207. DelegationInfoRepository groupRepository,
  208. TaskAssignmentRepository taskAssignmentRep,
  209. AirTicketResRepository airTicketResRep,
  210. DecreasePaymentsRepository decreasePaymentsRep,
  211. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  212. DelegationEnDataRepository delegationEnDataRep,
  213. EnterExitCostRepository enterExitCostRep,
  214. DelegationVisaRepository delegationVisaRep,
  215. MessageRepository message,
  216. VisaPriceRepository visaPriceRep,
  217. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  218. CheckBoxsRepository checkBoxs,
  219. GroupCostRepository GroupCostRepository,
  220. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  221. GroupCostParameterRepository GroupCostParameterRepository,
  222. HotelPriceRepository hotelPriceRep,
  223. CustomersRepository customersRep,
  224. SetDataRepository setDataRep,
  225. TourClientListRepository tourClientListRep,
  226. TeamRateRepository teamRateRep,
  227. UsersRepository usersRep,
  228. IJuHeApiService juHeApi,
  229. InvertedListRepository invertedListRep,
  230. VisaFeeInfoRepository visaFeeInfoRep,
  231. TicketBlackCodeRepository ticketBlackCodeRep,
  232. HotelInquiryRepository hotelInquiryRep,
  233. ThreeCodeRepository threeCodeRepository,
  234. FeeAuditRepository feeAuditRep,
  235. VisaCommissionRepository visaCommissionRep,
  236. ForeignReceivablesRepository ffrRep,
  237. OpinionaireRepository opinionaireRep,
  238. TableOperationRecordRepository tableorRep,
  239. EnterExitCostDraftRepository enterExitCostDraftRep,
  240. RestaurantRepository restaurantRep,
  241. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  242. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  243. VisaProcessRepository visaProcessRep,
  244. ProcessOverviewRepository processOverviewRep
  245. )
  246. {
  247. _logger = logger;
  248. _eec_textLogger = eec_textLogger;
  249. _groupTextLogger = groupTextLogger;
  250. _mapper = mapper;
  251. _grpScheduleRep = grpScheduleRep;
  252. _groupRepository = groupRepository;
  253. _taskAssignmentRep = taskAssignmentRep;
  254. _airTicketResRep = airTicketResRep;
  255. _sqlSugar = sqlSugar;
  256. url = AppSettingsHelper.Get("ExcelBaseUrl");
  257. path = AppSettingsHelper.Get("ExcelBasePath");
  258. if (!System.IO.Directory.Exists(path))
  259. {
  260. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  261. }
  262. _decreasePaymentsRep = decreasePaymentsRep;
  263. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  264. _delegationEnDataRep = delegationEnDataRep;
  265. _enterExitCostRep = enterExitCostRep;
  266. _delegationVisaRep = delegationVisaRep;
  267. _message = message;
  268. _visaPriceRep = visaPriceRep;
  269. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  270. _checkBoxs = checkBoxs;
  271. _GroupCostRepository = GroupCostRepository;
  272. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  273. _GroupCostParameterRepository = GroupCostParameterRepository;
  274. _hotelPriceRep = hotelPriceRep;
  275. _customersRep = customersRep;
  276. _setDataRep = setDataRep;
  277. _tourClientListRep = tourClientListRep;
  278. _teamRateRep = teamRateRep;
  279. _hubContext = hubContext;
  280. _usersRep = usersRep;
  281. _juHeApi = juHeApi;
  282. _invertedListRep = invertedListRep;
  283. _visaFeeInfoRep = visaFeeInfoRep;
  284. _ticketBlackCodeRep = ticketBlackCodeRep;
  285. _hotelInquiryRep = hotelInquiryRep;
  286. _threeCodeRepository = threeCodeRepository;
  287. _feeAuditRep = feeAuditRep;
  288. _visaCommissionRep = visaCommissionRep;
  289. _ffrRep = ffrRep;
  290. _opinionaireRep = opinionaireRep;
  291. _currencyInit = new List<CurrencyInfo>()
  292. {
  293. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  294. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  295. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  296. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  297. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  298. };
  299. _portTypeData = new List<int>() { 2, 3 };
  300. _tableorRep = tableorRep;
  301. _enterExitCostDraftRep = enterExitCostDraftRep;
  302. _restaurantRep = restaurantRep;
  303. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  304. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  305. _visaProcessRep = visaProcessRep;
  306. _processOverviewRep = processOverviewRep;
  307. }
  308. #region 页面加载弹窗信息
  309. /// <summary>
  310. /// 提示用户录入团组费用信息
  311. /// 根据用户ID获取分配权限内团组名称
  312. /// </summary>
  313. /// <param name="currUserId">用户Id</param>
  314. /// <param name="daysAgo">往前推的天数</param>
  315. /// <returns></returns>
  316. [HttpGet]
  317. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  318. public async Task<IActionResult> GetGroupNamesByUserId(int currUserId, int daysAgo = 5)
  319. {
  320. var stopwatch = Stopwatch.StartNew();
  321. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  322. .Where(x => x.Id == currUserId && x.IsDel == 0)
  323. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  324. .FirstAsync();
  325. if (userInfo == null)
  326. {
  327. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  328. }
  329. var jobId = userInfo.JobPostId;
  330. var feeTypeIds = new List<int>() { };
  331. if (_dataInit.TryGetValue(jobId, out var values))
  332. {
  333. feeTypeIds = values;
  334. }
  335. /*
  336. * 获取今天时间往前推5天查询团组c表里有没有费用
  337. */
  338. var today_startDate = DateTime.Now.Date.AddDays(-daysAgo);
  339. var today_endDate = DateTime.Now.Date.AddDays(-daysAgo).AddDays(1).AddSeconds(-1);
  340. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  341. .Where(di => di.IsDel == 0)
  342. .Where(di => di.VisitDate >= today_startDate && di.VisitDate <= today_endDate)
  343. // 存在任务分配记录
  344. .Where(di => SqlFunc.Subqueryable<Grp_GroupsTaskAssignment>()
  345. .Where(gta => gta.DIId == di.Id && gta.IsDel == 0 && feeTypeIds.Contains(gta.CTId))
  346. .Any())
  347. // 不存在费用记录
  348. .Where(di => !SqlFunc.Subqueryable<Grp_CreditCardPayment>()
  349. .Where(ccp => ccp.DIId == di.Id && ccp.IsDel == 0 && feeTypeIds.Contains(ccp.CTable))
  350. .Any())
  351. // 新增条件:不在确认记录表中(排除已确认的团组)
  352. .Where(di => !SqlFunc.Subqueryable<Grp_FeeEntryAcknowledge>()
  353. .Where(ack => ack.GroupId == di.Id && ack.IsDel == 0 && ack.UserId == currUserId)
  354. .Where(ack => ack.IsAcknowledged == AcknowledgeStatusEnum.Acknowledged) // 只排除已确认的记录
  355. .Any())
  356. .Select(di => new
  357. {
  358. di.Id,
  359. di.TeamName,
  360. di.VisitDate
  361. })
  362. .OrderBy(di => di.VisitDate)
  363. .ToListAsync();
  364. stopwatch.Stop();
  365. return Ok(JsonView(true, $"操作成功!【耗时:{stopwatch.ElapsedMilliseconds}ms】", new
  366. {
  367. isTips = groupNames.Any(),
  368. groupNames = groupNames.Select(x => new { x.Id, GroupName = x.TeamName, x.VisitDate }).ToList()
  369. }));
  370. }
  371. /// <summary>
  372. /// 提示用户录入团组费用信息
  373. /// 已知晓确认操作记录(添加)
  374. /// </summary>
  375. /// <param name="dto">请求体</param>
  376. /// <returns></returns>
  377. [HttpPost]
  378. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  379. public async Task<IActionResult> FeeEntryAcknowledgeCrate(FeeEntryAcknowledgeCrateDto dto)
  380. {
  381. // 1. 参数验证
  382. if (dto?.GroupIds == null || !dto.GroupIds.Any())
  383. {
  384. return Ok(JsonView(false, "请选择需要确认的团组!"));
  385. }
  386. if (dto.GroupIds.Count > 100)
  387. {
  388. return Ok(JsonView(false, "一次性确认团组数量不能超过100个!"));
  389. }
  390. if (dto.CurrUserId <= 0)
  391. {
  392. return Ok(JsonView(false, "用户ID无效!"));
  393. }
  394. //2. 验证用户存在性
  395. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  396. .Where(x => x.Id == dto.CurrUserId && x.IsDel == 0)
  397. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  398. .FirstAsync();
  399. if (userInfo == null)
  400. {
  401. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  402. }
  403. // 3. 获取费用类型
  404. var feeTypeIds = new List<int>() { };
  405. if (_dataInit.TryGetValue(userInfo.JobPostId, out var values))
  406. {
  407. feeTypeIds = values;
  408. }
  409. // 4. 验证团组存在性
  410. var validGroupIds = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  411. .Where(x => dto.GroupIds.Contains(x.Id) && x.IsDel == 0)
  412. .Select(x => x.Id)
  413. .ToListAsync();
  414. if (!validGroupIds.Any())
  415. {
  416. return Ok(JsonView(false, "未找到有效的团组信息!"));
  417. }
  418. // 5. 检查是否已存在确认记录(避免重复确认)
  419. var existingRecords = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  420. .Where(x => validGroupIds.Contains(x.GroupId) &&
  421. x.UserId == dto.CurrUserId &&
  422. x.IsDel == 0)
  423. .Select(x => new { x.GroupId, x.FeeTypeId })
  424. .ToListAsync();
  425. // 6. 准备插入数据(过滤已存在的记录)
  426. var infos = new List<Grp_FeeEntryAcknowledge>();
  427. foreach (var groupId in validGroupIds)
  428. {
  429. // 为每个费用类型创建确认记录
  430. foreach (var feeTypeId in feeTypeIds)
  431. {
  432. // 检查是否已存在相同记录
  433. var exists = existingRecords.Any(x => x.GroupId == groupId && x.FeeTypeId == feeTypeId);
  434. if (!exists)
  435. {
  436. infos.Add(new Grp_FeeEntryAcknowledge()
  437. {
  438. GroupId = groupId,
  439. UserId = dto.CurrUserId,
  440. JobPostId = userInfo.JobPostId,
  441. FeeTypeId = feeTypeId,
  442. IsAcknowledged = Domain.Enums.AcknowledgeStatusEnum.Acknowledged,
  443. AcknowledgeTime = DateTime.Now,
  444. AcknowledgeType = Domain.Enums.AcknowledgeTypeEnum.WebConfirm,
  445. CreateUserId = 4, // 系统创建
  446. });
  447. }
  448. }
  449. }
  450. if (!infos.Any())
  451. {
  452. return Ok(JsonView(true, "所选团组已确认,无需重复操作!"));
  453. }
  454. // 7. 批量插入数据
  455. var successCount = await _sqlSugar.Insertable(infos).ExecuteCommandAsync();
  456. if (successCount < 1)
  457. {
  458. return Ok(JsonView(false, $"操作失败!"));
  459. }
  460. return Ok(JsonView(true, $"操作成功!"));
  461. }
  462. #endregion
  463. #region 流程管控
  464. /// <summary>
  465. /// 获取团组流程管控信息
  466. /// </summary>
  467. /// <param name="_jsonDto">查询参数</param>
  468. /// <returns></returns>
  469. [HttpPost]
  470. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  471. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  472. {
  473. if (string.IsNullOrEmpty(_jsonDto.Paras))
  474. {
  475. return Ok(JsonView(false, "参数为空"));
  476. }
  477. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  478. if (_ScheduleDto != null)
  479. {
  480. if (_ScheduleDto.SearchType == 2)//获取列表
  481. {
  482. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  483. return Ok(JsonView(_grpScheduleViewList));
  484. }
  485. else//获取对象
  486. {
  487. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  488. if (_grpScheduleView != null)
  489. {
  490. return Ok(JsonView(_grpScheduleView));
  491. }
  492. }
  493. }
  494. else
  495. {
  496. return Ok(JsonView(false, "参数反序列化失败"));
  497. }
  498. return Ok(JsonView(false, "暂无数据!"));
  499. }
  500. /// <summary>
  501. /// 修改团组流程管控详细表数据
  502. /// </summary>
  503. /// <param name="dto"></param>
  504. /// <returns></returns>
  505. [HttpPost]
  506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  507. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  508. {
  509. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  510. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  511. .SetColumns(it => it.Duty == _detail.Duty)
  512. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  513. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  514. .SetColumns(it => it.JobContent == _detail.JobContent)
  515. .SetColumns(it => it.Remark == _detail.Remark)
  516. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  517. .Where(s => s.Id == dto.Id)
  518. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  519. .ExecuteCommandAsync();
  520. if (result > 0)
  521. {
  522. return Ok(JsonView(true, "保存成功!"));
  523. }
  524. return Ok(JsonView(false, "保存失败!"));
  525. }
  526. /// <summary>
  527. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  528. /// </summary>
  529. /// <param name="dto"></param>
  530. /// <returns></returns>
  531. [HttpPost]
  532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  533. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  534. {
  535. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  536. _detail.IsDel = 1;
  537. _detail.DeleteUserId = dto.Duty;
  538. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  539. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  540. .SetColumns(it => it.IsDel == _detail.IsDel)
  541. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  542. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  543. .Where(it => it.Id == dto.Id)
  544. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  545. //.WhereColumns(s => s.Id == dto.Id)
  546. .ExecuteCommandAsync();
  547. if (result > 0)
  548. {
  549. return Ok(JsonView(true, "删除成功!"));
  550. }
  551. return Ok(JsonView(false, "删除失败!"));
  552. }
  553. /// <summary>
  554. /// 增加团组流程管控详细表数据
  555. /// </summary>
  556. /// <param name="dto"></param>
  557. /// <returns></returns>
  558. [HttpPost]
  559. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  560. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  561. {
  562. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  563. if (DateTime.Now < _detail.ExpectBeginDt)
  564. {
  565. _detail.StepStatus = 0;
  566. }
  567. else
  568. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  569. _detail.StepStatus = 1;
  570. }
  571. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  572. if (result > 0)
  573. {
  574. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  575. return Ok(JsonView(true, "添加成功!", _result));
  576. }
  577. return Ok(JsonView(false, "添加失败!"));
  578. }
  579. #endregion
  580. #region 团组前期信息
  581. /// <summary>
  582. /// 团组前期信息H5-URL(员工对应地址)
  583. /// </summary>
  584. /// <param name="name">用户名称</param>
  585. /// <returns></returns>
  586. [HttpGet]
  587. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  588. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  589. {
  590. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  591. .Where(x => x.IsDel == 0)
  592. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  593. .OrderBy(x => x.Id)
  594. .Select(x => new
  595. {
  596. name = x.CnName,
  597. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  598. })
  599. .ToListAsync();
  600. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  601. }
  602. /// <summary>
  603. /// 团组前期信息 List
  604. /// </summary>
  605. /// <returns></returns>
  606. [HttpPost]
  607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  608. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  609. {
  610. var search = dto.Search;
  611. int[] nameTempIds = new int[] { 1, 12, 28 },
  612. countryTempIds = new int[] { 2, 13, 29 },
  613. daysTempIds = new int[] { 4, 15, 31 },
  614. ppNumTempIds = new int[] { 6 };
  615. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  616. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  617. .Where((opi, u) => opi.IsDel == 0)
  618. .OrderByDescending((opi, u) => opi.CreateTime)
  619. .Select((opi, u) => new GroupOrderPreInfoListView()
  620. {
  621. Id = opi.Id,
  622. Name = opi.Name,
  623. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  624. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  625. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  626. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  627. Operator = u.CnName,
  628. OperationTime = opi.CreateTime
  629. })
  630. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  631. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  632. .ToListAsync();
  633. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  634. int total = list.Count;
  635. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  636. var listPageData1 = listPageData
  637. .Skip((dto.PageIndex - 1) * dto.PageSize)
  638. .Take(dto.PageSize)
  639. .ToList();
  640. var infoIds = listPageData1.Select(x => x.Id).ToList();
  641. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  642. .Where(x => x.IsDel == 0 && x.STid == 109)
  643. .ToArrayAsync();
  644. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  645. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  646. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  647. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  648. .ToListAsync();
  649. foreach (var item in listPageData1)
  650. {
  651. var typeDatas1 = typeDatas.Select(x => new
  652. {
  653. x.Id,
  654. x.Name,
  655. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  656. }).ToArray();
  657. item.VersionDetails = typeDatas1;
  658. }
  659. return Ok(JsonView(listPageData1, listPageData1.Count));
  660. }
  661. /// <summary>
  662. /// 团组前期信息 Init
  663. /// </summary>
  664. /// <returns></returns>
  665. [HttpGet("{userId}")]
  666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  667. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  668. {
  669. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  670. }
  671. /// <summary>
  672. /// 国家数据源
  673. /// </summary>
  674. /// <param name="pageIndex">当前页码</param>
  675. /// <param name="pageSize">每页条数</param>
  676. /// <param name="search">查询条件</param>
  677. /// <returns></returns>
  678. [HttpGet]
  679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  680. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  681. {
  682. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  683. if (pageIndex == 0 && pageSize == 0)
  684. {
  685. //所有数据
  686. return Ok(JsonView(countrys, countrys.Count));
  687. }
  688. //分页
  689. int skip = (pageIndex - 1) * pageSize;
  690. int take = pageSize;
  691. if (!string.IsNullOrEmpty(search))
  692. {
  693. IEnumerable<char> charSequence = search.Select(c => c);
  694. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  695. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  696. return Ok(JsonView(pageData, pageResult1.Count));
  697. }
  698. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  699. return Ok(JsonView(pageResult2, countrys.Count));
  700. }
  701. /// <summary>
  702. /// 城市数据源
  703. /// </summary>
  704. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  705. /// <param name="pageIndex">当前页码</param>
  706. /// <param name="pageSize">每页条数</param>
  707. /// <param name="search">查询条件</param>
  708. /// <returns></returns>
  709. [HttpGet("{countryLabel}")]
  710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  711. public async Task<IActionResult> CityByCountry(
  712. string countryLabel,
  713. [FromQuery] int pageIndex,
  714. [FromQuery] int pageSize,
  715. [FromQuery] string search)
  716. {
  717. countryLabel = HttpUtility.UrlDecode(countryLabel);
  718. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  719. var citys = Array.Empty<string?>();
  720. if (countryList.Any())
  721. {
  722. var cityDatas = await _sqlSugar
  723. .Queryable<Grp_NationalTravelFee>()
  724. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  725. .ToArrayAsync();
  726. foreach (var item in cityDatas)
  727. {
  728. if (item.City.Contains("城市"))
  729. {
  730. item.City = item.Country + "-所有城市";
  731. }
  732. }
  733. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  734. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  735. }
  736. if (pageIndex == 0 && pageSize == 0)
  737. {
  738. //所有数据
  739. return Ok(JsonView(citys, citys?.Length ?? 0));
  740. }
  741. //分页
  742. int skip = (pageIndex - 1) * pageSize;
  743. int take = pageSize;
  744. if (!string.IsNullOrEmpty(search))
  745. {
  746. IEnumerable<char> charSequence = search.Select(c => c);
  747. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  748. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  749. return Ok(JsonView(pageData, pageResult1.Count));
  750. }
  751. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  752. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  753. }
  754. /// <summary>
  755. /// 团组前期信息 Info
  756. /// </summary>
  757. /// <param name="dto">Id</param>
  758. /// <returns></returns>
  759. [HttpGet("{Id}/{TempId}")]
  760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  761. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  762. {
  763. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  764. }
  765. /// <summary>
  766. /// 团组前期信息 移动端 Info
  767. /// </summary>
  768. /// <param name="dto">Id</param>
  769. /// <returns></returns>
  770. [HttpGet("{Id}/{TempId}")]
  771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  772. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  773. {
  774. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  775. }
  776. /// <summary>
  777. /// 团组前期信息 Save
  778. /// </summary>
  779. /// <param name="dto">Id</param>
  780. /// <returns></returns>
  781. [HttpPost]
  782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  783. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  784. {
  785. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  786. }
  787. /// <summary>
  788. /// 团组前期信息 Del
  789. /// </summary>
  790. /// <param name="dto">Id</param>
  791. /// <returns></returns>
  792. [HttpPost]
  793. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  794. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  795. {
  796. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  797. }
  798. /// <summary>
  799. /// 团组前期信息 文件下载
  800. /// </summary>
  801. /// <param name="dto">Id</param>
  802. /// <returns></returns>
  803. [HttpGet("{Id}/{TempId}")]
  804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  805. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  806. {
  807. int id = dto.Id, tempId = dto.TempId;
  808. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  809. var data = view.Data as GrpOrderPreInfoView;
  810. #region Excel
  811. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  812. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  813. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  814. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  815. var fileNamePrefix = string.Empty;
  816. if (tempId == 1405)
  817. {
  818. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  819. fileNamePrefix = $"{data.Name}_无商邀版";
  820. }
  821. else if (tempId == 1406)
  822. {
  823. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  824. fileNamePrefix = $"{data.Name}_有商邀版";
  825. }
  826. else
  827. {
  828. //tempId == 1404 默认下载
  829. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  830. fileNamePrefix = $"{data.Name}_单接送机";
  831. }
  832. foreach (var item in data.Items)
  833. {
  834. var obj = item.NewValue;
  835. if (obj == null) item.OriginVal = "";
  836. else if (obj.Equals("有") || obj.Equals("无"))
  837. {
  838. item.OriginVal = obj.ToString();
  839. }
  840. else if (obj is object[] objArray)
  841. {
  842. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  843. item.OriginVal = string.Join("、", stringArray);
  844. }
  845. else if (obj is string[] stringArray)
  846. {
  847. item.OriginVal = string.Join("、", stringArray);
  848. }
  849. else if (obj.Equals("-"))
  850. {
  851. item.OriginVal = "";
  852. }
  853. }
  854. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  855. fileName = CommonFun.ValidFileName(fileName);
  856. //载入模板
  857. var designer = new WorkbookDesigner
  858. {
  859. Workbook = new Workbook(tempPath)
  860. };
  861. if (tempId == 1406)
  862. {
  863. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  864. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  865. for (int i = 1; i <= view2.Length; i++)
  866. {
  867. view2[i - 1].Index = i;
  868. }
  869. designer.SetDataSource("View1", view1);
  870. designer.SetDataSource("View2", view2);
  871. }
  872. else
  873. {
  874. designer.SetDataSource("View", data.Items);
  875. }
  876. designer.Process();
  877. if (!Directory.Exists(savePath))
  878. {
  879. Directory.CreateDirectory(savePath);
  880. }
  881. string serverPath = $"{savePath}{fileName}";
  882. designer.Workbook.Save(serverPath);
  883. string rst = $"{servicePath}{ftpPath}{fileName}";
  884. #endregion
  885. return Ok(JsonView(new { url = rst }));
  886. }
  887. #endregion
  888. #region 团组基本信息
  889. /// <summary>
  890. /// 接团信息列表
  891. /// </summary>
  892. /// <param name="dto">团组列表请求dto</param>
  893. /// <returns></returns>
  894. [HttpPost]
  895. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  896. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  897. {
  898. var groupData = await _groupRepository.GetGroupList(dto);
  899. if (groupData.Code != 0)
  900. {
  901. return Ok(JsonView(false, groupData.Msg));
  902. }
  903. return Ok(JsonView(groupData.Data));
  904. }
  905. /// <summary>
  906. /// 分页查询团组列表
  907. /// </summary>
  908. /// <param name="dto"></param>
  909. /// <returns></returns>
  910. [HttpPost]
  911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  912. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  913. {
  914. var watch = new Stopwatch();
  915. watch.Start();
  916. RefAsync<int> total = 0;
  917. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  918. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  919. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  920. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  921. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  922. .Distinct()
  923. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  924. watch.Stop();
  925. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  926. }
  927. /// <summary>
  928. /// 接团信息列表 Page Init
  929. /// </summary>
  930. /// <returns></returns>
  931. [HttpPost]
  932. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  933. public async Task<IActionResult> PostGroupPageListInit()
  934. {
  935. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  936. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  937. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  938. var _view = new
  939. {
  940. depData = depDatas,
  941. rankData = rankDatas
  942. };
  943. return Ok(JsonView(true, "查询成功!", _view));
  944. }
  945. /// <summary>
  946. /// 接团信息列表 Page
  947. /// </summary>
  948. /// <param name="dto">团组列表请求dto</param>
  949. /// <returns></returns>
  950. [HttpPost]
  951. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  952. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  953. {
  954. #region 参数验证
  955. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  956. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  957. #region 页面操作权限验证
  958. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  959. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  960. #endregion
  961. #endregion
  962. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  963. {
  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. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  974. {
  975. string tj = dto.SearchCriteria;
  976. 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}%')",
  977. tj, tj, tj, tj, tj);
  978. }
  979. if (int.TryParse(dto.Rank, out int rankId))
  980. {
  981. if (rankId > 0) sqlWhere += string.Format("And gdi.TeamLevSId = {0}", rankId);
  982. }
  983. string sqlWhere1 = string.Empty;
  984. if (!string.IsNullOrEmpty(dto.Department) && !dto.Department.Equals("全部"))
  985. {
  986. sqlWhere1 = string.Format("Where Department = '{0}'", dto.Department);
  987. }
  988. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,Department,
  989. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  990. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  991. JietuanOperator,IsSure,CreateTime,IsBid,Step
  992. From (
  993. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  994. CASE WHEN gdi.JietuanOperator = 4 OR gdi.JietuanOperator = 21 THEN '国交部'
  995. ELSE (Select DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId) END AS 'Department',
  996. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,gdi.Step,
  997. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  998. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  999. su.CnName JietuanOperator,IsSure,gdi.CreateTime,gdi.IsBid
  1000. From Grp_DelegationInfo gdi
  1001. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1002. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1003. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1004. Where gdi.IsDel = 0 {0}
  1005. ) temp {1}", sqlWhere, sqlWhere1);
  1006. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1007. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  1008. //处理 团组模块实际操作人
  1009. _DelegationList.ForEach(async x =>
  1010. {
  1011. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  1012. var operatorNames = new StringBuilder();
  1013. //operatorNames.AppendLine("各模块实际操作人:");
  1014. if (operators.Any())
  1015. {
  1016. operators.ForEach(y =>
  1017. {
  1018. string label = string.Empty;
  1019. if (y.OperationUsers.Any())
  1020. {
  1021. var users = y.OperationUsers.Select(x => x.UserName).ToList();
  1022. label = string.Join('、', users);
  1023. }
  1024. else label = "暂未指定";
  1025. operatorNames.AppendLine($"{y.CTableName}:{label}");
  1026. operatorNames.AppendLine();
  1027. });
  1028. }
  1029. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  1030. });
  1031. var _view = new
  1032. {
  1033. PageFuncAuth = pageFunAuthView,
  1034. Data = _DelegationList
  1035. };
  1036. return Ok(JsonView(true, "查询成功!", _view, total));
  1037. }
  1038. else
  1039. {
  1040. return Ok(JsonView(false, "查询失败"));
  1041. }
  1042. }
  1043. /// <summary>
  1044. /// 团组列表
  1045. /// </summary>
  1046. /// <returns></returns>
  1047. [HttpPost]
  1048. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  1049. {
  1050. #region 参数验证
  1051. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1052. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1053. #region 页面操作权限验证
  1054. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1055. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1056. #endregion
  1057. #endregion
  1058. if (dto.PortType != 1 && dto.PortType != 2)
  1059. {
  1060. return Ok(JsonView(false, "查询失败!"));
  1061. }
  1062. string orderbyStr = "order by gdi.CreateTime Desc";
  1063. string sqlWhere = string.Empty;
  1064. if (dto.IsSure == 0) //未完成
  1065. {
  1066. sqlWhere += string.Format(@" And IsSure = 0");
  1067. }
  1068. else if (dto.IsSure == 1) //已完成
  1069. {
  1070. sqlWhere += string.Format(@" And IsSure = 1");
  1071. }
  1072. //团组类型
  1073. if (dto.TeamDid > 0)
  1074. {
  1075. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  1076. }
  1077. //团组名称
  1078. if (!string.IsNullOrEmpty(dto.TeamName))
  1079. {
  1080. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  1081. }
  1082. //客户名称
  1083. if (!string.IsNullOrEmpty(dto.ClientName))
  1084. {
  1085. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  1086. }
  1087. //客户单位
  1088. if (!string.IsNullOrEmpty(dto.ClientUnit))
  1089. {
  1090. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  1091. }
  1092. //出访时间
  1093. if (!string.IsNullOrEmpty(dto.visitDataTime))
  1094. {
  1095. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  1096. orderbyStr = "order by gdi.VisitDate";
  1097. }
  1098. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1099. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  1100. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  1101. JietuanOperator,IsSure,CreateTime
  1102. From (
  1103. Select row_number() over({0}) as Row_Number,
  1104. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  1105. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  1106. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  1107. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1108. From Grp_DelegationInfo gdi
  1109. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1110. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1111. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1112. Where gdi.IsDel = 0 {1}
  1113. ) temp ", orderbyStr, sqlWhere);
  1114. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1115. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  1116. #region 处理所属部门
  1117. /*
  1118. * 1.sq 和 gyy 等显示 市场部
  1119. * 2.王鸽和主管及张总还有管理员号统一国交部
  1120. * 2-1. 4 管理员 ,21 张海麟
  1121. */
  1122. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  1123. var userIds1 = new List<int>() { 4, 21 };
  1124. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  1125. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1126. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1127. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1128. .ToList();
  1129. foreach (var item in _DelegationList)
  1130. {
  1131. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1132. }
  1133. #endregion
  1134. var _view = new
  1135. {
  1136. PageFuncAuth = pageFunAuthView,
  1137. Data = _DelegationList
  1138. };
  1139. return Ok(JsonView(true, "查询成功!", _view, total));
  1140. }
  1141. /// <summary>
  1142. /// 接团信息详情
  1143. /// </summary>
  1144. /// <param name="dto">团组info请求dto</param>
  1145. /// <returns></returns>
  1146. [HttpPost]
  1147. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1148. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  1149. {
  1150. var groupData = await _groupRepository.GetGroupInfo(dto);
  1151. if (groupData.Code != 0)
  1152. {
  1153. return Ok(JsonView(false, groupData.Msg));
  1154. }
  1155. return Ok(JsonView(groupData.Data));
  1156. }
  1157. /// <summary>
  1158. /// 接团信息 编辑添加
  1159. /// 基础信息数据源
  1160. /// </summary>
  1161. /// <param name="dto"></param>
  1162. /// <returns></returns>
  1163. [HttpPost]
  1164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1165. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  1166. {
  1167. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  1168. if (groupData.Code != 0)
  1169. {
  1170. return Ok(JsonView(false, groupData.Msg));
  1171. }
  1172. return Ok(JsonView(groupData.Data));
  1173. }
  1174. /// <summary>
  1175. /// 成本修改团组信息
  1176. /// </summary>
  1177. /// <param name="dto"></param>
  1178. /// <returns></returns>
  1179. [HttpPost]
  1180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1181. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  1182. {
  1183. var jw = JsonView(false, "操作失败");
  1184. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  1185. if (di == null)
  1186. {
  1187. jw.Msg = "参数有误!";
  1188. return Ok(jw);
  1189. }
  1190. #region 添加出访起止时间
  1191. var startTime = new DateTime();
  1192. var endTime = new DateTime();
  1193. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1194. {
  1195. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1196. }
  1197. else
  1198. {
  1199. jw.Msg = "参数有误!";
  1200. return Ok(jw);
  1201. }
  1202. #endregion
  1203. di.VisitDate = startTime;
  1204. di.VisitPNumber = dto.VisitPNumber;
  1205. di.VisitDays = dto.VisitDays;
  1206. di.VisitStartDate = startTime;
  1207. di.VisitEndDate = endTime;
  1208. var count = _sqlSugar.Updateable(di)
  1209. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1210. .ExecuteCommand();
  1211. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1212. }
  1213. /// <summary>
  1214. /// 接团信息 编辑添加
  1215. /// 省份-城市 基础信息数据源
  1216. /// </summary>
  1217. /// <param name="dto"></param>
  1218. /// <returns></returns>
  1219. [HttpPost]
  1220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1221. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1222. {
  1223. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1224. string search = dto.Search;
  1225. var data = await _groupRepository.CityBasicSource();
  1226. int total = data.Length;
  1227. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1228. .Skip((pageIndex - 1) * pageSize)
  1229. .Take(pageSize)
  1230. .ToArray();
  1231. return Ok(JsonView(data, total));
  1232. }
  1233. /// <summary>
  1234. /// 接团信息 操作(增改)
  1235. /// </summary>
  1236. /// <param name="dto"></param>
  1237. /// <returns></returns>
  1238. [HttpPost]
  1239. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1240. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1241. {
  1242. // 创建 Stopwatch 实例
  1243. Stopwatch stopwatch = Stopwatch.StartNew();
  1244. decimal ffrPrice = 0.00M;
  1245. DateTime? visitDt = null;
  1246. if (dto.Status == 2)
  1247. {
  1248. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1249. if (groupInfo != null)
  1250. {
  1251. ffrPrice = groupInfo.PaymentMoney;
  1252. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1253. }
  1254. }
  1255. var groupData = await _groupRepository.GroupOperation(dto);
  1256. if (groupData.Code != 0)
  1257. {
  1258. return Ok(JsonView(false, groupData.Msg));
  1259. }
  1260. int diId = 0;
  1261. try
  1262. {
  1263. //添加时 默认加入团组汇率
  1264. if (dto.Status == 1) //添加
  1265. {
  1266. diId = groupData.Data;
  1267. //添加默认币种
  1268. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1269. //默认分配权限
  1270. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1271. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1272. var _managerIds = new List<int>() { 22, 32, 21 };
  1273. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1274. if (userIds.Count > 0)
  1275. {
  1276. userIds.Add(208);
  1277. //创建团组管控
  1278. GroupStepForDelegation.CreateWorkStep(diId);
  1279. //发送消息
  1280. string groupName = dto.TeamName;
  1281. string createGroupUser = string.Empty;
  1282. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1283. if (userInfo != null) createGroupUser = userInfo.CnName;
  1284. string title = $"系统通知";
  1285. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1286. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1287. }
  1288. //默认创建倒推表
  1289. await _invertedListRep._Create(dto.UserId, diId);
  1290. //默认创建签证流程
  1291. await _visaProcessRep.Create(dto.UserId, diId);
  1292. //默认创建团组流程总览信息
  1293. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1294. }
  1295. else if (dto.Status == 2)
  1296. {
  1297. diId = dto.Id;
  1298. }
  1299. #region 签证人员团组时间通知
  1300. #region 计算出访起止时间
  1301. var startTime = new DateTime();
  1302. var endTime = new DateTime();
  1303. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1304. {
  1305. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1306. }
  1307. #endregion
  1308. #endregion
  1309. #region 团组操作默认添加/修改收款账单
  1310. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1311. {
  1312. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1313. .Where(x => x.IsDel == 0 &&
  1314. x.Diid == diId &&
  1315. x.Remark.Equals("预付款")
  1316. )
  1317. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1318. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1319. .FirstAsync();
  1320. ffrInfo = new Fin_ForeignReceivables()
  1321. {
  1322. Diid = diId,
  1323. PriceName = dto.ClientUnit,
  1324. Price = dto.PaymentMoney,
  1325. Count = 1,
  1326. Unit = $"元",
  1327. ItemSumPrice = dto.PaymentMoney,
  1328. Rate = 1.0000M,
  1329. Currency = 836,
  1330. AddingWay = 0,
  1331. CreateUserId = dto.UserId,
  1332. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1333. Remark = $"预付款"
  1334. };
  1335. if (ffrInfo == null) //Add
  1336. {
  1337. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1338. }
  1339. else //修改
  1340. {
  1341. await _sqlSugar.Updateable(ffrInfo)
  1342. .UpdateColumns(x => new
  1343. {
  1344. x.PriceName,
  1345. x.Price,
  1346. x.ItemSumPrice,
  1347. x.CreateTime,
  1348. x.CreateUserId
  1349. })
  1350. .WhereColumns(x => x.Id)
  1351. .ExecuteCommandAsync();
  1352. }
  1353. }
  1354. #endregion
  1355. if (diId > 0)
  1356. {
  1357. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1358. }
  1359. // 停止计时
  1360. stopwatch.Stop();
  1361. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1362. }
  1363. catch (Exception ex)
  1364. {
  1365. // 停止计时
  1366. stopwatch.Stop();
  1367. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1368. Logs(ex.Message);
  1369. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1370. }
  1371. // 停止计时
  1372. stopwatch.Stop();
  1373. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1374. }
  1375. /// <summary>
  1376. /// 接团流程操作(增改)
  1377. /// 安卓端使用 建团时添加客户名单
  1378. /// </summary>
  1379. /// <param name="dto"></param>
  1380. /// <returns></returns>
  1381. [HttpPost]
  1382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1383. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1384. {
  1385. #region 参数验证
  1386. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1387. #region 页面操作权限验证
  1388. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1389. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1390. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1391. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1392. #endregion
  1393. #endregion
  1394. try
  1395. {
  1396. //_sqlSugar.BeginTran();
  1397. decimal ffrPrice = 0.00M;
  1398. DateTime? visitDt = null;
  1399. if (dto.Status == 2)
  1400. {
  1401. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1402. if (groupInfo != null)
  1403. {
  1404. ffrPrice = groupInfo.PaymentMoney;
  1405. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1406. }
  1407. }
  1408. var _dto = new GroupOperationDto();
  1409. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1410. var groupData = await _groupRepository.GroupOperation(_dto);
  1411. if (groupData.Code != 0)
  1412. {
  1413. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1414. }
  1415. int diId = 0;
  1416. //添加时 默认加入团组汇率
  1417. if (dto.Status == 1) //添加
  1418. {
  1419. diId = groupData.Data;
  1420. //添加默认币种
  1421. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1422. //默认分配权限
  1423. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1424. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1425. var _managerIds = new List<int>() { 21, 22, 32 };
  1426. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1427. if (userIds.Count > 0)
  1428. {
  1429. userIds.Add(208);
  1430. //创建团组管控
  1431. GroupStepForDelegation.CreateWorkStep(diId);
  1432. //发送消息
  1433. string groupName = dto.TeamName;
  1434. string createGroupUser = string.Empty;
  1435. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1436. if (userInfo != null) createGroupUser = userInfo.CnName;
  1437. string title = $"系统通知";
  1438. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1439. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1440. }
  1441. #region 应用推送
  1442. try
  1443. {
  1444. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1445. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1446. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1447. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1448. {
  1449. var userList = new List<string>() { users.QiyeChatUserId };
  1450. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1451. }
  1452. }
  1453. catch (Exception ex)
  1454. {
  1455. }
  1456. #endregion
  1457. //默认创建倒推表
  1458. await _invertedListRep._Create(dto.UserId, diId);
  1459. //默认创建签证流程
  1460. await _visaProcessRep.Create(dto.UserId, diId);
  1461. //默认创建团组流程总览信息
  1462. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1463. }
  1464. if (dto.Status == 2)
  1465. {
  1466. diId = dto.Id;
  1467. if (diId == 0)
  1468. {
  1469. //_sqlSugar.RollbackTran();
  1470. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1471. }
  1472. }
  1473. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1474. if (viewData.Code != 0)
  1475. {
  1476. //_sqlSugar.RollbackTran();
  1477. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1478. }
  1479. #region 团组操作默认添加/修改收款账单
  1480. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1481. {
  1482. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1483. .Where(x => x.IsDel == 0 &&
  1484. x.Diid == diId &&
  1485. x.Remark.Equals("预付款")
  1486. )
  1487. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1488. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1489. .FirstAsync();
  1490. ffrInfo = new Fin_ForeignReceivables()
  1491. {
  1492. Diid = diId,
  1493. PriceName = dto.ClientUnit,
  1494. Price = dto.PaymentMoney,
  1495. Count = 1,
  1496. Unit = $"元",
  1497. ItemSumPrice = dto.PaymentMoney,
  1498. Rate = 1.0000M,
  1499. Currency = 836,
  1500. AddingWay = 0,
  1501. CreateUserId = dto.UserId,
  1502. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1503. Remark = $"预付款"
  1504. };
  1505. if (ffrInfo == null) //Add
  1506. {
  1507. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1508. }
  1509. else //修改
  1510. {
  1511. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1512. .UpdateColumns(x => new
  1513. {
  1514. x.PriceName,
  1515. x.Price,
  1516. x.ItemSumPrice,
  1517. x.CreateTime,
  1518. x.CreateUserId
  1519. })
  1520. .WhereColumns(x => x.Id)
  1521. .ExecuteCommandAsync();
  1522. }
  1523. }
  1524. #endregion
  1525. #region 签证人员团组时间通知
  1526. #region 计算出访起止时间
  1527. var startTime = new DateTime();
  1528. var endTime = new DateTime();
  1529. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1530. {
  1531. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1532. }
  1533. #endregion
  1534. if (diId > 0)
  1535. {
  1536. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1537. }
  1538. #endregion
  1539. //_sqlSugar.CommitTran();
  1540. return Ok(JsonView(true, "添加成功"));
  1541. }
  1542. catch (Exception ex)
  1543. {
  1544. _sqlSugar.RollbackTran();
  1545. return Ok(JsonView(false, ex.Message));
  1546. }
  1547. }
  1548. /// <summary>
  1549. /// 接团流程操作(增改)
  1550. /// 安卓端使用 建团时添加客户名单
  1551. /// </summary>
  1552. /// <param name="dto"></param>
  1553. /// <returns></returns>
  1554. [HttpPost]
  1555. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1556. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1557. {
  1558. #region 参数验证
  1559. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1560. #region 页面操作权限验证
  1561. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1562. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1563. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1564. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1565. #endregion
  1566. #endregion
  1567. _sqlSugar.BeginTran();
  1568. decimal ffrPrice = 0.00M;
  1569. DateTime? visitDt = null;
  1570. if (dto.Status == 2)
  1571. {
  1572. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1573. if (groupInfo != null)
  1574. {
  1575. ffrPrice = groupInfo.PaymentMoney;
  1576. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1577. }
  1578. }
  1579. var _dto = new GroupOperationDto();
  1580. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1581. var groupData = await _groupRepository.GroupOperation(_dto);
  1582. if (groupData.Code != 0)
  1583. {
  1584. _sqlSugar.RollbackTran();
  1585. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1586. }
  1587. try
  1588. {
  1589. int diId = 0;
  1590. //添加时 默认加入团组汇率
  1591. if (dto.Status == 1) //添加
  1592. {
  1593. diId = groupData.Data;
  1594. //添加默认币种
  1595. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1596. //默认分配权限
  1597. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1598. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1599. var _managerIds = new List<int>() { 21, 22, 32 };
  1600. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1601. if (userIds.Count > 0)
  1602. {
  1603. userIds.Add(208);
  1604. //创建团组管控
  1605. GroupStepForDelegation.CreateWorkStep(diId);
  1606. //发送消息
  1607. string groupName = dto.TeamName;
  1608. string createGroupUser = string.Empty;
  1609. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1610. if (userInfo != null) createGroupUser = userInfo.CnName;
  1611. string title = $"系统通知";
  1612. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1613. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1614. }
  1615. #region 应用推送
  1616. try
  1617. {
  1618. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1619. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1620. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1621. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1622. {
  1623. var userList = new List<string>() { users.QiyeChatUserId };
  1624. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1625. }
  1626. }
  1627. catch (Exception ex)
  1628. {
  1629. _sqlSugar.CommitTran();
  1630. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1631. }
  1632. #endregion
  1633. //默认创建倒推表
  1634. await _invertedListRep._Create(dto.UserId, diId);
  1635. }
  1636. else if (dto.Status == 2)
  1637. {
  1638. diId = dto.Id;
  1639. if (diId == 0)
  1640. {
  1641. _sqlSugar.RollbackTran();
  1642. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1643. }
  1644. }
  1645. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1646. if (viewData.Code != 0)
  1647. {
  1648. _sqlSugar.RollbackTran();
  1649. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1650. }
  1651. #region 团组操作默认添加/修改收款账单
  1652. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1653. {
  1654. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1655. .Where(x => x.IsDel == 0 &&
  1656. x.Diid == diId &&
  1657. x.Remark.Equals("预付款")
  1658. )
  1659. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1660. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1661. .FirstAsync();
  1662. ffrInfo = new Fin_ForeignReceivables()
  1663. {
  1664. Diid = diId,
  1665. PriceName = dto.ClientUnit,
  1666. Price = dto.PaymentMoney,
  1667. Count = 1,
  1668. Unit = $"元",
  1669. ItemSumPrice = dto.PaymentMoney,
  1670. Rate = 1.0000M,
  1671. Currency = 836,
  1672. AddingWay = 0,
  1673. CreateUserId = dto.UserId,
  1674. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1675. Remark = $"预付款"
  1676. };
  1677. if (ffrInfo == null) //Add
  1678. {
  1679. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1680. }
  1681. else //修改
  1682. {
  1683. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1684. .UpdateColumns(x => new
  1685. {
  1686. x.PriceName,
  1687. x.Price,
  1688. x.ItemSumPrice,
  1689. x.CreateTime,
  1690. x.CreateUserId
  1691. })
  1692. .WhereColumns(x => x.Id)
  1693. .ExecuteCommandAsync();
  1694. }
  1695. }
  1696. #endregion
  1697. #region 签证人员团组时间通知
  1698. #region 计算出访起止时间
  1699. var startTime = new DateTime();
  1700. var endTime = new DateTime();
  1701. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1702. {
  1703. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1704. }
  1705. #endregion
  1706. if (diId > 0)
  1707. {
  1708. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1709. }
  1710. #endregion
  1711. _sqlSugar.CommitTran();
  1712. return Ok(JsonView(true));
  1713. }
  1714. catch (Exception ex)
  1715. {
  1716. _sqlSugar.RollbackTran();
  1717. return Ok(JsonView(false, ex.Message));
  1718. }
  1719. }
  1720. /// <summary>
  1721. /// 接团信息 操作(删除)
  1722. /// </summary>
  1723. /// <param name="dto"></param>
  1724. /// <returns></returns>
  1725. [HttpPost]
  1726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1727. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1728. {
  1729. var diId = dto.Id;
  1730. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1731. #region 删除 验证
  1732. /*
  1733. * 1、收款账单数据:0 条
  1734. * 2、收款退还数据:0 条
  1735. * 3、机票费用数据:0 条
  1736. * 4、签证费用数据:0 条
  1737. * 5、保险费用数据:0 条
  1738. * 6、酒店费用数据:0 条
  1739. * 7、公务出访数据:1 条
  1740. * 8、邀请公务活动费用数据:1 条
  1741. * 9、OP费用数据:5 条
  1742. * 10、其他费用数据:0 条
  1743. * 11、团组日付报销费用数据:0 条
  1744. *
  1745. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1746. */
  1747. //收款账单
  1748. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  1749. //收款退还
  1750. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1751. //机票费用
  1752. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1753. //签证费用
  1754. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  1755. //保险费用
  1756. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1757. //酒店费用
  1758. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1759. //公务出访
  1760. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1761. //邀请公务活动费用
  1762. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1763. //OP费用
  1764. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1765. //其他费用
  1766. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  1767. //团组日付报销费用
  1768. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  1769. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  1770. if (feeCount > 0)
  1771. {
  1772. var delMsgTips = new StringBuilder();
  1773. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  1774. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  1775. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  1776. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  1777. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  1778. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  1779. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  1780. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  1781. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  1782. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  1783. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  1784. delMsgTips.AppendLine($"");
  1785. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  1786. return Ok(JsonView(false, delMsgTips.ToString()));
  1787. }
  1788. #endregion
  1789. var groupData = await _groupRepository.GroupDel(dto);
  1790. if (groupData.Code != 0)
  1791. {
  1792. return Ok(JsonView(false, groupData.Msg));
  1793. }
  1794. return Ok(JsonView(true));
  1795. }
  1796. /// <summary>
  1797. /// 获取团组销售报价号
  1798. /// 团组添加时 使用
  1799. /// </summary>
  1800. /// <returns></returns>
  1801. [HttpPost]
  1802. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1803. public async Task<IActionResult> GetGroupSalesQuoteNo()
  1804. {
  1805. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  1806. if (groupData.Code != 0)
  1807. {
  1808. return Ok(JsonView(false, groupData.Msg));
  1809. }
  1810. object salesQuoteNo = new
  1811. {
  1812. SalesQuoteNo = groupData.Data
  1813. };
  1814. return Ok(JsonView(salesQuoteNo));
  1815. }
  1816. /// <summary>
  1817. /// 设置确认出团
  1818. /// </summary>
  1819. /// <param name="dto"></param>
  1820. /// <returns></returns>
  1821. [HttpPost]
  1822. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1823. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  1824. {
  1825. var groupData = await _groupRepository.ConfirmationGroup(dto);
  1826. if (groupData.Code != 0)
  1827. {
  1828. return Ok(JsonView(false, groupData.Msg));
  1829. }
  1830. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  1831. #region OA消息推送
  1832. try
  1833. {
  1834. string groupName = groupInfo.TeamName;
  1835. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  1836. string title = $"系统通知";
  1837. string content = $"团组[{groupName}]已确认出团!";
  1838. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  1839. }
  1840. catch (Exception ex)
  1841. {
  1842. }
  1843. #endregion
  1844. #region 应用推送
  1845. try
  1846. {
  1847. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  1848. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  1849. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1850. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1851. {
  1852. var userList = new List<string>() { users.QiyeChatUserId };
  1853. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  1854. }
  1855. }
  1856. catch (Exception ex)
  1857. {
  1858. }
  1859. #endregion
  1860. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  1861. return Ok(JsonView(true, "操作成功!", groupData.Data));
  1862. }
  1863. /// <summary>
  1864. /// 获取团组名称data And 签证国别Data
  1865. /// </summary>
  1866. /// <param name="dto"></param>
  1867. /// <returns></returns>
  1868. [HttpPost]
  1869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1870. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  1871. {
  1872. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  1873. if (groupData.Code != 0)
  1874. {
  1875. return Ok(JsonView(false, groupData.Msg));
  1876. }
  1877. return Ok(JsonView(groupData.Data));
  1878. }
  1879. /// <summary>
  1880. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  1881. /// </summary>
  1882. /// <returns></returns>
  1883. [HttpPost]
  1884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1885. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  1886. {
  1887. try
  1888. {
  1889. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  1890. if (groupData.Code != 0)
  1891. {
  1892. return Ok(JsonView(false, groupData.Msg));
  1893. }
  1894. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  1895. }
  1896. catch (Exception ex)
  1897. {
  1898. return Ok(JsonView(false, ex.Message));
  1899. throw;
  1900. }
  1901. }
  1902. /// <summary>
  1903. /// 团组清单 Excel
  1904. /// </summary>
  1905. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  1906. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  1907. /// <returns></returns>
  1908. [HttpGet]
  1909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1910. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  1911. {
  1912. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  1913. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  1914. if (!beginBool && !endBool)
  1915. {
  1916. return Ok(JsonView(false, "开始或结束时间不正确!"));
  1917. }
  1918. string sql = string.Format(@"
  1919. SELECT
  1920. ROW_NUMBER,
  1921. Id,
  1922. SalesQuoteNo,
  1923. TourCode,
  1924. TeamTypeId,
  1925. TeamType,
  1926. TeamLevId,
  1927. TeamLev,
  1928. TeamName,
  1929. ClientName,
  1930. ClientUnit,
  1931. VisitDate,
  1932. VisitDays,
  1933. VisitPNumber,
  1934. JietuanOperatorId,
  1935. JietuanOperator,
  1936. IsSure,
  1937. CreateUserName,
  1938. IsBid
  1939. FROM
  1940. (
  1941. SELECT
  1942. ROW_NUMBER() OVER(
  1943. ORDER BY
  1944. gdi.VisitDate Desc
  1945. ) AS ROW_NUMBER,
  1946. gdi.Id,
  1947. SalesQuoteNo,
  1948. TourCode,
  1949. ssd.Id TeamTypeId,
  1950. ssd.Name TeamType,
  1951. ssd1.Id TeamLevId,
  1952. ssd1.Name TeamLev,
  1953. TeamName,
  1954. ClientName,
  1955. ClientUnit,
  1956. VisitDate,
  1957. VisitDays,
  1958. VisitPNumber,
  1959. JietuanOperator JietuanOperatorId,
  1960. su.CnName JietuanOperator,
  1961. IsSure,
  1962. gdi.CreateTime,
  1963. su1.CnName As CreateUserName,
  1964. gdi.IsBid
  1965. FROM
  1966. Grp_DelegationInfo gdi
  1967. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1968. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1969. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1970. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  1971. WHERE
  1972. gdi.IsDel = 0
  1973. AND gdi.IsBid = 0
  1974. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  1975. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  1976. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  1977. #region 处理所属部门
  1978. /*
  1979. * 1.sq 和 gyy 等显示 市场部
  1980. * 2.王鸽和主管及张总还有管理员号统一国交部
  1981. * 2-1. 4 管理员 ,21 张海麟
  1982. */
  1983. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  1984. var userIds1 = new List<int>() { 4, 21 };
  1985. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  1986. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1987. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1988. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1989. .ToListAsync();
  1990. var droupIds = groupList.Select(it => it.Id).ToList();
  1991. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  1992. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  1993. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  1994. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  1995. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  1996. {
  1997. DiId = tcl.DiId,
  1998. LastName = dc.LastName,
  1999. FirstName = dc.FirstName,
  2000. Sex = dc.Sex,
  2001. Birthday = dc.BirthDay,
  2002. Company = cc.CompanyFullName,
  2003. Job = dc.Job,
  2004. CreateTime = tcl.CreateTime,
  2005. })
  2006. .ToList();
  2007. foreach (var item in groupList)
  2008. {
  2009. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  2010. string groupFirstName = "";
  2011. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  2012. if (currDatas.Any())
  2013. {
  2014. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  2015. }
  2016. item.GroupFirst = groupFirstName;
  2017. }
  2018. #endregion
  2019. #region Excel
  2020. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  2021. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  2022. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  2023. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  2024. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  2025. //载入模板
  2026. var designer = new WorkbookDesigner
  2027. {
  2028. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  2029. };
  2030. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  2031. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  2032. dt.TableName = "GroupList";
  2033. designer.SetDataSource(dt);
  2034. designer.Process();
  2035. if (!Directory.Exists(savePath))
  2036. {
  2037. Directory.CreateDirectory(savePath);
  2038. }
  2039. string serverPath = $"{savePath}{fileName}";
  2040. designer.Workbook.Save(serverPath);
  2041. string rst = $"{servicePath}{ftpPath}{fileName}";
  2042. #endregion
  2043. return Ok(JsonView(true, "操作成功!", rst));
  2044. }
  2045. /// <summary>
  2046. /// 团组合同下载(1.付款80% 2.付全款)
  2047. /// </summary>
  2048. /// <param name="dto"></param>
  2049. /// <returns></returns>
  2050. /// <exception cref="Exception"></exception>
  2051. [HttpPost]
  2052. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  2053. {
  2054. var jw = JsonView(false);
  2055. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  2056. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  2057. if (di == null)
  2058. {
  2059. jw.Msg = "团组Id有误!";
  2060. return Ok(jw);
  2061. }
  2062. #region 权限校验
  2063. var allDownFile = new List<int>() { 21 };
  2064. try
  2065. {
  2066. var setting = _sqlSugar.Queryable<Sys_SetData>()
  2067. .First(x => x.Id == 1418 && x.IsDel == 0);
  2068. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  2069. }
  2070. catch (Exception)
  2071. { }
  2072. var guojiaoDownFile = new List<int>() { 330, 383 };
  2073. var shichangDownFile = new List<int>() { 95 };
  2074. if (allDownFile.Contains(dto.UserId))
  2075. {
  2076. }
  2077. else if (guojiaoDownFile.Contains(dto.UserId))
  2078. {
  2079. var guojiaobuDi = new List<int>() { 4, 21 };
  2080. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  2081. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  2082. .Where((d, u) => u.Id == di.JietuanOperator)
  2083. .Select((d, u) => d.DepName)
  2084. .First();
  2085. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  2086. {
  2087. jw.Msg = "暂无下载权限!";
  2088. return Ok(jw);
  2089. }
  2090. }
  2091. else if (shichangDownFile.Contains(dto.UserId))
  2092. {
  2093. var dic = new Dictionary<int, int[]>()
  2094. {
  2095. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  2096. };
  2097. try
  2098. {
  2099. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  2100. if (sqSetting != null)
  2101. {
  2102. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  2103. foreach (var item in result.Keys)
  2104. {
  2105. if (dic.ContainsKey(item))
  2106. {
  2107. int[] dilatation = new int[dic[item].Length + result[item].Length];
  2108. Array.Copy(dic[item], dilatation, dic[item].Length);
  2109. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  2110. dic[item] = dilatation;
  2111. }
  2112. else
  2113. {
  2114. dic.Add(item, result[item]);
  2115. }
  2116. }
  2117. }
  2118. if (!dic[95].Contains(di.CreateUserId))
  2119. {
  2120. jw.Msg = "暂无下载权限!";
  2121. return Ok(jw);
  2122. }
  2123. }
  2124. catch (Exception)
  2125. { }
  2126. }
  2127. else if (dto.UserId == di.CreateUserId)
  2128. {
  2129. }
  2130. else
  2131. {
  2132. jw.Msg = "暂无下载权限!";
  2133. return Ok(jw);
  2134. }
  2135. #endregion
  2136. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  2137. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  2138. .ToListAsync();
  2139. if (!blackCodeList.Any())
  2140. {
  2141. jw.Msg = "该团无机票行程代码!";
  2142. return Ok(jw);
  2143. }
  2144. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  2145. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  2146. if (groupEnterExitCost == null)
  2147. {
  2148. jw.Msg = "暂无三公费用信息!";
  2149. return Ok(jw);
  2150. }
  2151. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  2152. rateList ??= new List<CurrencyInfo>();
  2153. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  2154. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  2155. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  2156. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  2157. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  2158. .Select((x, a, b) => new
  2159. {
  2160. x.Index,
  2161. itemName = a.Name,
  2162. CurrencyStr = b.Name,
  2163. x.Cost,
  2164. x.SubTotal,
  2165. x.Remark
  2166. })
  2167. .OrderBy((x) => x.Index)
  2168. .ToList();
  2169. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  2170. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  2171. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  2172. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  2173. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  2174. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  2175. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  2176. decimal subJJC = 0.00M,
  2177. subGWC = 0.00M,
  2178. subTDC = 0.00M;
  2179. //经济舱
  2180. if (groupEnterExitCost.SumJJC == 1)
  2181. {
  2182. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  2183. }
  2184. //公务舱
  2185. if (groupEnterExitCost.SumGWC == 1)
  2186. {
  2187. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  2188. }
  2189. //头等舱
  2190. if (groupEnterExitCost.SumTDC == 1)
  2191. {
  2192. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  2193. }
  2194. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  2195. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  2196. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  2197. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2198. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2199. .Select((x, s, dc, cc) => new GroupClints
  2200. {
  2201. Id = x.Id,
  2202. Name = s.Name,
  2203. IsAccompany = x.IsAccompany,
  2204. CompanyFullName = cc.CompanyFullName
  2205. })
  2206. .ToListAsync();
  2207. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2208. //获取舱位人数
  2209. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2210. .GroupBy(x => x.Name)
  2211. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2212. .ToList();
  2213. string cityPath = string.Empty;
  2214. string startCity = string.Empty;
  2215. string endCity = string.Empty;
  2216. foreach (var item in blackCodeList)
  2217. {
  2218. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2219. cityPath += city + "\r\n";
  2220. if (item.Equals(blackCodeList.First()))
  2221. {
  2222. var sp = city.Split('-');
  2223. startCity = sp[0];
  2224. endCity = sp[^1];
  2225. }
  2226. }
  2227. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2228. var bookMarkDic = new Dictionary<string, string>
  2229. {
  2230. { "ClientUnit", di.ClientUnit },
  2231. { "VisitCountry", di.VisitCountry },
  2232. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2233. { "VisitPNumber", di.VisitPNumber.ToString() },
  2234. { "CityPath", cityPath },
  2235. { "StartCity", startCity },
  2236. { "EndCity", endCity },
  2237. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2238. };
  2239. Document doc = null;
  2240. var percentage = 0.8M;
  2241. var fileNameadd = "预付";
  2242. if (dto.FileType == 1)
  2243. {
  2244. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2245. }
  2246. else if (dto.FileType == 2)
  2247. {
  2248. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2249. percentage = 1;
  2250. fileNameadd = "全款";
  2251. }
  2252. else
  2253. {
  2254. throw new Exception("FileType有误!");
  2255. }
  2256. var builder = new DocumentBuilder(doc);
  2257. decimal totalPrice = 0.00M;
  2258. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2259. if (firstTable != null)
  2260. {
  2261. // 遍历表格的行和单元格
  2262. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2263. {
  2264. for (int i = 0; i < row.Cells.Count; i++)
  2265. {
  2266. var cell = row.Cells[i];
  2267. // 读取单元格内容
  2268. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2269. if (cellTextFirst.Contains("舱位"))
  2270. {
  2271. break;
  2272. }
  2273. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2274. {
  2275. if (i == 2)
  2276. {
  2277. if (cellTextFirst == "经济舱")
  2278. {
  2279. // 设置单元格内容
  2280. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2281. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2282. }
  2283. else
  2284. {
  2285. // 设置单元格内容
  2286. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2287. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2288. }
  2289. }
  2290. if (i == 3)
  2291. {
  2292. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2293. if (count != null)
  2294. {
  2295. // 设置单元格内容
  2296. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2297. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2298. }
  2299. }
  2300. if (i == 4)
  2301. {
  2302. var rowPrice = 0.00M;
  2303. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2304. count ??= 0;
  2305. if (cellTextFirst == "经济舱")
  2306. {
  2307. rowPrice = subJJC * (int)count;
  2308. }
  2309. else
  2310. {
  2311. rowPrice = subGWC * (int)count;
  2312. }
  2313. totalPrice += rowPrice;
  2314. // 设置单元格内容
  2315. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2316. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2317. }
  2318. }
  2319. }
  2320. }
  2321. }
  2322. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2323. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2324. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2325. //--合同表格部分
  2326. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2327. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2328. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2329. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2330. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2331. bookMarkDic.Add("CityPath1", cityPath);
  2332. bookMarkDic.Add("CityPath2", cityPath);
  2333. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2334. if (contractTable != null)
  2335. {
  2336. //数据源
  2337. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2338. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2339. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2340. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2341. .Select((it, y, s) => new
  2342. {
  2343. it.Cost,
  2344. it.SubTotal,
  2345. it.Type,
  2346. y.Id,
  2347. y.City,
  2348. s.Name,
  2349. CurrencyCodeCn = s.Remark
  2350. })
  2351. .ToList()
  2352. .Select(x => new
  2353. {
  2354. CurrencyCode = x.Name,
  2355. CityId = x.Id,
  2356. x.City,
  2357. di.VisitPNumber,
  2358. x.Type,
  2359. x.Cost,
  2360. x.SubTotal,
  2361. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2362. x.CurrencyCodeCn,
  2363. });
  2364. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2365. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2366. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2367. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2368. var tableSettings = new List<tableSetting>()
  2369. {
  2370. new(){ Index = 1 , Property = "City"},
  2371. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2372. new(){ Index = 3 , Property = "Cost"},
  2373. new(){ Index = 4 , Property = "VisitPNumber"},
  2374. //new tableSetting{ Index = 5 , Property = ""},
  2375. //new tableSetting{ Index = 6 , Property = ""},
  2376. new(){ Index = 7 , Property = "Rate"},
  2377. //new tableSetting{ Index = 8 , Property = ""},
  2378. };
  2379. //1.住宿费
  2380. int cloneRow = 8;
  2381. int startDayPrice = 8; //写入index
  2382. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2383. foreach (var dac in dac1)
  2384. {
  2385. var first = dac.First();
  2386. var dayCount = dac.Count();
  2387. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2388. for (int i = 1; i < row.Cells.Count; i++)
  2389. {
  2390. var cell = row.Cells[i];
  2391. var findProperty = tableSettings.Find(x => x.Index == i);
  2392. if (findProperty != null)
  2393. {
  2394. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2395. // 设置单元格内容
  2396. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2397. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2398. }
  2399. else
  2400. {
  2401. switch (i)
  2402. {
  2403. case 5:
  2404. cell.FirstParagraph.Runs.Clear();
  2405. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2406. break;
  2407. case 6:
  2408. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2409. cell.FirstParagraph.Runs.Clear();
  2410. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2411. break;
  2412. case 8:
  2413. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2414. cell.FirstParagraph.Runs.Clear();
  2415. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2416. ZSPriceSum += xiaojiRMB;
  2417. break;
  2418. default:
  2419. break;
  2420. }
  2421. }
  2422. }
  2423. startDayPrice++;
  2424. if (!dac1.Last().Equals(dac))
  2425. {
  2426. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2427. // 将克隆的行追加到原行后面
  2428. contractTable.Rows.Insert(startDayPrice, newRow);
  2429. }
  2430. else
  2431. {
  2432. cloneRow += dac1.Count + 1;
  2433. startDayPrice = cloneRow;
  2434. }
  2435. }
  2436. //2.伙食费
  2437. foreach (var dac in dac2)
  2438. {
  2439. var first = dac.First();
  2440. var dayCount = dac.Count();
  2441. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2442. for (int i = 1; i < row.Cells.Count; i++)
  2443. {
  2444. var cell = row.Cells[i];
  2445. var findProperty = tableSettings.Find(x => x.Index == i);
  2446. if (findProperty != null)
  2447. {
  2448. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2449. // 设置单元格内容
  2450. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2451. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2452. }
  2453. else
  2454. {
  2455. switch (i)
  2456. {
  2457. case 5:
  2458. cell.FirstParagraph.Runs.Clear();
  2459. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2460. break;
  2461. case 6:
  2462. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2463. cell.FirstParagraph.Runs.Clear();
  2464. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2465. break;
  2466. case 8:
  2467. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2468. cell.FirstParagraph.Runs.Clear();
  2469. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2470. HSPriceSum += xiaojiRMB;
  2471. break;
  2472. default:
  2473. break;
  2474. }
  2475. }
  2476. }
  2477. startDayPrice++;
  2478. if (!dac2.Last().Equals(dac))
  2479. {
  2480. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2481. // 将克隆的行追加到原行后面
  2482. contractTable.Rows.Insert(startDayPrice, newRow);
  2483. }
  2484. else
  2485. {
  2486. cloneRow += dac2.Count + 1;
  2487. startDayPrice = cloneRow;
  2488. }
  2489. }
  2490. //3.公杂费
  2491. foreach (var dac in dac3)
  2492. {
  2493. var first = dac.First();
  2494. var dayCount = dac.Count();
  2495. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2496. for (int i = 1; i < row.Cells.Count; i++)
  2497. {
  2498. var cell = row.Cells[i];
  2499. var findProperty = tableSettings.Find(x => x.Index == i);
  2500. if (findProperty != null)
  2501. {
  2502. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2503. // 设置单元格内容
  2504. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2505. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2506. }
  2507. else
  2508. {
  2509. switch (i)
  2510. {
  2511. case 5:
  2512. cell.FirstParagraph.Runs.Clear();
  2513. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2514. break;
  2515. case 6:
  2516. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2517. cell.FirstParagraph.Runs.Clear();
  2518. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2519. break;
  2520. case 8:
  2521. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2522. cell.FirstParagraph.Runs.Clear();
  2523. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2524. GZPriceSum += xiaojiRMB;
  2525. break;
  2526. default:
  2527. break;
  2528. }
  2529. }
  2530. }
  2531. startDayPrice++;
  2532. if (!dac3.Last().Equals(dac))
  2533. {
  2534. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2535. // 将克隆的行追加到原行后面
  2536. contractTable.Rows.Insert(startDayPrice, newRow);
  2537. }
  2538. else
  2539. {
  2540. cloneRow += dac3.Count + 1;
  2541. startDayPrice = cloneRow;
  2542. }
  2543. }
  2544. //合并单元格
  2545. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2546. {
  2547. var currentRow = contractTable.Rows[i];
  2548. var nextRow = contractTable.Rows[i + 1];
  2549. // 获取当前行和下一行的第一个单元格
  2550. Cell currentCell = currentRow.Cells[0];
  2551. Cell nextCell = nextRow.Cells[0];
  2552. // 检查单元格内容是否一致(去除尾部的换行符)
  2553. string currentText = currentCell.GetText().Trim();
  2554. string nextText = nextCell.GetText().Trim();
  2555. if (currentText == nextText)
  2556. {
  2557. // 如果当前单元格已经被合并,找到合并的起始单元格
  2558. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2559. {
  2560. // 找到合并的起始单元格
  2561. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2562. // 将下一行的单元格设置为合并的后续单元格
  2563. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2564. }
  2565. else
  2566. {
  2567. // 如果当前单元格是合并的起始单元格
  2568. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2569. // 将下一行的单元格设置为合并的后续单元格
  2570. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2571. }
  2572. }
  2573. else
  2574. {
  2575. // 如果内容不一致,重置当前单元格的合并属性
  2576. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2577. {
  2578. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2579. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2580. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2581. }
  2582. else
  2583. {
  2584. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2585. }
  2586. }
  2587. }
  2588. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2589. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2590. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2591. }
  2592. foreach (var bookmarkName in bookMarkDic.Keys)
  2593. {
  2594. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2595. if (bookmark != null)
  2596. {
  2597. if (bookmarkName == "ClientUnit")
  2598. {
  2599. // 移动到书签位置
  2600. builder.MoveTo(bookmark.BookmarkStart);
  2601. // 设置字体样式为下划线
  2602. builder.Font.Underline = Aspose.Words.Underline.Single;
  2603. // 插入书签值
  2604. builder.Write(bookMarkDic[bookmarkName]);
  2605. // 清除字体格式,避免影响后续文本
  2606. builder.Font.ClearFormatting();
  2607. }
  2608. else
  2609. {
  2610. builder.MoveToBookmark(bookmarkName);
  2611. builder.Write(bookMarkDic[bookmarkName]);
  2612. }
  2613. }
  2614. }
  2615. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2616. doc.Save(savePaht);
  2617. jw.Msg = "生成成功!";
  2618. jw.Code = 200;
  2619. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2620. return Ok(jw);
  2621. }
  2622. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2623. {
  2624. int index = rowIndex;
  2625. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2626. {
  2627. index--;
  2628. }
  2629. return index;
  2630. }
  2631. /// <summary>
  2632. /// 报批完成企微通知
  2633. /// </summary>
  2634. /// <param name="dto"></param>
  2635. /// <returns></returns>
  2636. [HttpPost]
  2637. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2638. {
  2639. int currUserId = dto.currUserId;
  2640. int diid = dto.diid;
  2641. var jw = JsonView(true);
  2642. var users = new List<string>();
  2643. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2644. .First(x => x.Id == 1460);
  2645. try
  2646. {
  2647. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2648. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2649. //添加分配人员
  2650. // 79 车/导游地接
  2651. // 80 签证
  2652. // 81 邀请/公务活动
  2653. var setdataids = new List<int>() { 79, 81 };
  2654. foreach (var groupModule in groupModuleOperators)
  2655. {
  2656. if (setdataids.Contains(groupModule.CTableId))
  2657. {
  2658. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2659. }
  2660. }
  2661. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2662. //消息通知成功 更改团组step、记录日志
  2663. if (res)
  2664. {
  2665. var groupStep = 0; //0-新建 1-企微消息通知
  2666. //更改团组step
  2667. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2668. .SetColumns(x => new Grp_DelegationInfo()
  2669. {
  2670. Step = 2
  2671. })
  2672. .Where(x => x.Id == diid && x.IsDel == 0)
  2673. .ExecuteCommandAsync();
  2674. if (updStatus > 0) groupStep = 2;
  2675. string groupStepLabel = groupStep switch
  2676. {
  2677. 1 => "新建",
  2678. 2 => "企微消息通知(报批)",
  2679. _ => "未设置"
  2680. };
  2681. //记录日志
  2682. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2683. .Where(x => x.Id == diid && x.IsDel == 0)
  2684. .Select(x => x.TeamName)
  2685. .First() ?? "-";
  2686. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2687. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2688. .Select(x => x.CnName)
  2689. .First() ?? "-";
  2690. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2691. //设置 签证流程初始值
  2692. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2693. }
  2694. }
  2695. catch (Exception ex)
  2696. {
  2697. return Ok(JsonView(false, ex.Message));
  2698. }
  2699. return Ok(jw);
  2700. }
  2701. #endregion
  2702. #region 团组&签证
  2703. #region 团组&签证 New
  2704. /// <summary>
  2705. /// 团组&签证 New
  2706. /// DeepSeek API:测试API连通性
  2707. /// </summary>
  2708. /// <param name="file">请求dto</param>
  2709. /// <returns></returns>
  2710. [HttpPost]
  2711. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2712. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2713. {
  2714. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2715. }
  2716. /// <summary>
  2717. /// 团组&签证 New
  2718. /// DeepSeek API:检查可用端点
  2719. /// </summary>
  2720. /// <param name="file">请求dto</param>
  2721. /// <returns></returns>
  2722. [HttpPost]
  2723. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2724. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2725. {
  2726. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2727. }
  2728. /// <summary>
  2729. /// 团组&签证 New
  2730. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2731. /// </summary>
  2732. /// <param name="visaFile">文件</param>
  2733. /// <param name="fileTypeId">
  2734. /// 1. 澳新签证个人申请表
  2735. /// 2. 出国个人申请表
  2736. /// 3. 美国签证个人申请表格
  2737. /// 4. 沙特个人信息表格
  2738. /// 5. 申根签证个人资料表
  2739. /// 6. 中文个人简历模板
  2740. /// </param>
  2741. /// <returns></returns>
  2742. [HttpPost]
  2743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2744. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2745. {
  2746. //文件验证
  2747. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  2748. //var visaFiles = new VisaUploadFileTypeView();
  2749. //var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  2750. //if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  2751. //服务器存储文件
  2752. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  2753. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  2754. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  2755. using (var stream = new FileStream(filePath, FileMode.Create))
  2756. {
  2757. await visaFile.CopyToAsync(stream);
  2758. }
  2759. //日志记录-上传文件
  2760. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  2761. #region 上传文件到DeepSeekAPI
  2762. //IFormFile localFile = null;
  2763. ////获取项目中的cs文件
  2764. //try
  2765. //{
  2766. // _logger.LogInformation("读取并上传项目文件请求");
  2767. // // 1. 读取项目文件
  2768. // var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  2769. // if (readResponse.SuccessCount == 0)
  2770. // {
  2771. // return Ok(JsonView(false, "读取项目文件失败"));
  2772. // }
  2773. // localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  2774. //}
  2775. //catch (Exception ex)
  2776. //{
  2777. // _logger.LogError(ex, "读取项目文件失败");
  2778. // return Ok(JsonView(false, "读取项目文件失败"));
  2779. //}
  2780. //if (localFile == null)
  2781. //{
  2782. // return Ok(JsonView(false, "读取项目文件失败"));
  2783. //}
  2784. //var fileReq = new DeepSeekFileUploadRequest()
  2785. //{
  2786. // Files = new List<IFormFile> { localFile, visaFile },
  2787. //};
  2788. //var filesResult = new List<FileUploadResult>();
  2789. //try
  2790. //{
  2791. // _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  2792. // filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  2793. // // 需要等待处理完成
  2794. // if (fileReq.WaitForProcessing)
  2795. // {
  2796. // foreach (var result in filesResult)
  2797. // {
  2798. // if (result.Success)
  2799. // {
  2800. // try
  2801. // {
  2802. // var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  2803. // result.Status = processedFile.Status;
  2804. // }
  2805. // catch (Exception ex)
  2806. // {
  2807. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2808. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2809. // }
  2810. // }
  2811. // }
  2812. // }
  2813. //}
  2814. //catch (Exception ex)
  2815. //{
  2816. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  2817. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  2818. //}
  2819. //#endregion
  2820. //if (filesResult == null || filesResult.Count < 1)
  2821. //{
  2822. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  2823. //}
  2824. ////
  2825. //try
  2826. //{
  2827. // var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  2828. // _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  2829. // string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  2830. // var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  2831. // return Ok(response);
  2832. //}
  2833. //catch (Exception ex)
  2834. //{
  2835. // _logger.LogError(ex, "使用文件聊天失败");
  2836. // return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  2837. //}
  2838. #endregion
  2839. #region kimi API
  2840. //加载文件OpCarTouristGuideGroundContent
  2841. //kimi AI 识别文档返回json结果
  2842. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  2843. var KiMiApi = new KiMiApiClient();
  2844. var files = new List<IFormFile>() { visaFile };
  2845. var seedConter = await KiMiApi.UploadFilesAsync(files);
  2846. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  2847. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  2848. var seedMessage = string.Format(@"你是领事馆电子材料审核员,只关注 Word 里的表格,正文、页眉页脚、水印、批注全部忽略。
  2849. 任务:把表格里的每个可填字段转换成“标题:值”的键值对,标题用原文,值用原文,不翻译。
  2850. 规则如下:
  2851. 1. 行列对齐:先按视觉补齐所有合并单元格——纵向合并则重复上方单元格内容,横向合并则留空字符串;无线表按对齐虚拟列线。
  2852. 2. 单格内出现多个“□”时,把被勾选(☑、√、×、■)的选项原文输出;若没有任何勾选,该字段输出 null。
  2853. 3. 所有日期统一转 yyyy-mm-dd,原格式“1990年1月1日”→1990-01-01;若缺日/月,用-01补位。
  2854. 4. 电话、传真、手机号:输出连续数字,遇到“(0 )”或“-”一律删除,只保留 7~15 位数字;若缺区号,原样保留。
  2855. 5. 金额:保留原数字,如“3000”。
  2856. 6. 地址:省、市、区、街道、门牌、邮编用空格分隔,不省略。
  2857. 7. 若同一张表出现“现住址”“家庭地址”“单位地址”等多列,依次编号 address_home / address_unit / address_legal。
  2858. 8. 输出顺序:按表格从左到右、从上到下逐行扫描,字段名重复时加序号,如 child_name_1、child_name_2。
  2859. 9. 结果格式:每行一个键值对,字段名与值之间用英文冒号+空格分隔,不要表格 Markdown,不要多余说明。
  2860. 10. 文件命名空间:每份表的最前面加一行 filename 作为起始标记(例:出国个人申请表.doc)。
  2861. 11. 内容为空的字段,显示标题,记空值。
  2862. 12. 只返回json结果,不需要其他内容;json内容去掉换行。");
  2863. var messages = new List<SeedMessages>
  2864. {
  2865. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  2866. new() { Role = KimiRole.user, Content = seedMessage }
  2867. };
  2868. messages.InsertRange(1, seedConter);
  2869. string jsonString = string.Empty;
  2870. object jsonData = null;
  2871. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  2872. while (!isJson)
  2873. {
  2874. kimiAI_API_Index++;
  2875. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  2876. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  2877. jsonString += kimiApiResult_JObject["content"].ToString();
  2878. string startStr = "```json", endStr = "```";
  2879. // 判断并清除开头部分
  2880. if (jsonString.StartsWith(startStr))
  2881. {
  2882. jsonString = jsonString.Replace(startStr, "");
  2883. }
  2884. // 判断并清除结尾部分
  2885. if (jsonString.EndsWith(endStr))
  2886. {
  2887. jsonString = jsonString.Replace(endStr, "");
  2888. }
  2889. //验证json格式是否正确
  2890. try
  2891. {
  2892. jsonData = JsonDocument.Parse(jsonString);
  2893. isJson = true; // 如果解析成功,则是json格式
  2894. }
  2895. catch (Exception)
  2896. {
  2897. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  2898. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  2899. }
  2900. }
  2901. if (jsonData == null)
  2902. {
  2903. return Ok(JsonView(false, "kimi识别json转换失败。"));
  2904. }
  2905. var visaDetails = new VisaDetailsView();
  2906. //按照表格类型分别进行参数处理
  2907. // 1. 澳新签证个人申请表
  2908. // 2. 出国个人申请表
  2909. // 3. 美国签证个人申请表格
  2910. // 4. 沙特个人信息表格
  2911. // 5. 申根签证个人资料表
  2912. // 6. 中文个人简历模板
  2913. switch (fileTypeId)
  2914. {
  2915. //澳新签证个人申请表
  2916. case 1:
  2917. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2918. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  2919. break;
  2920. //美国签证个人申请表格
  2921. case 3:
  2922. _logger.LogInformation("【签证上传文件操作信息】【美国签证个人申请表格】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  2923. string name = (string)jsonData.GetType().GetProperty("姓名")!.GetValue(jsonData)!;
  2924. string passportNo = (string)jsonData.GetType().GetProperty("护照号码")!.GetValue(jsonData)!;
  2925. string passportPlace = (string)jsonData.GetType().GetProperty("护照签发地")!.GetValue(jsonData)!;
  2926. string idNo = (string)jsonData.GetType().GetProperty("身份证号码")!.GetValue(jsonData)!;
  2927. string maritalStatusText = (string)jsonData.GetType().GetProperty("婚姻状况")!.GetValue(jsonData)!;
  2928. int maritalStatus = maritalStatusText switch
  2929. {
  2930. "未设置" => 0,
  2931. "未婚" => 1,
  2932. "已婚" => 2,
  2933. "离异" => 3,
  2934. "丧偶" => 4,
  2935. _ => -1
  2936. };
  2937. string birthDay = (string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!;
  2938. DateTime.TryParse(birthDay, out DateTime birthDayDt);
  2939. string birthPlace = (string)jsonData.GetType().GetProperty("出生地点")!.GetValue(jsonData)!;
  2940. var birthDay1 = CommonFun.SplitProvinceCity(birthPlace);
  2941. string birthDay_mate = (string)jsonData.GetType().GetProperty("配偶出生日期")!.GetValue(jsonData)!;
  2942. DateTime.TryParse(birthDay_mate, out DateTime birthDayDt_mate);
  2943. string birthPlace_mate = (string)jsonData.GetType().GetProperty("配偶出生地")!.GetValue(jsonData)!;
  2944. var birthDay1_mate = CommonFun.SplitProvinceCity(birthPlace_mate);
  2945. var addressText = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  2946. var address = SplitAddressZip(addressText);
  2947. //美国驾照信息
  2948. string driveText = (string)jsonData.GetType().GetProperty("是否有美国驾照")!.GetValue(jsonData)!;
  2949. var driveInfo = LicenseParser(driveText);
  2950. //美国社会安全号或者纳税ID号
  2951. string ssnText = (string)jsonData.GetType().GetProperty("是否有美国社会安全号或者纳税ID号")!.GetValue(jsonData)!;
  2952. //单位信息
  2953. string clientName = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校")!.GetValue(jsonData)!;
  2954. string clientAddr = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校地址")!.GetValue(jsonData)!;//
  2955. var (hasSsnItin, number) = SsnItinParser(ssnText);
  2956. //婚姻相关
  2957. var WeddingText = (string)jsonData.GetType().GetProperty("若离婚,婚姻起止时间")!.GetValue(jsonData)!;
  2958. var (f, t) = WeddingParser(WeddingText);
  2959. //美国联系人电话和邮箱
  2960. var peText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2961. var usa_phone = Regex.Match(peText ?? "", @"[\d-]+").Value; // 数字和中横线
  2962. var usa_email = Regex.Match(peText ?? "", @"[^@\s]+@[^@\s]+\.[^@\s]+").Value;
  2963. //赴美时间、停留时间处理
  2964. var usa_dateText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  2965. var (usa_d, usa_days) = TravelParser(usa_dateText);
  2966. //赴美同行人
  2967. string usaCmpNameText = (string)jsonData.GetType().GetProperty("赴美同行人")!.GetValue(jsonData)!;
  2968. string usaCmpName = string.Empty;
  2969. if (usaCmpNameText.Contains("是"))
  2970. {
  2971. var usaCmpNameTextSplit = usaCmpNameText.Replace(":", "-").Replace("", "-").Split("-");
  2972. if (usaCmpNameTextSplit.Length > 1)
  2973. {
  2974. usaCmpName = usaCmpNameTextSplit[1];
  2975. }
  2976. }
  2977. //是否丢失过护照
  2978. string loseCodeText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2979. string loseCode = string.Empty;
  2980. if (loseCodeText.Contains("是"))
  2981. {
  2982. var loseCodeTextSplit = loseCodeText.Replace(":", "-").Replace("", "-").Split("-");
  2983. if (loseCodeTextSplit.Length > 1)
  2984. {
  2985. usaCmpName = loseCodeTextSplit[1];
  2986. }
  2987. }
  2988. //是否获得过美国签证
  2989. string usaVisaText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  2990. string usaVisaDateText = (string)jsonData.GetType().GetProperty("获得日期")!.GetValue(jsonData)!;
  2991. //DateTime usaVisaDate;
  2992. if (!string.IsNullOrEmpty(usaVisaDateText))
  2993. {
  2994. if (DateTime.TryParse(usaVisaDateText, out DateTime usaVisaDate))
  2995. {
  2996. visaDetails.ClientInfo.GetUSAVisaDate = usaVisaDate;
  2997. }
  2998. }
  2999. string usaFingerText = (string)jsonData.GetType().GetProperty("是否留过十指指纹")!.GetValue(jsonData)!;
  3000. int usaFinger = 0;
  3001. if (usaFingerText.Contains('是')) usaFinger = 1;
  3002. string usaLoseText = (string)jsonData.GetType().GetProperty("签证是否曾遗失")!.GetValue(jsonData)!;
  3003. int usaLose = 0;
  3004. if (usaLoseText.Contains("是")) usaLose = 1;
  3005. //是否曾抵达过美国
  3006. string usaHadArrival‌Text = (string)jsonData.GetType().GetProperty("是否曾抵达过美国")!.GetValue(jsonData)!;
  3007. var (usaHadArrivalf, usaHadArrivalD, usaHadArrivalDays) = TravelHadFlagParser(usaHadArrival‌Text);
  3008. //是否有被美国拒发签证的经历
  3009. string usaRejecteVisaTest = (string)jsonData.GetType().GetProperty("是否有被美国拒发签证的经历")!.GetValue(jsonData)!;
  3010. var (denied, rejectedDate, rejectedPlace, rejectedType) = VisaDenialParser(usaRejecteVisaTest);
  3011. if (denied)
  3012. {
  3013. visaDetails.ClientInfo.RejectedDate = rejectedDate;
  3014. visaDetails.ClientInfo.RejectedPlace = rejectedPlace;
  3015. visaDetails.ClientInfo.RejectedVisa = rejectedType;
  3016. }
  3017. //是否在申请或曾经申请过美国移民签证
  3018. string usaImmVisaText‌ = (string)jsonData.GetType().GetProperty("是否在申请或曾经申请过美国移民签证")!.GetValue(jsonData)!;
  3019. var (immDenied, immDate, immPlace, immType) = VisaDenialParser(usaImmVisaText‌);
  3020. if (immDenied)
  3021. {
  3022. visaDetails.ClientInfo.USAImmVisa‌Date = immDate;
  3023. visaDetails.ClientInfo.USAImmVisa‌Place = immPlace;
  3024. visaDetails.ClientInfo.USAImmVisa‌ = immType;
  3025. }
  3026. //在美直系
  3027. string usaImmedText‌ = (string)jsonData.GetType().GetProperty("是否有直系亲属在美国")!.GetValue(jsonData)!;
  3028. var (immedDenied, immedName, immedRel, immedStat) = FourFieldParser(usaImmedText‌);
  3029. if (immedDenied)
  3030. {
  3031. visaDetails.ClientInfo.USAImmedFamName = immedName;
  3032. visaDetails.ClientInfo.USAImmedFamRel = immedRel;
  3033. visaDetails.ClientInfo.USAImmedFamStat = immedStat;
  3034. }
  3035. //在美旁系
  3036. string usaUncleText‌ = (string)jsonData.GetType().GetProperty("是否有旁系亲属在美国")!.GetValue(jsonData)!;
  3037. var (uncleDenied, uncleName, uncleRel, uncleStat) = FourFieldParser(usaUncleText‌);
  3038. if (immedDenied)
  3039. {
  3040. visaDetails.ClientInfo.USAUncleFamName = uncleName;
  3041. visaDetails.ClientInfo.USAUncleFamRel = uncleName;
  3042. visaDetails.ClientInfo.USAUncleFamStat = uncleStat;
  3043. }
  3044. //服役时间 MilitaryParser
  3045. string militaryText‌ = (string)jsonData.GetType().GetProperty("是否曾参过军")!.GetValue(jsonData)!;
  3046. var (militaryH, militaryB, militaryR, militaryS, (militaryStart, militaryEnd)) = MilitaryParser(militaryText‌);
  3047. var militarys = new List<MilitaryInfo>();
  3048. if (militaryH)
  3049. {
  3050. militarys.Add(new()
  3051. {
  3052. MilBranch = militaryB,
  3053. MilRank = militaryR,
  3054. MilSkill = militaryS,
  3055. ServeTimeBegin = militaryStart,
  3056. ServeTimeEnd = militaryEnd,
  3057. });
  3058. }
  3059. //申请人父母信息 ParentParser
  3060. string fthMthText‌ = (string)jsonData.GetType().GetProperty("申请人父母信息")!.GetValue(jsonData)!;
  3061. if (!string.IsNullOrEmpty(fthMthText‌))
  3062. {
  3063. var (fName, fDob, mName, mDob) = ParentParser(fthMthText‌);
  3064. visaDetails.ClientInfo.FthName = fName;
  3065. visaDetails.ClientInfo.FthBirth = fDob;
  3066. visaDetails.ClientInfo.MthName = mName;
  3067. visaDetails.ClientInfo.MthBirth = mDob;
  3068. }
  3069. visaDetails.ClientInfo = new()
  3070. {
  3071. LastName = name.GetLastName(),
  3072. FirstName = name.GetFirstName(),
  3073. Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1,
  3074. OldName = (string)jsonData.GetType().GetProperty("曾用名")!.GetValue(jsonData)!,
  3075. BirthDay = birthDayDt,
  3076. BirthProvince = birthDay1.province,
  3077. BirthCity = birthDay1.city,
  3078. Address = address.address,
  3079. PostCodes = address.zipCode,
  3080. Marriage = maritalStatus,
  3081. MateName = (string)jsonData.GetType().GetProperty("配偶姓名")!.GetValue(jsonData)!,
  3082. MateBirthDay = birthDayDt_mate,
  3083. MateBirthCountry = birthDay1_mate.province,
  3084. MateBirthCity = birthDay1_mate.city,
  3085. USA_DLNo = driveInfo.number,
  3086. USA_DLPlace = driveInfo.place,
  3087. USA_SSNOrITIN = number,
  3088. Resident = CleanPrefix((string)jsonData.GetType().GetProperty("是否是其他国家的永久居民")!.GetValue(jsonData)!),
  3089. HasSocialAcc‌ = CleanPrefix((string)jsonData.GetType().GetProperty("近五年内是否使用过任何社交账号")!.GetValue(jsonData)!),
  3090. WeddingDate = f,
  3091. DivorceDate = t,
  3092. DivorceRsn = (string)jsonData.GetType().GetProperty("离婚原因")!.GetValue(jsonData)!,
  3093. Job = (string)jsonData.GetType().GetProperty("职务")!.GetValue(jsonData)!,
  3094. Wage = (string)jsonData.GetType().GetProperty("月薪")!.GetValue(jsonData)!,
  3095. WorkState = (string)jsonData.GetType().GetProperty("工作职责")!.GetValue(jsonData)!,
  3096. WorkDate = (string)jsonData.GetType().GetProperty("入职/入学时间(详细到月)")!.GetValue(jsonData)!,
  3097. USAAddress = (string)jsonData.GetType().GetProperty("请提供美国详细住址")!.GetValue(jsonData)!,
  3098. USAPurpose = (string)jsonData.GetType().GetProperty("赴美目的")!.GetValue(jsonData)!,
  3099. CostBearers = (string)jsonData.GetType().GetProperty("费用谁付")!.GetValue(jsonData)!,
  3100. USAContact = (string)jsonData.GetType().GetProperty("美国联系人或组织")!.GetValue(jsonData)!,
  3101. USAContactTel = usa_phone,
  3102. USAContactEmail = usa_email,
  3103. USADate = usa_d,
  3104. USADays = usa_days,
  3105. USAArrivalCity‌ = (string)jsonData.GetType().GetProperty("赴美的到达城市")!.GetValue(jsonData)!,
  3106. USADepartCity‌ = (string)jsonData.GetType().GetProperty("赴美的离开城市")!.GetValue(jsonData)!,
  3107. USAVisitSites‌ = (string)jsonData.GetType().GetProperty("计划在美国访问的景点")!.GetValue(jsonData)!,
  3108. USACmpName = usaCmpName,
  3109. USACmpRelation = (string)jsonData.GetType().GetProperty("同行人关系")!.GetValue(jsonData)!,
  3110. Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!,
  3111. ClientPhone = (string)jsonData.GetType().GetProperty("单位电话")!.GetValue(jsonData)!,
  3112. Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!,
  3113. Cntry5Y‌ = (string)jsonData.GetType().GetProperty("过去5年内到过的国家")!.GetValue(jsonData)!,
  3114. LangSkill‌ = (string)jsonData.GetType().GetProperty("面签时能流利交流的语言")!.GetValue(jsonData)!,
  3115. LoseCode = loseCode,
  3116. DenyNationRsn = (string)jsonData.GetType().GetProperty("曾被哪些国家拒签/拒签原因")!.GetValue(jsonData)!,
  3117. USAVisaCode = (string)jsonData.GetType().GetProperty("签证号码")!.GetValue(jsonData)!,
  3118. USAVisaCate = (string)jsonData.GetType().GetProperty("获签类型")!.GetValue(jsonData)!,
  3119. //GetUSAVisaDate = usaVisaDate,
  3120. USAFinger = usaFinger,
  3121. IsLose = usaLose,
  3122. USAHadArrival = usaHadArrivalD,
  3123. USAHadDays = usaHadArrivalDays,
  3124. ArmyState = JsonConvert.SerializeObject(militarys)
  3125. };
  3126. visaDetails.ClientCerts = new() {
  3127. new(){ SdId = 74,CertNo = passportNo,IDCardAddress = passportPlace },
  3128. new(){ SdId = 73,CertNo = idNo},
  3129. };
  3130. visaDetails.ClientCompany = new() { CompanyFullName = clientName, Address = clientAddr };
  3131. break;
  3132. //中文个人简历模板
  3133. case 6:
  3134. _logger.LogInformation("【签证上传文件操作信息】【中文个人简历模板】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3135. visaDetails.ClientInfo.LastName = (string)jsonData.GetType().GetProperty("姓名(中英文拼音)")!.GetValue(jsonData)!;
  3136. visaDetails.ClientInfo.Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1;
  3137. DateTime.TryParse((string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!, out DateTime birthDay11);
  3138. visaDetails.ClientInfo.BirthDay = birthDay11;
  3139. visaDetails.ClientInfo.BirthProvince = (string)jsonData.GetType().GetProperty("出生地")!.GetValue(jsonData)!;
  3140. visaDetails.ClientInfo.Address = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3141. visaDetails.ClientInfo.Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!;
  3142. visaDetails.ClientInfo.TableOpTel = (string)jsonData.GetType().GetProperty("工作电话")!.GetValue(jsonData)!;
  3143. visaDetails.ClientInfo.Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!;
  3144. visaDetails.ClientInfo.Email = (string)jsonData.GetType().GetProperty("电子邮件")!.GetValue(jsonData)!;
  3145. //学校信息
  3146. visaDetails.ClientSchools.Add(new()
  3147. {
  3148. School = (string)jsonData.GetType().GetProperty("教育学校名称")!.GetValue(jsonData)!,
  3149. Education = (string)jsonData.GetType().GetProperty("教育学位")!.GetValue(jsonData)!,
  3150. Subject = (string)jsonData.GetType().GetProperty("教育专业")!.GetValue(jsonData)!,
  3151. Remark = (string)jsonData.GetType().GetProperty("教育论文题目/研究重点(硕士、博士)")!.GetValue(jsonData)!,
  3152. });
  3153. //工作信息
  3154. visaDetails.ClientCompany = new()
  3155. {
  3156. CompanyFullName = (string)jsonData.GetType().GetProperty("工作经历雇主")!.GetValue(jsonData)!,
  3157. };
  3158. visaDetails.ClientInfo.Job = (string)jsonData.GetType().GetProperty("工作经历职位或头衔职责")!.GetValue(jsonData)!;
  3159. break;
  3160. default:
  3161. break;
  3162. }
  3163. //数据提交
  3164. #region 数据提交
  3165. _sqlSugar.BeginTran();
  3166. // 客户公司表
  3167. var compId = UpsertReturnId<Crm_CustomerCompany>(visaDetails.ClientCompany, o => o.CompanyFullName);
  3168. if (compId < 1)
  3169. {
  3170. _sqlSugar.RollbackTran();
  3171. return Ok(JsonView(false, "公司信息更新失败!"));
  3172. }
  3173. visaDetails.ClientInfo.CrmCompanyId = compId;
  3174. // 客户资料表
  3175. var clientId = UpsertReturnId<Crm_DeleClient>(visaDetails.ClientInfo, o => new { o.LastName, o.FirstName });
  3176. if (clientId < 1)
  3177. {
  3178. _sqlSugar.RollbackTran();
  3179. return Ok(JsonView(false, "客户信息更新失败!"));
  3180. }
  3181. for (int i = 0; i < visaDetails.ClientFamilys.Count(); i++)
  3182. {
  3183. visaDetails.ClientFamilys[i].DcId = clientId;
  3184. }
  3185. for (int i = 0; i < visaDetails.ClientCerts.Count(); i++)
  3186. {
  3187. visaDetails.ClientCerts[i].DcId = clientId;
  3188. }
  3189. for (int i = 0; i < visaDetails.ClientSchools.Count(); i++)
  3190. {
  3191. visaDetails.ClientSchools[i].DcId = clientId;
  3192. }
  3193. // 客户家庭表
  3194. foreach (var item in visaDetails.ClientFamilys)
  3195. {
  3196. var famId = UpsertReturnId<Crm_VisaCustomerFamily>(item, o => o.Name);
  3197. if (famId < 1)
  3198. {
  3199. _sqlSugar.RollbackTran();
  3200. return Ok(JsonView(false, "客户家庭信息更新失败!"));
  3201. }
  3202. }
  3203. // 客户证件表
  3204. foreach (var item in visaDetails.ClientCerts)
  3205. {
  3206. var certId = UpsertReturnId<Crm_CustomerCert>(item, o => o.CertNo);
  3207. if (certId < 1)
  3208. {
  3209. _sqlSugar.RollbackTran();
  3210. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3211. }
  3212. }
  3213. // 客户学历表
  3214. foreach (var item in visaDetails.ClientSchools)
  3215. {
  3216. var schoolId = UpsertReturnId<Crm_VisaCustomerSchool>(item, o => o.School);
  3217. if (schoolId < 1)
  3218. {
  3219. _sqlSugar.RollbackTran();
  3220. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3221. }
  3222. }
  3223. _sqlSugar.CommitTran();
  3224. #endregion
  3225. #endregion
  3226. return Ok(JsonView(true, jsonString));
  3227. }
  3228. #region 扩展处理
  3229. // 从 Expression<Func<T,object>> 里取出属性名
  3230. static string GetPropName<T>(Expression<Func<T, object>> expr)
  3231. {
  3232. if (expr.Body is UnaryExpression ue) expr = Expression.Lambda<Func<T, object>>(ue.Operand, expr.Parameters);
  3233. return ((MemberExpression)expr.Body).Member.Name;
  3234. }
  3235. /// <summary>
  3236. /// 5.1.4.193 可用:存在更新(非NULL非空串),不存在插入,返回主键ID
  3237. /// </summary>
  3238. public int UpsertReturnId<T>(T entity, Expression<Func<T, object>> whereExpr) where T : class, new()
  3239. {
  3240. // 1. 空字符串→NULL,让后续忽略
  3241. foreach (var pi in typeof(T).GetProperties())
  3242. if (pi.PropertyType == typeof(string) &&
  3243. pi.GetValue(entity) is string s &&
  3244. string.IsNullOrWhiteSpace(s))
  3245. pi.SetValue(entity, null);
  3246. // 2. 从表达式里拿属性名
  3247. string propName = GetPropName(whereExpr);
  3248. var propValue = typeof(T).GetProperty(propName)?.GetValue(entity);
  3249. // 3. 判断存在
  3250. bool exists = _sqlSugar.Queryable<T>().Where(propName, propValue).Any();
  3251. // 4. 执行 Upsert
  3252. if (exists)
  3253. {
  3254. _sqlSugar.Updateable(entity)
  3255. .WhereColumns(propName) // 指定条件列
  3256. .IgnoreColumns(ignoreAllNullColumns: true) // 忽略 NULL
  3257. .ExecuteCommand();
  3258. }
  3259. else
  3260. {
  3261. _sqlSugar.Insertable(entity).ExecuteReturnIdentity();
  3262. }
  3263. // 5. 返回主键值(自增/雪花已回填)
  3264. var idProp = typeof(T).GetProperties()
  3265. .First(p => p.GetCustomAttributes<SugarColumn>()
  3266. .Any(a => a.IsPrimaryKey));
  3267. return (int)idProp.GetValue(entity)!;
  3268. }
  3269. /// <summary>
  3270. /// 地址喊邮编 相关处理
  3271. /// </summary>
  3272. public static (string address, string zipCode) SplitAddressZip(string? s)
  3273. {
  3274. if (string.IsNullOrWhiteSpace(s))
  3275. return ("", "");
  3276. ReadOnlySpan<char> src = s.AsSpan();
  3277. int i = src.IndexOf("邮编".AsSpan());
  3278. if (i < 0) // 没有“邮编”字样
  3279. return (src.Trim().ToString(), "");
  3280. ReadOnlySpan<char> addr = src[..i].TrimEnd();
  3281. ReadOnlySpan<char> zip = src[(i + 3)..].Trim(); // 跳过“邮编:”
  3282. // 可能只有“邮编:”而没有数字
  3283. return (addr.IsEmpty ? "" : addr.ToString(),
  3284. zip.IsEmpty ? "" : zip.ToString());
  3285. }
  3286. /// <summary>
  3287. /// 驾照相 关处理
  3288. /// </summary>
  3289. /// <param name="raw"></param>
  3290. /// <returns></returns>
  3291. public static (bool hasLicense, string number, string place) LicenseParser(string? raw)
  3292. {
  3293. if (string.IsNullOrWhiteSpace(raw))
  3294. return (false, "", "");
  3295. // 1. 是否持有
  3296. bool has = raw.StartsWith("是", System.StringComparison.OrdinalIgnoreCase) ||
  3297. raw.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3298. // 2. 去掉前缀,按空格切
  3299. ReadOnlySpan<char> s = raw.AsSpan();
  3300. int colon = s.IndexOf(':');
  3301. ReadOnlySpan<char> after = colon < 0 ? s : s[(colon + 1)..];
  3302. after = after.Trim();
  3303. int space = after.IndexOf(' ');
  3304. ReadOnlySpan<char> num = space < 0 ? after : after[..space];
  3305. ReadOnlySpan<char> st = space < 0 ? ReadOnlySpan<char>.Empty : after[(space + 1)..];
  3306. return (has, num.ToString().Trim(), st.ToString().Trim());
  3307. }
  3308. /// <summary>
  3309. /// 美国社会安全号或者纳税ID号 相关处理
  3310. /// </summary>
  3311. /// <param name="raw"></param>
  3312. /// <returns></returns>
  3313. public static (bool hasSsnItin, string number) SsnItinParser(string? raw)
  3314. {
  3315. if (string.IsNullOrWhiteSpace(raw))
  3316. return (false, "");
  3317. ReadOnlySpan<char> s = raw.AsSpan();
  3318. // 1. 是否持有
  3319. bool has = s.StartsWith("是", System.StringComparison.Ordinal) ||
  3320. s.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3321. // 2. 取号码(去掉前缀和空格)
  3322. int colon = s.IndexOf(':');
  3323. ReadOnlySpan<char> num = colon < 0
  3324. ? ReadOnlySpan<char>.Empty
  3325. : s[(colon + 1)..].Trim();
  3326. return (has, num.ToString());
  3327. }
  3328. /// <summary>
  3329. /// 取消开始的“是:”或者“是”或者“ :”
  3330. /// </summary>
  3331. /// <param name="raw"></param>
  3332. /// <returns></returns>
  3333. public static string CleanPrefix(string? raw)
  3334. {
  3335. if (string.IsNullOrWhiteSpace(raw)) return "";
  3336. // 跳过第一个“是”或“Y”
  3337. ReadOnlySpan<char> s = raw.AsSpan();
  3338. int start = 0;
  3339. if (s.StartsWith("是") || s.StartsWith("Y", StringComparison.OrdinalIgnoreCase))
  3340. start = 1;
  3341. // 跳过连续 : 或空格
  3342. while (start < s.Length && (s[start] == ':' || s[start] == ' '))
  3343. start++;
  3344. return s[start..].Trim().ToString();
  3345. }
  3346. /// <summary>
  3347. /// 婚姻起止时间处理
  3348. /// </summary>
  3349. /// <param name="raw"></param>
  3350. /// <returns></returns>
  3351. public static (DateTime? fromDate, DateTime? toDate) WeddingParser(string? raw)
  3352. {
  3353. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3354. Regex _clean = new(@"[\s~至]+", RegexOptions.Compiled);
  3355. // 1. 把所有“空格~至”统一成 '-'
  3356. string normalized = _clean.Replace(raw, "-");
  3357. // 2. 切两段
  3358. string[] parts = normalized.Split('-', StringSplitOptions.RemoveEmptyEntries);
  3359. if (parts.Length != 2) return (null, null);
  3360. // 3. 解析
  3361. bool ff = DateTime.TryParse(parts[0].Trim(), out var from);
  3362. bool tf = DateTime.TryParse(parts[1].Trim(), out var to);
  3363. return (tf ? from : null, tf ? to : null);
  3364. }
  3365. /// <summary>
  3366. /// 出行日期和天数处理
  3367. /// </summary>
  3368. /// <param name="raw"></param>
  3369. /// <returns></returns>
  3370. public static (DateTime? travelDate, int? days) TravelParser(string? raw)
  3371. {
  3372. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3373. // 切成两段:第一段日期,第二段天数
  3374. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3375. string[] parts = sep.Split(raw.Trim());
  3376. if (parts.Length < 2) return (null, null);
  3377. bool okDate = DateTime.TryParse(parts[0], out DateTime date);
  3378. bool okDays = int.TryParse(parts[1], out int days) && days > 0;
  3379. return (okDate ? date : null, okDays ? days : null);
  3380. }
  3381. /// <summary>
  3382. /// 是否曾抵达过美国
  3383. /// </summary>
  3384. /// <param name="raw"></param>
  3385. /// <returns></returns>
  3386. public static (bool hasTravel, string date, string days) TravelHadFlagParser(string? raw)
  3387. {
  3388. if (string.IsNullOrWhiteSpace(raw)) return (false, string.Empty, string.Empty);
  3389. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3390. // 1. 是否持有
  3391. bool has = raw.AsSpan().TrimStart().StartsWith("是") ||
  3392. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3393. // 2. 用非数字分隔符切成三段:第一段空,第二段日期,第三段天数
  3394. string[] parts = sep.Split(raw.Trim());
  3395. if (parts.Length < 3) return (has, string.Empty, string.Empty);
  3396. return (has, parts[1], parts[2]);
  3397. }
  3398. /// <summary>
  3399. /// 是否有被美国拒发签证的经历
  3400. /// </summary>
  3401. /// <param name="raw"></param>
  3402. /// <returns></returns>
  3403. public static (bool wasDenied, DateTime? date, string place, string visaType) VisaDenialParser(string? raw)
  3404. {
  3405. if (string.IsNullOrWhiteSpace(raw)) return (false, null, "", "");
  3406. bool denied = raw.AsSpan().TrimStart().StartsWith("有") ||
  3407. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3408. var parts = Regex.Split(raw.Trim(), @"[^0-9A-Za-z-]+");
  3409. if (parts.Length < 4) return (denied, null, "", "");
  3410. DateTime.TryParse(parts[1], out var dt); // ← 这里改为 DateTime
  3411. return (denied, dt, parts[2], parts[3]);
  3412. }
  3413. /// <summary>
  3414. /// 在美直系、旁系 处理
  3415. /// </summary>
  3416. /// <param name="raw"></param>
  3417. /// <returns></returns>
  3418. public static (bool flag, string name, string rel, string stat) FourFieldParser(string? raw)
  3419. {
  3420. if (string.IsNullOrWhiteSpace(raw)) return (false, "", "", "");
  3421. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3422. if (parts.Length < 4) return (false, "", "", "");
  3423. bool flag = parts[0] is "有" or "是" or "Y" or "Yes";
  3424. string name = parts[1];
  3425. string rel = parts[2];
  3426. string stat = parts[3];
  3427. return (flag, name, rel, stat);
  3428. }
  3429. /// <summary>
  3430. /// 服役时间处理
  3431. /// </summary>
  3432. /// <param name="raw"></param>
  3433. /// <returns></returns>
  3434. public static (bool hasService, string branch, string rank, string specialty, (DateTime? start, DateTime? end) period) MilitaryParser(string? raw)
  3435. {
  3436. const string fmt = "yyyy年MM月dd日";
  3437. if (string.IsNullOrWhiteSpace(raw))
  3438. return (false, "", "", "", (null, null));
  3439. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3440. if (parts.Length < 5) return (false, "", "", "", (null, null));
  3441. bool has = parts[0] is "是" or "Y" or "Yes";
  3442. string branch = parts[1];
  3443. string rank = parts[2];
  3444. string specialty = parts[3];
  3445. // 拼回时间字符串
  3446. string periodRaw = string.Join(" ", parts[4..]);
  3447. var span = periodRaw.AsSpan();
  3448. int zhi = span.IndexOf("至");
  3449. if (zhi < 0) return (has, branch, rank, specialty, (null, null));
  3450. var startStr = span.Slice(0, zhi).Trim();
  3451. var endStr = span.Slice(zhi + 1).Trim();
  3452. bool okStart = DateTime.TryParseExact(startStr.ToString(), fmt, null, DateTimeStyles.None, out var start);
  3453. bool okEnd = DateTime.TryParseExact(endStr.ToString(), fmt, null, DateTimeStyles.None, out var end);
  3454. return (has, branch, rank, specialty, (okStart ? start : null, okEnd ? end : null));
  3455. }
  3456. /// <summary>
  3457. /// 申请人父母信息
  3458. /// </summary>
  3459. /// <param name="raw"></param>
  3460. /// <returns></returns>
  3461. public static (string fatherName, DateTime? fatherDob, string motherName, DateTime? motherDob) ParentParser(string? raw)
  3462. {
  3463. const string fmt = "yyyy年MM月dd日";
  3464. if (string.IsNullOrWhiteSpace(raw)) return ("", null, "", null);
  3465. // 按空格切,去掉空元素
  3466. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3467. if (parts.Length < 4) return ("", null, "", null);
  3468. // 父亲
  3469. string fName = parts[0];
  3470. DateTime.TryParseExact(parts[1], fmt, null, DateTimeStyles.None, out var fDob);
  3471. // 母亲
  3472. string mName = parts[2];
  3473. DateTime.TryParseExact(parts[3], fmt, null, DateTimeStyles.None, out var mDob);
  3474. return (fName, fDob, mName, mDob);
  3475. }
  3476. public class VisaDetailsView
  3477. {
  3478. /// <summary>
  3479. /// 客户资料表
  3480. /// </summary>
  3481. public Crm_DeleClient ClientInfo { get; set; }
  3482. /// <summary>
  3483. /// 客户家庭表
  3484. /// </summary>
  3485. public List<Crm_VisaCustomerFamily> ClientFamilys { get; set; }
  3486. /// <summary>
  3487. /// 客户公司表
  3488. /// </summary>
  3489. public Crm_CustomerCompany ClientCompany { get; set; }
  3490. /// <summary>
  3491. /// 客户证件表
  3492. /// </summary>
  3493. public List<Crm_CustomerCert> ClientCerts { get; set; }
  3494. /// <summary>
  3495. /// 客户学历表
  3496. /// </summary>
  3497. public List<Crm_VisaCustomerSchool> ClientSchools { get; set; }
  3498. }
  3499. private int GetSuccessCount(List<FileUploadResult> results)
  3500. {
  3501. var count = 0;
  3502. foreach (var result in results)
  3503. {
  3504. if (result.Success) count++;
  3505. }
  3506. return count;
  3507. }
  3508. #endregion
  3509. /// <summary>
  3510. /// 根据团组Id获取签证客户信息List
  3511. /// </summary>
  3512. /// <param name="dto">请求dto</param>
  3513. /// <returns></returns>
  3514. [HttpPost]
  3515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3516. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  3517. {
  3518. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  3519. if (groupData.Code != 0)
  3520. {
  3521. return Ok(JsonView(false, groupData.Msg));
  3522. }
  3523. return Ok(JsonView(groupData.Data));
  3524. }
  3525. /// <summary>
  3526. /// IOS获取团组签证拍照上传进度01(团组列表)
  3527. /// </summary>
  3528. /// <param name="dto">请求dto</param>
  3529. /// <returns></returns>
  3530. [HttpPost]
  3531. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3532. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  3533. {
  3534. if (dto == null)
  3535. {
  3536. return Ok(JsonView(false, "参数为空"));
  3537. }
  3538. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  3539. return Ok(JsonView(visaList));
  3540. }
  3541. /// <summary>
  3542. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  3543. /// </summary>
  3544. /// <returns></returns>
  3545. [HttpPost]
  3546. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3547. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  3548. {
  3549. if (dto == null)
  3550. {
  3551. return Ok(JsonView(false, "请求错误:"));
  3552. }
  3553. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  3554. return Ok(JsonView(list));
  3555. }
  3556. /// <summary>
  3557. /// IOS获取团组签证拍照上传进度03(相册)
  3558. /// </summary>
  3559. /// <returns></returns>
  3560. [HttpPost]
  3561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3562. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  3563. {
  3564. if (dto == null)
  3565. {
  3566. return Ok(JsonView(false, "请求错误:"));
  3567. }
  3568. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  3569. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  3570. list.ForEach(s => s.url = url);
  3571. return Ok(JsonView(list));
  3572. }
  3573. /// <summary>
  3574. /// IOS获取团组签证拍照上传进度04(图片上传)
  3575. /// </summary>
  3576. /// <param name="dto"></param>
  3577. /// <returns></returns>
  3578. [HttpPost]
  3579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3580. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  3581. {
  3582. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  3583. //if (!string.IsNullOrEmpty(result))
  3584. //{
  3585. //}
  3586. //else {
  3587. // return Ok(JsonView(false, "上传失败"));
  3588. //}
  3589. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  3590. int sucNum = 0;
  3591. try
  3592. {
  3593. foreach (var item in dto.base64DataList)
  3594. {
  3595. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  3596. string result = DecodeBase64ToImage(item, imageName);
  3597. if (!string.IsNullOrEmpty(result))
  3598. {
  3599. var pic = new Grp_VisaProgressCustomerPicture
  3600. {
  3601. CreateUserId = dto.CreateUserId,
  3602. PicName = imageName,
  3603. PicPath = result,
  3604. VisaProgressCustomerId = dto.visaProgressCustomerId
  3605. };
  3606. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  3607. if (insertResult > 0)
  3608. {
  3609. sucNum++;
  3610. }
  3611. }
  3612. }
  3613. }
  3614. catch (Exception ex)
  3615. {
  3616. return Ok(JsonView(false, ex.Message));
  3617. }
  3618. string msg = string.Format(@"成功上传{0}张", sucNum);
  3619. return Ok(JsonView(true, msg));
  3620. }
  3621. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  3622. {
  3623. string filename = "";//声明一个string类型的相对路径
  3624. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  3625. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  3626. try//会有异常抛出,try,catch一下
  3627. {
  3628. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  3629. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  3630. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  3631. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  3632. //文件名称
  3633. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  3634. //上传的文件的路径
  3635. string filePath = "";
  3636. if (!Directory.Exists(fileDir))
  3637. {
  3638. Directory.CreateDirectory(fileDir);
  3639. }
  3640. //上传的文件的路径
  3641. filePath = fileDir + filename;
  3642. //string url = HttpRuntime.AppDomainAppPath.ToString();
  3643. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  3644. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  3645. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  3646. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  3647. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  3648. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  3649. ms.Close();//关闭当前流,并释放所有与之关联的资源
  3650. bitmap.Dispose();
  3651. }
  3652. catch (Exception e)
  3653. {
  3654. string massage = e.Message;
  3655. Logs("IOS图片上传Error:" + massage);
  3656. //filename = e.Message;
  3657. }
  3658. return filename;//返回相对路径
  3659. }
  3660. /// <summary>
  3661. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  3662. /// </summary>
  3663. /// <param name="dto"></param>
  3664. /// <returns></returns>
  3665. [HttpPost]
  3666. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3667. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  3668. {
  3669. if (dto == null)
  3670. {
  3671. return Ok(JsonView(false, "请求错误:"));
  3672. }
  3673. string msg = "参数错误";
  3674. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  3675. {
  3676. try
  3677. {
  3678. //_delegationVisaRep.BeginTran();
  3679. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  3680. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  3681. .Where(s => s.Id == dto.visaProgressCustomerId)
  3682. .ExecuteCommandAsync();
  3683. if (updCount > 0 && dto.publishCode == 1)
  3684. {
  3685. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  3686. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  3687. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  3688. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  3689. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  3690. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  3691. if (groupData == null)
  3692. {
  3693. _delegationVisaRep.RollbackTran();
  3694. }
  3695. string title = string.Format(@"[签证进度更新]");
  3696. string content = string.Format(@"测试文本");
  3697. bool rst = await _message.AddMsg(new MessageDto()
  3698. {
  3699. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  3700. IssuerId = dto.publisher,
  3701. Title = title,
  3702. Content = content,
  3703. ReleaseTime = DateTime.Now,
  3704. UIdList = new List<int> {
  3705. 234
  3706. }
  3707. });
  3708. if (rst)
  3709. {
  3710. return Ok(JsonView(true, "发送通知成功"));
  3711. }
  3712. }
  3713. //_delegationVisaRep.CommitTran();
  3714. }
  3715. catch (Exception)
  3716. {
  3717. //_delegationVisaRep.RollbackTran();
  3718. }
  3719. }
  3720. return Ok(JsonView(true, msg));
  3721. }
  3722. #endregion
  3723. #endregion
  3724. #region 团组任务分配
  3725. /// <summary>
  3726. /// 团组任务分配初始化
  3727. /// </summary>
  3728. /// <returns></returns>
  3729. [HttpPost]
  3730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3731. public async Task<IActionResult> GetTaskAssignmen()
  3732. {
  3733. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  3734. if (groupData.Code != 0)
  3735. {
  3736. return Ok(JsonView(false, groupData.Msg));
  3737. }
  3738. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3739. }
  3740. /// <summary>
  3741. /// 团组任务分配查询
  3742. /// </summary>
  3743. /// <param name="dto"></param>
  3744. /// <returns></returns>
  3745. [HttpPost]
  3746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3747. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  3748. {
  3749. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  3750. if (groupData.Code != 0)
  3751. {
  3752. return Ok(JsonView(false, groupData.Msg));
  3753. }
  3754. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3755. }
  3756. /// <summary>
  3757. /// 团组任务分配操作
  3758. /// </summary>
  3759. /// <param name="dto"></param>
  3760. /// <returns></returns>
  3761. [HttpPost]
  3762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3763. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  3764. {
  3765. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  3766. if (groupData.Code != 0)
  3767. {
  3768. return Ok(JsonView(false, groupData.Msg));
  3769. }
  3770. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  3771. }
  3772. /// <summary>
  3773. /// 团组任务分配
  3774. /// 批量分配
  3775. /// 查询团组
  3776. /// </summary>
  3777. /// <param name="dto"></param>
  3778. /// <returns></returns>
  3779. [HttpPost]
  3780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3781. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  3782. {
  3783. //参数验证
  3784. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  3785. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  3786. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  3787. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  3788. }
  3789. /// <summary>
  3790. /// 团组任务分配
  3791. /// 批量分配
  3792. /// </summary>
  3793. /// <param name="dto"></param>
  3794. /// <returns></returns>
  3795. [HttpPost]
  3796. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3797. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  3798. {
  3799. //参数验证
  3800. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  3801. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  3802. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  3803. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  3804. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  3805. }
  3806. #endregion
  3807. #region 团组费用审核
  3808. /// <summary>
  3809. /// 费用审核
  3810. /// 团组列表 Page
  3811. /// </summary>
  3812. /// <param name="_dto">团组列表请求dto</param>
  3813. /// <returns></returns>
  3814. [HttpPost]
  3815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3816. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  3817. {
  3818. #region 参数验证
  3819. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3820. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3821. #region 页面操作权限验证
  3822. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3823. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3824. #endregion
  3825. #endregion
  3826. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 2) // web/Android/IOS
  3827. {
  3828. string sqlWhere = string.Empty;
  3829. if (_dto.IsSure == 0) //未完成
  3830. {
  3831. sqlWhere += string.Format(@" And IsSure = 0");
  3832. }
  3833. else if (_dto.IsSure == 1) //已完成
  3834. {
  3835. sqlWhere += string.Format(@" And IsSure = 1");
  3836. }
  3837. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  3838. {
  3839. string tj = _dto.SearchCriteria;
  3840. 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}%')",
  3841. tj, tj, tj, tj, tj);
  3842. }
  3843. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  3844. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  3845. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  3846. From (
  3847. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  3848. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  3849. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  3850. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  3851. From Grp_DelegationInfo gdi
  3852. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  3853. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  3854. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  3855. Where gdi.IsDel = 0 {0}
  3856. ) temp ", sqlWhere);
  3857. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  3858. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  3859. var _view = new
  3860. {
  3861. PageFuncAuth = pageFunAuthView,
  3862. Data = _DelegationList
  3863. };
  3864. return Ok(JsonView(true, "查询成功!", _view, total));
  3865. }
  3866. else
  3867. {
  3868. return Ok(JsonView(false, "查询失败"));
  3869. }
  3870. }
  3871. /// <summary>
  3872. /// 获取团组费用审核
  3873. /// </summary>
  3874. /// <param name="_dto"></param>
  3875. /// <returns></returns>
  3876. [HttpPost]
  3877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3878. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  3879. {
  3880. try
  3881. {
  3882. #region 参数验证
  3883. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  3884. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  3885. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  3886. #region 页面操作权限验证
  3887. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  3888. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  3889. #endregion
  3890. #endregion
  3891. var _view = new Grp_CreditCardPaymentView();
  3892. var clientNameList = GetSimplClientList(_dto.DiId);
  3893. #region 费用清单
  3894. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  3895. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  3896. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  3897. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  3898. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  3899. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  3900. /*
  3901. * 76://酒店预订
  3902. */
  3903. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3904. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3905. /*
  3906. * 79://车/导游地接
  3907. */
  3908. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3909. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3910. /*
  3911. * 80: //签证
  3912. */
  3913. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3914. /*
  3915. *81: //邀请/公务活动
  3916. */
  3917. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3918. /*
  3919. * 82: //团组客户保险
  3920. */
  3921. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3922. /*
  3923. * Lable = 85 机票预订
  3924. */
  3925. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3926. /*
  3927. * 85 机票预定
  3928. */
  3929. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3930. /*
  3931. * 98 其他款项
  3932. */
  3933. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3934. /*
  3935. * 285:收款退还
  3936. */
  3937. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3938. /*
  3939. * 1015: //超支费用
  3940. */
  3941. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  3942. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  3943. /*
  3944. * 币种信息
  3945. */
  3946. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  3947. /*
  3948. * 车/导游地接 费用类型
  3949. */
  3950. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  3951. /*
  3952. * 车/导游地接 费用类型
  3953. */
  3954. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  3955. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  3956. /*
  3957. * 用户信息
  3958. */
  3959. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  3960. /*
  3961. * 费用模块
  3962. */
  3963. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  3964. string priceModule = string.Empty;
  3965. if (sdPriceName != null)
  3966. {
  3967. priceModule = sdPriceName.Name;
  3968. }
  3969. /*
  3970. * 成本信息
  3971. */
  3972. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  3973. decimal _groupRate = 0.0000M;
  3974. string _groupCurrencyCode = "-";
  3975. if (groupCost != null)
  3976. {
  3977. _groupRate = groupCost.Rate;
  3978. if (int.TryParse(groupCost.Currency, out int _currency))
  3979. {
  3980. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  3981. }
  3982. else _groupCurrencyCode = groupCost.Currency;
  3983. }
  3984. string costContentSql = $"Select * From Grp_GroupCost";
  3985. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  3986. //处理日期为空的天数
  3987. for (int i = 0; i < groupCostDetails.Count; i++)
  3988. if (i != 0)
  3989. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  3990. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  3991. /*
  3992. * 处理详情数据
  3993. */
  3994. foreach (var entity in entityList)
  3995. {
  3996. var _detail = new Grp_CreditCardPaymentDetailView
  3997. {
  3998. Id = entity.Id,
  3999. PriceName = priceModule,
  4000. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  4001. };
  4002. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  4003. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  4004. //处理金额
  4005. if (entity.CTable == 1015)
  4006. {
  4007. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  4008. if (czInfo != null)
  4009. {
  4010. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  4011. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  4012. }
  4013. }
  4014. /*
  4015. * 应付款金额
  4016. */
  4017. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  4018. string PaymentCurrency_WaitPay = "Unknown";
  4019. string hotelCurrncyCode = "Unknown";
  4020. string hotelCurrncyName = "Unknown";
  4021. if (sdPaymentCurrency_WaitPay != null)
  4022. {
  4023. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  4024. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  4025. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  4026. if (hotelCurrncyCode.Equals("CNY"))
  4027. {
  4028. entity.DayRate = 1.0000M;
  4029. }
  4030. }
  4031. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  4032. /*
  4033. * 此次付款金额
  4034. */
  4035. decimal CurrPayStr = 0.00M,
  4036. OriginalCurrPay = 0.00M;
  4037. if (entity.PayPercentage == 0)
  4038. {
  4039. if (entity.PayThenMoney != 0)
  4040. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  4041. }
  4042. else
  4043. {
  4044. if (entity.PayMoney != 0)
  4045. {
  4046. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  4047. }
  4048. }
  4049. //if (_dto.Label == 79)
  4050. //{
  4051. // string original = string.Empty;
  4052. // if (hotelCurrncyCode.Equals("CNY"))
  4053. // {
  4054. // OriginalCurrPay = CurrPayStr;
  4055. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  4056. // }
  4057. // else
  4058. // {
  4059. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  4060. // //760 EUR(7600.00 CNY)
  4061. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  4062. // }
  4063. //}
  4064. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  4065. string original = string.Empty;
  4066. if (hotelCurrncyCode.Equals("CNY"))
  4067. {
  4068. OriginalCurrPay = CurrPayStr;
  4069. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  4070. }
  4071. else
  4072. {
  4073. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  4074. //760 EUR(7600.00 CNY)
  4075. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  4076. }
  4077. /*
  4078. * 剩余尾款
  4079. */
  4080. decimal BalanceStr = 0;
  4081. if (CurrPayStr != 0)
  4082. {
  4083. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  4084. BalanceStr = 0;
  4085. else
  4086. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  4087. }
  4088. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  4089. /*
  4090. * Bus名称
  4091. */
  4092. _detail.BusName = "待增加";
  4093. /*
  4094. *费用所属
  4095. */
  4096. switch (entity.CTable)
  4097. {
  4098. case 76://酒店预订
  4099. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4100. if (hotelReservations != null)
  4101. {
  4102. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  4103. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  4104. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  4105. string roomFeeStr = "", roomFeestr1 = "";
  4106. //是否比较房型价格
  4107. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  4108. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  4109. roomFeeStr += $"<br/>";
  4110. var roomTotal = 0.00M;
  4111. if (hotelReservations.SingleRoomPrice > 0)
  4112. {
  4113. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  4114. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4115. //__isSingle = true;
  4116. roomTotal += fee;
  4117. }
  4118. if (hotelReservations.DoubleRoomPrice > 0)
  4119. {
  4120. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  4121. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4122. // __isDouble = true;
  4123. roomTotal += fee;
  4124. }
  4125. if (hotelReservations.SuiteRoomPrice > 0)
  4126. {
  4127. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  4128. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4129. //__isSuite = true;
  4130. roomTotal += fee;
  4131. }
  4132. if (hotelReservations.OtherRoomPrice > 0)
  4133. {
  4134. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  4135. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  4136. //__isOther = true;
  4137. roomTotal += fee;
  4138. }
  4139. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  4140. else roomFeeStr += " 0.00 * 0";
  4141. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  4142. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  4143. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  4144. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  4145. /*
  4146. * 费用类型
  4147. * 1:房费
  4148. * 2:早餐
  4149. * 3:地税
  4150. * 4:城市税
  4151. * </summary>
  4152. */
  4153. //地税
  4154. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  4155. if (governmentRentData != null)
  4156. {
  4157. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  4158. governmentRentFee = governmentRentData.Price;
  4159. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  4160. if (governmentRentCurrData != null)
  4161. {
  4162. governmentRentCode = governmentRentCurrData.Name;
  4163. governmentRentName = $"({governmentRentCurrData.Remark})";
  4164. }
  4165. }
  4166. //城市税
  4167. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  4168. if (cityTaxData != null)
  4169. {
  4170. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  4171. cityTaxFee = cityTaxData.Price;
  4172. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  4173. if (cityTaxCurrData != null)
  4174. {
  4175. cityTaxCode = cityTaxCurrData.Name;
  4176. cityTaxName = $"({cityTaxCurrData.Remark})";
  4177. }
  4178. }
  4179. //酒店早餐
  4180. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  4181. if (breakfastData != null)
  4182. {
  4183. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  4184. breakfastFee = breakfastData.Price;
  4185. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  4186. if (breakfastCurrData != null)
  4187. {
  4188. breakfastCode = breakfastCurrData.Name;
  4189. breakfastName = $"({breakfastCurrData.Remark})";
  4190. }
  4191. }
  4192. //房间费用
  4193. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  4194. if (roomData != null)
  4195. {
  4196. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  4197. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  4198. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  4199. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  4200. roomFee = roomData.Price;
  4201. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  4202. if (roomCurrData != null)
  4203. {
  4204. roomCode = roomCurrData.Name;
  4205. roomName = $"({roomCurrData.Remark})";
  4206. }
  4207. }
  4208. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  4209. string hotelCostStr = "";
  4210. decimal hotelCsotTotal = 0.00M;
  4211. if (groupCost != null)
  4212. {
  4213. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  4214. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  4215. }
  4216. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  4217. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  4218. string hotelCost_day = "";
  4219. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  4220. foreach (var item in hotelCostDetails1)
  4221. {
  4222. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  4223. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  4224. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  4225. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  4226. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  4227. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  4228. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  4229. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  4230. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  4231. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  4232. hotelCost_day += @$"<br/>";
  4233. }
  4234. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  4235. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  4236. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  4237. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  4238. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  4239. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  4240. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  4241. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  4242. $"房间说明: {hotelReservations.Remark} <br/>" +
  4243. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  4244. $"{hotelBreakfastStr}" +
  4245. $"{hotelGovernmentRentStr}" +
  4246. $"{hotelCityTaxStr}";
  4247. _detail.PriceNameContent = hotelReservations.HotelName;
  4248. }
  4249. break;
  4250. case 79://车/导游地接
  4251. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4252. if (touristGuideGroundReservations != null)
  4253. {
  4254. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  4255. {
  4256. _detail.BusName = touristGuideGroundReservations.BusName;
  4257. }
  4258. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  4259. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  4260. //if (isInt)
  4261. //{
  4262. // var cityInfo = cityData.Find(it => it.Id == cityId);
  4263. // if (cityInfo != null)
  4264. // {
  4265. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  4266. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  4267. // if (carFeeItem != null)
  4268. // {
  4269. // nameContent += $@"({carFeeItem.Name})";
  4270. // }
  4271. // _detail.PriceNameContent = nameContent;
  4272. // }
  4273. //}
  4274. //else
  4275. //{
  4276. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  4277. //}
  4278. var touristGuideGroundReservationsContents =
  4279. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  4280. var opContent_sb = new StringBuilder();
  4281. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  4282. opContent_sb.AppendLine(contetTitle);
  4283. foreach (var item in touristGuideGroundReservationsContents)
  4284. {
  4285. string typeName = "Unknown";
  4286. string carCurrencyCode = "Unknown";
  4287. string carCurrencyName = "Unknown";
  4288. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  4289. if (carTypeData != null) typeName = carTypeData.Name;
  4290. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  4291. if (currencyData != null)
  4292. {
  4293. carCurrencyCode = currencyData.Name;
  4294. carCurrencyName = currencyData.Remark;
  4295. }
  4296. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  4297. bool IsCurrencyAgreement = false;
  4298. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  4299. string opCostStr = string.Empty;
  4300. decimal opCostTypePrice = 0.00M;
  4301. #region 处理成本各项费用
  4302. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  4303. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  4304. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  4305. costOPFeeCNY = 0.00M, //团组成本 op费用
  4306. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  4307. if (opCost.Count > 0)
  4308. {
  4309. switch (item.SId)
  4310. {
  4311. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  4312. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  4313. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  4314. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  4315. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  4316. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  4317. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  4318. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  4319. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  4320. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  4321. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  4322. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  4323. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  4324. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  4325. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  4326. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  4327. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  4328. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  4329. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  4330. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  4331. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  4332. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  4333. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  4334. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  4335. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  4336. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  4337. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  4338. }
  4339. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  4340. costOPFeeCNY = opCostTypePrice * _groupRate;
  4341. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  4342. }
  4343. #endregion
  4344. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  4345. aduitOPFeeCNY = item.Price * entity.DayRate;
  4346. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  4347. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  4348. $"{opTypeStr} {opCostStr}<br/>" +
  4349. $"明细:{item.PriceContent ?? "-"}<br/>" +
  4350. $"备注:{item.Remark ?? "-"}<br/><br/>";
  4351. if (entity.IsAuditGM != 3) //状态 != 自动审核
  4352. {
  4353. if (IsCurrencyAgreement)
  4354. {
  4355. if (item.Price > opCostTypePrice)
  4356. {
  4357. opContent_sb.Append("<span style='color:red;'>");
  4358. opContent_sb.Append(opContent);
  4359. opContent_sb.Append("</span>");
  4360. opContent_sb.AppendLine();
  4361. }
  4362. else
  4363. {
  4364. opContent_sb.Append(opContent);
  4365. opContent_sb.AppendLine();
  4366. }
  4367. }
  4368. else
  4369. {
  4370. //验证是否超成本 按付款比例计算
  4371. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  4372. {
  4373. opContent_sb.Append("<span style='color:red;'>");
  4374. opContent_sb.Append(opContent);
  4375. opContent_sb.Append("</span>");
  4376. opContent_sb.AppendLine();
  4377. }
  4378. else
  4379. {
  4380. opContent_sb.Append(opContent);
  4381. opContent_sb.AppendLine();
  4382. }
  4383. }
  4384. }
  4385. else
  4386. {
  4387. opContent_sb.Append(opContent);
  4388. opContent_sb.AppendLine();
  4389. }
  4390. }
  4391. _detail.PriceMsgContent = opContent_sb.ToString();
  4392. }
  4393. break;
  4394. case 80: //签证
  4395. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  4396. if (visaInfo != null)
  4397. {
  4398. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  4399. _detail.PriceNameContent = visaInfo.VisaDescription;
  4400. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  4401. }
  4402. break;
  4403. case 81: //邀请/公务活动
  4404. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  4405. if (_ioa != null)
  4406. {
  4407. string inviteCurrName = "Unknown", //邀请费用币种 Name
  4408. inviteCurrCode = "Unknown", //邀请费用币种 Code
  4409. sendCurrName = "Unknown", //快递费用币种 Name
  4410. sendCurrCode = "Unknown", //快递费用币种 Code
  4411. eventsCurrName = "Unknown", //公务活动费币种 Name
  4412. eventsCurrCode = "Unknown", //公务活动费币种 Code
  4413. translateCurrName = "Unknown", //公务翻译费 Name
  4414. translateCurrCode = "Unknown"; //公务翻译费 Code
  4415. #region 处理费用币种
  4416. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  4417. if (inviteCurrData != null)
  4418. {
  4419. inviteCurrName = inviteCurrData.Remark;
  4420. inviteCurrCode = inviteCurrData.Name;
  4421. }
  4422. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  4423. if (sendCurrData != null)
  4424. {
  4425. sendCurrName = sendCurrData.Remark;
  4426. sendCurrCode = sendCurrData.Name;
  4427. }
  4428. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  4429. if (eventsCurrData != null)
  4430. {
  4431. eventsCurrName = eventsCurrData.Remark;
  4432. eventsCurrCode = eventsCurrData.Name;
  4433. }
  4434. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  4435. if (translateCurrData != null)
  4436. {
  4437. translateCurrName = translateCurrData.Remark;
  4438. translateCurrCode = translateCurrData.Name;
  4439. }
  4440. #endregion
  4441. _detail.PriceNameContent = _ioa.InviterArea;
  4442. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  4443. List<string> priceExpNames = new List<string>();
  4444. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  4445. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  4446. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  4447. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  4448. if (priceExpNames != null && priceExpNames.Count > 0)
  4449. {
  4450. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  4451. }
  4452. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  4453. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  4454. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  4455. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  4456. $@"备注:" + _ioa.Remark + "<br/>";
  4457. }
  4458. break;
  4459. case 82: //团组客户保险
  4460. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  4461. if (customers != null)
  4462. {
  4463. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  4464. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  4465. }
  4466. break;
  4467. case 85: //机票预订
  4468. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  4469. if (jpRes != null)
  4470. {
  4471. string FlightsDescription = jpRes.FlightsDescription;
  4472. string PriceDescription = jpRes.PriceDescription;
  4473. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  4474. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  4475. }
  4476. break;
  4477. case 98://其他款项
  4478. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  4479. if (gdpRes != null)
  4480. {
  4481. //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/";
  4482. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  4483. //{
  4484. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  4485. //}
  4486. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  4487. _detail.PriceNameContent = gdpRes.PriceName;
  4488. }
  4489. break;
  4490. case 285://收款退还
  4491. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  4492. if (refundAndOtherMoney != null)
  4493. {
  4494. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  4495. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  4496. }
  4497. break;
  4498. case 751://酒店早餐
  4499. break;
  4500. case 1015://超支费用
  4501. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  4502. if (groupExtraCost != null)
  4503. {
  4504. _detail.PriceNameContent = groupExtraCost.PriceName;
  4505. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  4506. }
  4507. break;
  4508. default:
  4509. break;
  4510. }
  4511. /*
  4512. * 申请人
  4513. */
  4514. string operatorName = " - ";
  4515. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  4516. if (_opUser != null)
  4517. {
  4518. operatorName = _opUser.CnName;
  4519. }
  4520. _detail.OperatorName = operatorName;
  4521. /*
  4522. * 审核人
  4523. */
  4524. string auditOperatorName = " - ";
  4525. if (entity.IsAuditGM != 0)
  4526. {
  4527. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  4528. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  4529. else
  4530. {
  4531. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  4532. if (_adUser != null)
  4533. {
  4534. auditOperatorName = _adUser.CnName;
  4535. }
  4536. }
  4537. }
  4538. _detail.AuditOperatorName = auditOperatorName;
  4539. /*
  4540. * 超预算比例
  4541. */
  4542. string overBudgetStr = "";
  4543. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  4544. else if (entity.ExceedBudget == 0)
  4545. {
  4546. if (entity.CTable == 76 || entity.CTable == 79)
  4547. {
  4548. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  4549. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  4550. }
  4551. else
  4552. {
  4553. overBudgetStr = "未超预算";
  4554. }
  4555. }
  4556. else overBudgetStr = entity.ExceedBudget.ToString("P");
  4557. _detail.OverBudget = overBudgetStr;
  4558. decimal auditFee = 0.00M; //已审核金额 人名币
  4559. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  4560. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  4561. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  4562. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  4563. {
  4564. auditedFeeOriginal = entity.PayMoney;
  4565. auditFee = CurrPayStr;
  4566. }
  4567. else if (entity.IsAuditGM == 0)
  4568. {
  4569. unAuditFeeCNY = CurrPayStr;
  4570. unAuditFeeOriginal = OriginalCurrPay;
  4571. OriginalCurrPay = 0.00M;
  4572. }
  4573. /*
  4574. * 费用总计
  4575. */
  4576. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  4577. {
  4578. CurrencyId = entity.PaymentCurrency,
  4579. CurrencyName = PaymentCurrency_WaitPay,
  4580. AmountPayable = entity.PayMoney,
  4581. ThisPayment = OriginalCurrPay,
  4582. BalancePayment = BalanceStr,
  4583. AuditedFunds = auditFee,
  4584. AuditedFundsOriginal = auditedFeeOriginal,
  4585. UnAuditFundsCNY = unAuditFeeCNY,
  4586. UnAuditFundsOriginal = unAuditFeeOriginal
  4587. });
  4588. _detail.IsAuditGM = entity.IsAuditGM;
  4589. detailList.Add(_detail);
  4590. }
  4591. #endregion
  4592. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  4593. /*
  4594. * 下方描述处理
  4595. */
  4596. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  4597. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  4598. if (ccpCurrencyPrice != null)
  4599. {
  4600. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  4601. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  4602. }
  4603. else
  4604. {
  4605. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  4606. }
  4607. string amountPayableStr = string.Format(@"应付款总金额: ");
  4608. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  4609. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  4610. string auditedFundsStr = string.Format(@"已审费用总额: ");
  4611. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  4612. foreach (var item in nonDuplicat)
  4613. {
  4614. var currencyName = item.CurrencyName;
  4615. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  4616. if (strs.Count > 0)
  4617. {
  4618. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  4619. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  4620. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  4621. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  4622. //单独处理此次付款金额
  4623. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4624. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  4625. //单独处理已审核费用
  4626. //if (item.CurrencyId == 836) //人民币
  4627. //{
  4628. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  4629. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  4630. //}
  4631. //else
  4632. //{
  4633. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  4634. //}
  4635. if (currencyName.Equals("CNY"))
  4636. {
  4637. //已审核费用
  4638. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  4639. //未审核费用
  4640. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  4641. }
  4642. else
  4643. {
  4644. //已审核费用
  4645. 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"));
  4646. //未审核费用
  4647. 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"));
  4648. }
  4649. }
  4650. }
  4651. _view.TotalStr1 = amountPayableStr[..^1];
  4652. _view.TotalStr2 = thisPaymentStr[..^1];
  4653. _view.TotalStr3 = balancePaymentStr[..^1];
  4654. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  4655. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  4656. var _view1 = new
  4657. {
  4658. PageFuncAuth = pageFunAuthView,
  4659. Data = _view
  4660. };
  4661. return Ok(JsonView(_view1));
  4662. }
  4663. catch (Exception ex)
  4664. {
  4665. return Ok(JsonView(false, ex.Message));
  4666. }
  4667. }
  4668. /// <summary>
  4669. /// 费用审核
  4670. /// 修改团组费用审核状态
  4671. /// </summary>
  4672. /// <param name="_dto">参数Json字符串</param>
  4673. /// <returns></returns>
  4674. [HttpPost]
  4675. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4676. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  4677. {
  4678. #region 参数验证
  4679. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  4680. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  4681. #endregion
  4682. #region 页面操作权限验证
  4683. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  4684. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  4685. #endregion
  4686. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  4687. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  4688. DateTime dtNow = DateTime.Now;
  4689. _groupRepository.BeginTran();
  4690. int rst = 0;
  4691. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  4692. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  4693. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  4694. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  4695. var msgDatas = new List<dynamic>();
  4696. var dic_ccp_user = new Dictionary<int, int>() { };
  4697. foreach (var item in idList)
  4698. {
  4699. int CreditId = int.Parse(item);
  4700. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  4701. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  4702. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  4703. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  4704. .Where(s => s.Id == CreditId)
  4705. .ExecuteCommandAsync();
  4706. if (result < 1)
  4707. {
  4708. rst = -1;
  4709. _groupRepository.RollbackTran();
  4710. return Ok(JsonView(false, "操作失败并回滚!"));
  4711. }
  4712. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  4713. if (creditData != null)
  4714. {
  4715. #region 应用通知配置
  4716. try
  4717. {
  4718. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  4719. }
  4720. catch (Exception ex)
  4721. {
  4722. }
  4723. #endregion
  4724. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  4725. string groupNameStr = string.Empty;
  4726. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  4727. if (groupData != null) groupNameStr = groupData.TeamName;
  4728. string creditTypeStr = string.Empty;
  4729. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  4730. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  4731. string creditCurrency = string.Empty;
  4732. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  4733. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  4734. if (creditCurrency.Equals("CNY"))
  4735. {
  4736. creditData.DayRate = 1.0000M;
  4737. }
  4738. if (creditData.PayPercentage == 0.00M)
  4739. {
  4740. creditData.PayPercentage = 100M;
  4741. }
  4742. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  4743. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  4744. string msgContent = "";
  4745. if (creditCurrency.Equals("CNY"))
  4746. {
  4747. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  4748. }
  4749. else
  4750. {
  4751. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  4752. }
  4753. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  4754. }
  4755. }
  4756. if (rst == 0)
  4757. {
  4758. _groupRepository.CommitTran();
  4759. foreach (var item in msgDatas)
  4760. {
  4761. //发送消息
  4762. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  4763. }
  4764. #region 应用推送
  4765. try
  4766. {
  4767. foreach (var ccpId in dic_ccp_user.Keys)
  4768. {
  4769. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  4770. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  4771. }
  4772. }
  4773. catch (Exception)
  4774. {
  4775. }
  4776. #endregion
  4777. return Ok(JsonView(true, "操作成功!"));
  4778. }
  4779. return Ok(JsonView(false, "操作失败!"));
  4780. }
  4781. /// <summary>
  4782. /// 费用审核
  4783. /// 其他款项 文件下载
  4784. /// </summary>
  4785. /// <param name="id">其他款项 主键编号</param>
  4786. /// <returns></returns>
  4787. [HttpGet("{id}")]
  4788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4789. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  4790. {
  4791. //网站域名
  4792. 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/";
  4793. var otherInfo = await _decreasePaymentsRep._sqlSugar
  4794. .Queryable<Grp_DecreasePayments>()
  4795. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  4796. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  4797. .Select((x, y) => new
  4798. {
  4799. x.Id,
  4800. x.FilePath
  4801. })
  4802. .FirstAsync();
  4803. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  4804. {
  4805. var url = $"{baseUrl}{otherInfo.FilePath}";
  4806. return Ok(JsonView(true, "操作成功!", url));
  4807. }
  4808. return Ok(JsonView(false, "暂无附件"));
  4809. }
  4810. #endregion
  4811. #region 机票费用录入
  4812. /// <summary>
  4813. /// 机票录入当前登录人可操作团组
  4814. /// </summary>
  4815. /// <param name="dto"></param>
  4816. /// <returns></returns>
  4817. [HttpPost]
  4818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4819. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  4820. {
  4821. try
  4822. {
  4823. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  4824. if (groupData.Code != 0)
  4825. {
  4826. return Ok(JsonView(false, groupData.Msg));
  4827. }
  4828. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4829. }
  4830. catch (Exception ex)
  4831. {
  4832. return Ok(JsonView(false, ex.Message));
  4833. }
  4834. }
  4835. /// <summary>
  4836. /// 机票费用录入列表
  4837. /// </summary>
  4838. /// <param name="dto"></param>
  4839. /// <returns></returns>
  4840. [HttpPost]
  4841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4842. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  4843. {
  4844. try
  4845. {
  4846. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  4847. if (groupData.Code != 0)
  4848. {
  4849. return Ok(JsonView(false, groupData.Msg));
  4850. }
  4851. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4852. }
  4853. catch (Exception ex)
  4854. {
  4855. return Ok(JsonView(false, ex.Message));
  4856. throw;
  4857. }
  4858. }
  4859. /// <summary>
  4860. /// 根据id查询费用录入信息
  4861. /// </summary>
  4862. /// <param name="dto"></param>
  4863. /// <returns></returns>
  4864. [HttpPost]
  4865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4866. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  4867. {
  4868. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  4869. if (groupData.Code != 0)
  4870. {
  4871. return Ok(JsonView(false, groupData.Msg));
  4872. }
  4873. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4874. }
  4875. /// <summary>
  4876. /// 机票费用录入操作(Status:1.新增,2.修改)
  4877. /// </summary>
  4878. /// <param name="dto"></param>
  4879. /// <returns></returns>
  4880. [HttpPost]
  4881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  4882. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  4883. {
  4884. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  4885. if (groupData.Code != 0)
  4886. {
  4887. return Ok(JsonView(false, groupData.Msg));
  4888. }
  4889. #region 应用推送
  4890. try
  4891. {
  4892. var diId = dto.AirTicketResOpData.DiId;
  4893. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  4894. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  4895. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  4896. //自动审核
  4897. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  4898. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  4899. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  4900. $"GroupId:{diId};airId:{dataId};",
  4901. status,
  4902. auditMsg);
  4903. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  4904. //2024-10-21 新增LZ UID
  4905. var userIds = new List<int>() { 21 };
  4906. string title = $"系统通知";
  4907. string content = "";
  4908. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  4909. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  4910. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4911. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  4912. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  4913. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  4914. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  4915. }
  4916. catch (Exception ex)
  4917. {
  4918. }
  4919. #endregion
  4920. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  4921. }
  4922. /// <summary>
  4923. /// 机票费用自动审核 AI识别方式
  4924. /// </summary>
  4925. /// <returns></returns>
  4926. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  4927. {
  4928. var ecoTypeIds = new List<int>() {
  4929. 459, //超经舱
  4930. 460, //经济舱
  4931. 1430, //公务舱(实际经济舱)
  4932. 1432, //头等舱(实际经济舱)
  4933. };
  4934. var bizTypeIds = new List<int>() {
  4935. 457, //头等舱
  4936. 458, //公务舱
  4937. 1431, //头等舱(实际公务舱)
  4938. };
  4939. var auditFeeTypeIds = new List<int>() { };
  4940. auditFeeTypeIds.AddRange(ecoTypeIds);
  4941. auditFeeTypeIds.AddRange(bizTypeIds);
  4942. int currModule = 85;
  4943. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  4944. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  4945. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  4946. .Select((x, y) => new
  4947. {
  4948. x.Id,
  4949. CcpId = y.Id,
  4950. x.FlightsDate,
  4951. x.PrePrice,
  4952. x.CType,
  4953. x.ClientNum,
  4954. x.DIId
  4955. })
  4956. .FirstAsync();
  4957. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  4958. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  4959. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  4960. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  4961. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  4962. var groupCostContents = await _sqlSugar
  4963. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  4964. .Where(x => x.IsDel == 0 && x.Diid == diId)
  4965. .ToListAsync();
  4966. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  4967. //处理 成本详细信息日期为空 填装费用信息
  4968. var airFeeLabel = new StringBuilder();
  4969. airFeeLabel.AppendLine("费用成本:");
  4970. for (int i = 0; i < groupCostContents.Count; i++)
  4971. {
  4972. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  4973. {
  4974. int index = i - 1;
  4975. if (index >= 0)
  4976. {
  4977. groupCostContents[i].Date = groupCostContents[index].Date;
  4978. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4979. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4980. }
  4981. }
  4982. else
  4983. {
  4984. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  4985. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  4986. }
  4987. var item = groupCostContents[i];
  4988. airFeeLabel.AppendLine($"{item.Date}");
  4989. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  4990. }
  4991. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  4992. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  4993. //访问Kimi AI 返回价格结果
  4994. var msgs = new List<SeedMessages>()
  4995. {
  4996. new ()
  4997. {
  4998. Role = KimiRole.user,
  4999. Content = airFeeLabel.ToString()
  5000. }
  5001. };
  5002. var client = new KiMiApiClient();
  5003. var kimiApiResult = await client.SeedMessage(msgs);
  5004. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  5005. string clients = kimiApiResult_JObject["content"].ToString();
  5006. decimal ecoPri_kimiAI = 0.00M,
  5007. bizPri_kimiAI = 0.00M;
  5008. //单个价格: 经济舱价格
  5009. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  5010. //价格文本包含/:/前经济舱价格 /后公务舱价格
  5011. if (clients.Contains('/'))
  5012. {
  5013. var priArray = clients.Split('/');
  5014. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  5015. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  5016. }
  5017. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  5018. var isAutoAudit = false;
  5019. //价格验证处理
  5020. //经济舱
  5021. if (ecoTypeIds.Contains(airInfo.CType))
  5022. {
  5023. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  5024. }
  5025. //公务舱
  5026. else if (bizTypeIds.Contains(airInfo.CType))
  5027. {
  5028. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  5029. }
  5030. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  5031. //是否执行自动审核
  5032. if (isAutoAudit)
  5033. {
  5034. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  5035. .SetColumns(x => x.IsAuditGM == 3)
  5036. .SetColumns(x => x.AuditGMOperate == 4)
  5037. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  5038. .Where(x => x.Id == airInfo.CcpId)
  5039. .ExecuteCommandAsync();
  5040. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  5041. }
  5042. return (false, "当前费用超过成本费用,不可自动审核!");
  5043. }
  5044. /// <summary>
  5045. /// 机票费用录入
  5046. /// 自动审核测试 - AI 识别
  5047. /// </summary>
  5048. /// <param name="groupId"></param>
  5049. /// <param name="Id"></param>
  5050. /// <returns></returns>
  5051. [HttpPost]
  5052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5053. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  5054. {
  5055. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  5056. return Ok(JsonView(status, msg));
  5057. }
  5058. /// <summary>
  5059. /// 根据舱位类型查询接团客户名单信息
  5060. /// </summary>
  5061. /// <param name="dto"></param>
  5062. /// <returns></returns>
  5063. [HttpPost]
  5064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5065. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  5066. {
  5067. try
  5068. {
  5069. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  5070. if (crm_Groups.Count != 0)
  5071. {
  5072. var Customer = new List<dynamic>();
  5073. foreach (var item in crm_Groups)
  5074. {
  5075. var data = new
  5076. {
  5077. item.Id,
  5078. item.Pinyin,
  5079. Name = item.LastName + item.FirstName
  5080. };
  5081. Customer.Add(data);
  5082. }
  5083. return Ok(JsonView(true, "查询成功!", Customer));
  5084. }
  5085. return Ok(JsonView(true, "暂无数据", crm_Groups));
  5086. }
  5087. catch (Exception ex)
  5088. {
  5089. return Ok(JsonView(false, "程序错误!"));
  5090. throw;
  5091. }
  5092. }
  5093. /// <summary>
  5094. /// 根据团号获取客户信息
  5095. /// </summary>
  5096. /// <param name="dto"></param>
  5097. /// <returns></returns>
  5098. [HttpPost]
  5099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5100. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  5101. {
  5102. var jw = JsonView(false);
  5103. if (dto.DIID < 1)
  5104. {
  5105. jw.Msg += "请输入正确的diid";
  5106. return Ok(jw);
  5107. }
  5108. var arr = GetSimplClientList(dto.DIID);
  5109. jw = JsonView(true, "获取成功!", arr);
  5110. return Ok(jw);
  5111. }
  5112. private List<SimplClientInfo> GetSimplClientList(int diId)
  5113. {
  5114. 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);
  5115. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  5116. foreach (var item in arr)
  5117. {
  5118. EncryptionProcessor.DecryptProperties(item);
  5119. }
  5120. return arr;
  5121. }
  5122. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  5123. {
  5124. string result = origin;
  5125. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  5126. {
  5127. string[] temparr = origin.Split(',');
  5128. string fistrStr = temparr[0];
  5129. int count = temparr.Length;
  5130. bool success = int.TryParse(fistrStr, out int tempId);
  5131. if (success)
  5132. {
  5133. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  5134. if (tempInfo != null)
  5135. {
  5136. if (count > 1)
  5137. {
  5138. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  5139. }
  5140. else
  5141. {
  5142. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  5143. }
  5144. }
  5145. }
  5146. }
  5147. return result;
  5148. }
  5149. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  5150. {
  5151. string result = origin;
  5152. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  5153. {
  5154. string[] temparr = origin.Split(',');
  5155. result = "";
  5156. foreach (var item in temparr)
  5157. {
  5158. bool success = int.TryParse(item, out int tempId);
  5159. if (success)
  5160. {
  5161. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  5162. if (tempInfo != null)
  5163. {
  5164. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  5165. }
  5166. }
  5167. }
  5168. }
  5169. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  5170. return result;
  5171. }
  5172. /// <summary>
  5173. /// 机票费用录入,删除
  5174. /// </summary>
  5175. /// <param name="dto"></param>
  5176. /// <returns></returns>
  5177. [HttpPost]
  5178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5179. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  5180. {
  5181. try
  5182. {
  5183. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  5184. if (res)
  5185. {
  5186. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  5187. {
  5188. IsDel = 1,
  5189. DeleteUserId = dto.DeleteUserId,
  5190. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  5191. }).ExecuteCommandAsync();
  5192. return Ok(JsonView(true, "删除成功!"));
  5193. }
  5194. return Ok(JsonView(false, "删除失败!"));
  5195. }
  5196. catch (Exception ex)
  5197. {
  5198. return Ok(JsonView(false, "程序错误!"));
  5199. throw;
  5200. }
  5201. }
  5202. /// <summary>
  5203. /// 导出机票录入报表
  5204. /// </summary>
  5205. /// <param name="dto"></param>
  5206. /// <returns></returns>
  5207. [HttpPost]
  5208. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5209. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  5210. {
  5211. try
  5212. {
  5213. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  5214. if (groupData.Code != 0)
  5215. {
  5216. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5217. }
  5218. else
  5219. {
  5220. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  5221. if (AirTicketReservations.Count != 0)
  5222. {
  5223. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  5224. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  5225. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  5226. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  5227. var designer = new WorkbookDesigner
  5228. {
  5229. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  5230. };
  5231. decimal countCost = 0;
  5232. foreach (var item in AirTicketReservations)
  5233. {
  5234. #region 处理客人姓名
  5235. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  5236. item.ClientName = clientNames;
  5237. #endregion
  5238. if (item.BankType == "其他")
  5239. {
  5240. item.BankNo = "--";
  5241. }
  5242. else
  5243. {
  5244. if (!string.IsNullOrEmpty(item.BankType))
  5245. {
  5246. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  5247. }
  5248. }
  5249. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  5250. item.Price = System.Decimal.Round(item.Price, 2);
  5251. countCost += Convert.ToDecimal(item.Price);
  5252. }
  5253. designer.SetDataSource("Export", AirTicketReservations);
  5254. designer.SetDataSource("ExportDiCode", diCode);
  5255. designer.SetDataSource("ExportDiName", diName);
  5256. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  5257. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  5258. designer.Process();
  5259. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  5260. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  5261. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  5262. return Ok(JsonView(true, "成功", url = rst));
  5263. }
  5264. else
  5265. {
  5266. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  5267. }
  5268. }
  5269. }
  5270. catch (Exception ex)
  5271. {
  5272. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  5273. throw;
  5274. }
  5275. }
  5276. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  5277. /// <summary>
  5278. /// 行程单导出
  5279. /// </summary>
  5280. /// <param name="dto"></param>
  5281. /// <returns></returns>
  5282. [HttpPost]
  5283. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5284. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  5285. {
  5286. try
  5287. {
  5288. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  5289. if (groupData.Code != 0)
  5290. {
  5291. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  5292. }
  5293. else
  5294. {
  5295. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  5296. if (dto.Language == "CN")
  5297. {
  5298. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  5299. var builder = new DocumentBuilder(doc);
  5300. int tableIndex = 0;//表格索引
  5301. //得到文档中的第一个表格
  5302. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5303. foreach (var item in _AirTicketReservations)
  5304. {
  5305. #region 处理固定数据
  5306. string[] FlightsCode = item.FlightsCode.Split('/');
  5307. if (FlightsCode.Length != 0)
  5308. {
  5309. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5310. if (_AirCompany != null)
  5311. {
  5312. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5313. }
  5314. else
  5315. {
  5316. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5317. }
  5318. }
  5319. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5320. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5321. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5322. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5323. string name = "";
  5324. foreach (string clientName in nameArray)
  5325. {
  5326. if (!name.Contains(clientName))
  5327. {
  5328. name += clientName + ",";
  5329. }
  5330. }
  5331. if (!string.IsNullOrWhiteSpace(name))
  5332. {
  5333. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5334. }
  5335. else
  5336. {
  5337. table.Range.Bookmarks["ClientName"].Text = "--";
  5338. }
  5339. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5340. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5341. table.Range.Bookmarks["JointTicket"].Text = "--";
  5342. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5343. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5344. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5345. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5346. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5347. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5348. #endregion
  5349. #region 循环数据处理
  5350. var airs = new List<AirInfo>();
  5351. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5352. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5353. for (int i = 0; i < FlightsCode.Length; i++)
  5354. {
  5355. var air = new AirInfo();
  5356. string[] tempstr = DayArray[i]
  5357. .Replace("\r\n", string.Empty)
  5358. .Replace("\\r\\n", string.Empty)
  5359. .TrimStart().TrimEnd()
  5360. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5361. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5362. string starCity = "";
  5363. if (star_Three != null)
  5364. {
  5365. starCity = star_Three.AirPort;
  5366. }
  5367. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5368. string EndCity = "";
  5369. if (End_Three != null)
  5370. {
  5371. EndCity = End_Three.AirPort;
  5372. }
  5373. air.Destination = starCity + "/" + EndCity;
  5374. air.Flight = FlightsCode[i];
  5375. air.SeatingClass = item.CTypeName;
  5376. string dateTime = tempstr[2];
  5377. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5378. air.FlightDate = DateTemp;
  5379. air.DepartureTime = tempstr[5];
  5380. air.LandingTime = tempstr[6];
  5381. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5382. air.TicketStatus = "--";
  5383. air.Luggage = "--";
  5384. air.DepartureTerminal = "--";
  5385. air.LandingTerminal = "--";
  5386. airs.Add(air);
  5387. }
  5388. int row = 13;
  5389. for (int i = 0; i < airs.Count; i++)
  5390. {
  5391. if (airs.Count > 2)
  5392. {
  5393. for (int j = 0; j < airs.Count - 2; j++)
  5394. {
  5395. var CopyRow = table.Rows[12].Clone(true);
  5396. table.Rows.Add(CopyRow);
  5397. }
  5398. }
  5399. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5400. int index = 0;
  5401. foreach (PropertyInfo property in properties)
  5402. {
  5403. string value = property.GetValue(airs[i]).ToString();
  5404. Cell ishcel0 = table.Rows[row].Cells[index];
  5405. var p = new Paragraph(doc);
  5406. string s = value;
  5407. p.AppendChild(new Run(doc, s));
  5408. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5409. ishcel0.AppendChild(p);
  5410. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5411. index++;
  5412. }
  5413. row++;
  5414. }
  5415. #endregion
  5416. var lastParagraph = new Paragraph(doc);
  5417. //第一个表格末尾加段落
  5418. table.ParentNode.InsertAfter(lastParagraph, table);
  5419. //复制第一个表格
  5420. Table cloneTable = (Table)table.Clone(true);
  5421. //在文档末尾段落后面加入复制的表格
  5422. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5423. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5424. {
  5425. int rownewsIndex = 13;
  5426. for (int i = 0; i < 2; i++)
  5427. {
  5428. var CopyRow = table.Rows[12].Clone(true);
  5429. table.Rows.RemoveAt(13);
  5430. table.Rows.Add(CopyRow);
  5431. rownewsIndex++;
  5432. }
  5433. }
  5434. else
  5435. {
  5436. table.Rows.RemoveAt(12);
  5437. }
  5438. cloneTable.Rows.RemoveAt(12);
  5439. }
  5440. if (_AirTicketReservations.Count != 0)
  5441. {
  5442. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5443. if (FlightsCode.Length != 0)
  5444. {
  5445. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5446. if (_AirCompany != null)
  5447. {
  5448. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  5449. }
  5450. else
  5451. {
  5452. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5453. }
  5454. }
  5455. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5456. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5457. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5458. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5459. string name = "";
  5460. foreach (string clientName in nameArray)
  5461. {
  5462. if (!name.Contains(clientName))
  5463. {
  5464. name += clientName + ",";
  5465. }
  5466. }
  5467. if (!string.IsNullOrWhiteSpace(name))
  5468. {
  5469. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  5470. }
  5471. else
  5472. {
  5473. table.Range.Bookmarks["ClientName"].Text = "--";
  5474. }
  5475. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5476. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5477. table.Range.Bookmarks["JointTicket"].Text = "--";
  5478. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5479. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5480. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5481. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5482. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5483. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5484. }
  5485. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5486. //保存合并后的文档
  5487. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  5488. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5489. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5490. return Ok(JsonView(true, "成功!", rst));
  5491. }
  5492. else
  5493. {
  5494. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  5495. var builder = new DocumentBuilder(doc);
  5496. int tableIndex = 0;//表格索引
  5497. //得到文档中的第一个表格
  5498. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  5499. var texts = new List<string>();
  5500. foreach (var item in _AirTicketReservations)
  5501. {
  5502. string[] FlightsCode = item.FlightsCode.Split('/');
  5503. if (FlightsCode.Length != 0)
  5504. {
  5505. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5506. if (_AirCompany != null)
  5507. {
  5508. if (!transDic.ContainsKey(_AirCompany.CnName))
  5509. {
  5510. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  5511. }
  5512. }
  5513. else
  5514. {
  5515. if (!transDic.ContainsKey("--"))
  5516. {
  5517. transDic.Add("--", "--");
  5518. }
  5519. }
  5520. }
  5521. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5522. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5523. string name = "";
  5524. foreach (string clientName in nameArray)
  5525. {
  5526. name += clientName + ",";
  5527. }
  5528. if (!texts.Contains(name))
  5529. {
  5530. texts.Add(name);
  5531. }
  5532. var airs = new List<AirInfo>();
  5533. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5534. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5535. for (int i = 0; i < FlightsCode.Length; i++)
  5536. {
  5537. var air = new AirInfo();
  5538. string[] tempstr = DayArray[i]
  5539. .Replace("\r\n", string.Empty)
  5540. .Replace("\\r\\n", string.Empty)
  5541. .TrimStart().TrimEnd()
  5542. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5543. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5544. if (star_Three != null)
  5545. {
  5546. if (!transDic.ContainsKey(star_Three.AirPort))
  5547. {
  5548. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  5549. }
  5550. }
  5551. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5552. if (End_Three != null)
  5553. {
  5554. if (!transDic.ContainsKey(End_Three.AirPort))
  5555. {
  5556. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  5557. }
  5558. }
  5559. if (!texts.Contains(item.CTypeName))
  5560. {
  5561. texts.Add(item.CTypeName);
  5562. }
  5563. }
  5564. }
  5565. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  5566. if (transData.Count > 0)
  5567. {
  5568. foreach (TranslateResult item in transData)
  5569. {
  5570. if (!transDic.ContainsKey(item.Query))
  5571. {
  5572. transDic.Add(item.Query, item.Translation);
  5573. }
  5574. }
  5575. }
  5576. foreach (var item in _AirTicketReservations)
  5577. {
  5578. #region 处理固定数据
  5579. string[] FlightsCode = item.FlightsCode.Split('/');
  5580. if (FlightsCode.Length != 0)
  5581. {
  5582. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5583. if (_AirCompany != null)
  5584. {
  5585. string str = "--";
  5586. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5587. if (!string.IsNullOrEmpty(translateResult))
  5588. {
  5589. str = translateResult;
  5590. str = _airTicketResRep.Processing(str);
  5591. }
  5592. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5593. }
  5594. else
  5595. {
  5596. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5597. }
  5598. }
  5599. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5600. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5601. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5602. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5603. string names = "";
  5604. foreach (string clientName in nameArray)
  5605. {
  5606. names += clientName + ",";
  5607. }
  5608. if (!string.IsNullOrWhiteSpace(names))
  5609. {
  5610. string str = "--";
  5611. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5612. if (!string.IsNullOrEmpty(translateResult))
  5613. {
  5614. str = translateResult;
  5615. str = _airTicketResRep.Processing(str);
  5616. }
  5617. table.Range.Bookmarks["ClientName"].Text = str;
  5618. }
  5619. else
  5620. {
  5621. table.Range.Bookmarks["ClientName"].Text = "--";
  5622. }
  5623. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5624. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5625. table.Range.Bookmarks["JointTicket"].Text = "--";
  5626. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5627. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5628. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5629. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5630. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5631. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5632. #endregion
  5633. #region 循环数据处理
  5634. var airs = new List<AirInfo>();
  5635. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  5636. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  5637. for (int i = 0; i < FlightsCode.Length; i++)
  5638. {
  5639. var air = new AirInfo();
  5640. string[] tempstr = DayArray[i]
  5641. .Replace("\r\n", string.Empty)
  5642. .Replace("\\r\\n", string.Empty)
  5643. .TrimStart().TrimEnd()
  5644. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  5645. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  5646. string starCity = "";
  5647. if (star_Three != null)
  5648. {
  5649. string str2 = "--";
  5650. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  5651. if (!string.IsNullOrEmpty(translateResult2))
  5652. {
  5653. str2 = translateResult2;
  5654. str2 = _airTicketResRep.Processing(str2);
  5655. }
  5656. starCity = str2;
  5657. }
  5658. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  5659. string EndCity = "";
  5660. if (End_Three != null)
  5661. {
  5662. string str1 = "--";
  5663. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  5664. if (!string.IsNullOrEmpty(translateResult1))
  5665. {
  5666. str1 = translateResult1;
  5667. str1 = _airTicketResRep.Processing(str1);
  5668. }
  5669. EndCity = str1;
  5670. }
  5671. air.Destination = starCity + "/" + EndCity;
  5672. air.Flight = FlightsCode[i];
  5673. string str = "--";
  5674. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  5675. if (!string.IsNullOrEmpty(translateResult))
  5676. {
  5677. str = translateResult;
  5678. str = _airTicketResRep.Processing(str);
  5679. }
  5680. air.SeatingClass = str;
  5681. string dateTime = tempstr[2];
  5682. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  5683. air.FlightDate = DateTemp;
  5684. air.DepartureTime = tempstr[5];
  5685. air.LandingTime = tempstr[6];
  5686. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  5687. air.TicketStatus = "--";
  5688. air.Luggage = "--";
  5689. air.DepartureTerminal = "--";
  5690. air.LandingTerminal = "--";
  5691. airs.Add(air);
  5692. }
  5693. int row = 13;
  5694. for (int i = 0; i < airs.Count; i++)
  5695. {
  5696. if (airs.Count > 2)
  5697. {
  5698. for (int j = 0; j < airs.Count - 2; j++)
  5699. {
  5700. var CopyRow = table.Rows[12].Clone(true);
  5701. table.Rows.Add(CopyRow);
  5702. }
  5703. }
  5704. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  5705. int index = 0;
  5706. foreach (PropertyInfo property in properties)
  5707. {
  5708. string value = property.GetValue(airs[i]).ToString();
  5709. Cell ishcel0 = table.Rows[row].Cells[index];
  5710. var p = new Paragraph(doc);
  5711. string s = value;
  5712. p.AppendChild(new Run(doc, s));
  5713. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  5714. ishcel0.AppendChild(p);
  5715. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  5716. //ishcel0.CellFormat.VerticalAlignment=
  5717. index++;
  5718. }
  5719. row++;
  5720. }
  5721. #endregion
  5722. var lastParagraph = new Paragraph(doc);
  5723. //第一个表格末尾加段落
  5724. table.ParentNode.InsertAfter(lastParagraph, table);
  5725. //复制第一个表格
  5726. Table cloneTable = (Table)table.Clone(true);
  5727. //在文档末尾段落后面加入复制的表格
  5728. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  5729. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  5730. {
  5731. int rownewsIndex = 13;
  5732. for (int i = 0; i < 2; i++)
  5733. {
  5734. var CopyRow = table.Rows[12].Clone(true);
  5735. table.Rows.RemoveAt(13);
  5736. table.Rows.Add(CopyRow);
  5737. rownewsIndex++;
  5738. }
  5739. }
  5740. else
  5741. {
  5742. table.Rows.RemoveAt(12);
  5743. }
  5744. cloneTable.Rows.RemoveAt(12);
  5745. }
  5746. if (_AirTicketReservations.Count != 0)
  5747. {
  5748. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  5749. if (FlightsCode.Length != 0)
  5750. {
  5751. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  5752. if (_AirCompany != null)
  5753. {
  5754. string str = "--";
  5755. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  5756. if (!string.IsNullOrEmpty(translateResult))
  5757. {
  5758. str = translateResult;
  5759. str = _airTicketResRep.Processing(str);
  5760. }
  5761. table.Range.Bookmarks["AirlineCompany"].Text = str;
  5762. }
  5763. else
  5764. {
  5765. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  5766. }
  5767. }
  5768. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  5769. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  5770. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  5771. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  5772. string names = "";
  5773. foreach (string clientName in nameArray)
  5774. {
  5775. names += clientName + ",";
  5776. }
  5777. if (!string.IsNullOrWhiteSpace(names))
  5778. {
  5779. string str = "--";
  5780. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  5781. if (!string.IsNullOrEmpty(translateResult))
  5782. {
  5783. str = translateResult;
  5784. str = _airTicketResRep.Processing(str);
  5785. }
  5786. table.Range.Bookmarks["ClientName"].Text = str;
  5787. }
  5788. else
  5789. {
  5790. table.Range.Bookmarks["ClientName"].Text = "--";
  5791. }
  5792. table.Range.Bookmarks["TicketNumber"].Text = "--";
  5793. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  5794. table.Range.Bookmarks["JointTicket"].Text = "--";
  5795. table.Range.Bookmarks["TimeIssue"].Text = "--";
  5796. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  5797. table.Range.Bookmarks["NavigationCode"].Text = "--";
  5798. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  5799. table.Range.Bookmarks["AgentPhone"].Text = "--";
  5800. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  5801. }
  5802. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  5803. //保存合并后的文档
  5804. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  5805. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  5806. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  5807. return Ok(JsonView(true, "成功!", rst));
  5808. }
  5809. }
  5810. }
  5811. catch (Exception ex)
  5812. {
  5813. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  5814. throw;
  5815. }
  5816. }
  5817. #endregion
  5818. #region 团组增减款项 --> 其他款项
  5819. /// <summary>
  5820. /// 团组增减款项下拉框绑定
  5821. /// </summary>
  5822. /// <param name="dto"></param>
  5823. /// <returns></returns>
  5824. [HttpPost]
  5825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5826. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  5827. {
  5828. #region 参数验证
  5829. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5830. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  5831. #endregion
  5832. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  5833. }
  5834. /// <summary>
  5835. /// 根据团组Id查询团组增减款项
  5836. /// </summary>
  5837. /// <param name="dto"></param>
  5838. /// <returns></returns>
  5839. [HttpPost]
  5840. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5841. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  5842. {
  5843. #region 参数验证
  5844. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  5845. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  5846. #endregion
  5847. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  5848. }
  5849. /// <summary>
  5850. /// 团组增减款项操作(Status:1.新增,2.修改)
  5851. /// </summary>
  5852. /// <param name="dto"></param>
  5853. /// <returns></returns>
  5854. [HttpPost]
  5855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5856. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  5857. {
  5858. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  5859. if (groupData.Code != 200)
  5860. {
  5861. return Ok(JsonView(false, groupData.Msg));
  5862. }
  5863. #region 应用推送
  5864. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  5865. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  5866. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  5867. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  5868. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  5869. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  5870. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  5871. if (recheck)
  5872. {
  5873. //自动审核
  5874. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  5875. }
  5876. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  5877. //2024-10-21 新增LZ UID
  5878. var userIds = new List<int>() { 21 };
  5879. string title = $"系统通知";
  5880. string content = "";
  5881. var diId = dto.DiId;
  5882. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  5883. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  5884. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5885. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  5886. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  5887. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  5888. #endregion
  5889. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5890. }
  5891. /// <summary>
  5892. /// 团组增减款项操作 删除
  5893. /// </summary>
  5894. /// <param name="dto"></param>
  5895. /// <returns></returns>
  5896. [HttpPost]
  5897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5898. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  5899. {
  5900. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  5901. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  5902. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  5903. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  5904. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  5905. }
  5906. /// <summary>
  5907. /// 根据团组增减款项Id查询
  5908. /// </summary>
  5909. /// <param name="dto"></param>
  5910. /// <returns></returns>
  5911. [HttpPost]
  5912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5913. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  5914. {
  5915. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  5916. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  5917. }
  5918. /// <summary>
  5919. /// 查询供应商名称
  5920. /// </summary>
  5921. /// <param name="dto"></param>
  5922. /// <returns></returns>
  5923. [HttpPost]
  5924. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  5925. {
  5926. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  5927. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  5928. ?? new List<Grp_DecreasePayments>();
  5929. dbResult = dbResult.Distinct(new
  5930. ProductComparer()).ToList();
  5931. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  5932. {
  5933. x.Id,
  5934. x.SupplierAddress,
  5935. x.SupplierArea,
  5936. x.SupplierContact,
  5937. x.SupplierContactNumber,
  5938. x.SupplierEmail,
  5939. x.SupplierName,
  5940. x.SupplierSocialAccount,
  5941. x.SupplierTypeId,
  5942. }).ToList());
  5943. return Ok(jw);
  5944. }
  5945. /// <summary>
  5946. /// 团组增减款项 OTA匹配
  5947. /// </summary>
  5948. /// <param name="file"></param>
  5949. /// <returns></returns>
  5950. [HttpPost]
  5951. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  5952. {
  5953. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  5954. string fileName = file.FileName;
  5955. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  5956. {
  5957. return Ok(JsonView(false, "请上传Excel文件!"));
  5958. }
  5959. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  5960. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  5961. if (!Directory.Exists(path))
  5962. {
  5963. Directory.CreateDirectory(path);
  5964. }
  5965. var filePath = @$"{path}/{fileName}";
  5966. //保存文件
  5967. using (FileStream fs = System.IO.File.Create(filePath))
  5968. {
  5969. file.CopyTo(fs);
  5970. fs.Flush();
  5971. }
  5972. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  5973. //读取ExcelFile
  5974. DataTable dt = ConvertExcelToDataTable(filePath);
  5975. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  5976. dt.TableName = "TB";
  5977. //修改table列名
  5978. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  5979. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  5980. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  5981. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  5982. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  5983. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  5984. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  5985. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  5986. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  5987. dt.Columns[9].ColumnName = "Quantity"; // 台数
  5988. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  5989. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  5990. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  5991. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  5992. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  5993. var otaOrderNos = new List<string>();
  5994. foreach (DataRow item in dt.Rows)
  5995. {
  5996. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  5997. }
  5998. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  5999. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  6000. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  6001. .Select((dp, di) => new
  6002. {
  6003. dp.PriceName,
  6004. dp.OTAOrderNo,
  6005. dp.FeeTotal,
  6006. di.TeamName,
  6007. })
  6008. .ToListAsync();
  6009. foreach (DataRow item in dt.Rows)
  6010. {
  6011. var otaOrderNo = item["OTAOrderNo"].ToString();
  6012. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  6013. if (oaData == null) continue;
  6014. item["GroupName"] = oaData.TeamName;
  6015. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  6016. }
  6017. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  6018. var pairs = new Dictionary<string, object>();
  6019. var datas = new List<DataTable>
  6020. {
  6021. dt
  6022. };
  6023. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  6024. return Ok(JsonView(true, "操作成功", new { url }));
  6025. }
  6026. #region
  6027. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  6028. {
  6029. // 创建Workbook对象
  6030. var workbook = new Workbook(excelFilePath);
  6031. // 获取第一个工作表
  6032. var worksheet = workbook.Worksheets[0];
  6033. // 将工作表转换为DataTable
  6034. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  6035. return dataTable;
  6036. }
  6037. #endregion
  6038. /// <summary>
  6039. /// 世运会数据
  6040. /// </summary>
  6041. /// <returns></returns>
  6042. [HttpGet]
  6043. public IActionResult WorldGamesData()
  6044. {
  6045. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  6046. var groupMenu = setData.GroupBy(x => x.T0);
  6047. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  6048. foreach (var item in groupMenu)
  6049. {
  6050. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  6051. {
  6052. Data = new SetDataView
  6053. {
  6054. Name = item.Key
  6055. },
  6056. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  6057. });
  6058. }
  6059. return Ok(JsonView(true, "success", resultArr));
  6060. }
  6061. #endregion
  6062. #region 文件上传、删除
  6063. /// <summary>
  6064. /// region 文件上传 可以带参数
  6065. /// </summary>
  6066. /// <param name="file"></param>
  6067. /// <returns></returns>
  6068. [HttpPost]
  6069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6070. public async Task<IActionResult> UploadProject(IFormFile file)
  6071. {
  6072. //var TypeName = Request.Headers["TypeName"].ToString();
  6073. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  6074. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6075. ////文件名称
  6076. //string projectFileName = file.FileName;
  6077. ////上传的文件的路径
  6078. //string filePath = $"{fileDir}/{projectFileName}";
  6079. //if (TypeName == "A")//A代表团组增减款项
  6080. //{
  6081. // filePath = fileDir + $@"\团组增减款项相关文件";
  6082. // if (!Directory.Exists(filePath))
  6083. // {
  6084. // Directory.CreateDirectory(filePath);
  6085. // }
  6086. // //上传的文件的路径
  6087. // filePath += $@"\{projectFileName}";
  6088. //}
  6089. //else if (TypeName == "B")//B代表商邀相关文件
  6090. //{
  6091. // //上传的文件的路径
  6092. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6093. // if (!Directory.Exists(filePath))
  6094. // {
  6095. // Directory.CreateDirectory(filePath);
  6096. // }
  6097. // //上传的文件的路径
  6098. // filePath = $@"\{projectFileName}";
  6099. //}
  6100. //try
  6101. //{
  6102. // using (FileStream fs = System.IO.File.Create(filePath))
  6103. // {
  6104. // file.CopyTo(fs);
  6105. // fs.Flush();
  6106. // }
  6107. //}
  6108. //catch (Exception ex)
  6109. //{
  6110. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  6111. //}
  6112. //return Ok(JsonView(true, "上传成功!", projectFileName));
  6113. try
  6114. {
  6115. var TypeName = Request.Headers["TypeName"].ToString();
  6116. if (file != null)
  6117. {
  6118. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6119. //文件名称
  6120. string projectFileName = file.FileName;
  6121. //上传的文件的路径
  6122. string filePath = $"{fileDir}/{projectFileName}";
  6123. if (TypeName == "A")//A代表团组增减款项
  6124. {
  6125. if (!Directory.Exists(fileDir))
  6126. {
  6127. Directory.CreateDirectory(fileDir);
  6128. }
  6129. //上传的文件的路径
  6130. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  6131. }
  6132. else if (TypeName == "B")//B代表商邀相关文件
  6133. {
  6134. if (!Directory.Exists(fileDir))
  6135. {
  6136. Directory.CreateDirectory(fileDir);
  6137. }
  6138. //上传的文件的路径
  6139. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6140. }
  6141. using (FileStream fs = System.IO.File.Create(filePath))
  6142. {
  6143. file.CopyTo(fs);
  6144. fs.Flush();
  6145. }
  6146. return Ok(JsonView(true, "上传成功!", projectFileName));
  6147. }
  6148. else
  6149. {
  6150. return Ok(JsonView(false, "上传失败!"));
  6151. }
  6152. }
  6153. catch (Exception ex)
  6154. {
  6155. return Ok(JsonView(false, ex.Message));
  6156. }
  6157. }
  6158. /// <summary>
  6159. /// 删除指定文件
  6160. /// </summary>
  6161. /// <param name="dto"></param>
  6162. /// <returns></returns>
  6163. [HttpPost]
  6164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6165. public async Task<IActionResult> DelFile(DelFileDto dto)
  6166. {
  6167. try
  6168. {
  6169. var TypeName = Request.Headers["TypeName"].ToString();
  6170. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  6171. string filePath = "";
  6172. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6173. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  6174. int id = 0;
  6175. if (TypeName == "A")
  6176. {
  6177. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  6178. // 删除该文件
  6179. System.IO.File.Delete(filePath);
  6180. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  6181. .Where(a => a.Id == dto.Id)
  6182. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  6183. .ExecuteCommandAsync();
  6184. }
  6185. else if (TypeName == "B")
  6186. {
  6187. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  6188. // 删除该文件
  6189. System.IO.File.Delete(filePath);
  6190. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  6191. if (info != null)
  6192. {
  6193. string[] files = Array.Empty<string>();
  6194. if (!string.IsNullOrEmpty(info.Attachment))
  6195. {
  6196. try
  6197. {
  6198. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  6199. }
  6200. catch (Exception)
  6201. {
  6202. files = new List<string>() { info.Attachment }.ToArray();
  6203. }
  6204. }
  6205. if (files.Length > 0)
  6206. {
  6207. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  6208. string filePath2 = string.Empty;
  6209. if (files1.Length > 0)
  6210. {
  6211. filePath2 = JsonConvert.SerializeObject(files1);
  6212. }
  6213. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6214. .Where(a => a.Id == dto.Id)
  6215. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  6216. .ExecuteCommandAsync();
  6217. }
  6218. }
  6219. }
  6220. if (id != 0)
  6221. {
  6222. return Ok(JsonView(true, "成功!"));
  6223. }
  6224. else
  6225. {
  6226. return Ok(JsonView(false, "失败!"));
  6227. }
  6228. }
  6229. catch (Exception ex)
  6230. {
  6231. return Ok(JsonView(false, "程序错误!"));
  6232. throw;
  6233. }
  6234. }
  6235. /// <summary>
  6236. /// 文件上传多个文件 可以带参数
  6237. /// </summary>
  6238. /// <param name="files"></param>
  6239. /// <returns></returns>
  6240. [HttpPost]
  6241. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6242. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  6243. {
  6244. try
  6245. {
  6246. var TypeName = Request.Headers["TypeName"].ToString();
  6247. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  6248. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  6249. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  6250. var filePahts = new List<string>();
  6251. foreach (var file in files)
  6252. {
  6253. //文件名称
  6254. string projectFileName = file.FileName;
  6255. //上传的文件的路径
  6256. string filePath = $"{fileDir}/{projectFileName}";
  6257. if (TypeName == "A")//A代表团组增减款项
  6258. {
  6259. if (!Directory.Exists(fileDir))
  6260. {
  6261. Directory.CreateDirectory(fileDir);
  6262. }
  6263. //上传的文件的路径
  6264. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  6265. }
  6266. else if (TypeName == "B")//B代表商邀相关文件
  6267. {
  6268. if (!Directory.Exists(fileDir))
  6269. {
  6270. Directory.CreateDirectory(fileDir);
  6271. }
  6272. //上传的文件的路径
  6273. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  6274. }
  6275. using (FileStream fs = System.IO.File.Create(filePath))
  6276. {
  6277. file.CopyTo(fs);
  6278. fs.Flush();
  6279. }
  6280. filePahts.Add(projectFileName);
  6281. }
  6282. return Ok(JsonView(true, "上传成功!", filePahts));
  6283. }
  6284. catch (Exception ex)
  6285. {
  6286. return Ok(JsonView(false, ex.Message));
  6287. }
  6288. }
  6289. #endregion
  6290. #region 商邀费用录入
  6291. /// <summary>
  6292. /// 根据团组Id查询商邀费用列表
  6293. /// </summary>
  6294. /// <param name="dto"></param>
  6295. /// <returns></returns>
  6296. [HttpPost]
  6297. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6298. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  6299. {
  6300. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  6301. if (groupData.Code != 0)
  6302. {
  6303. return Ok(JsonView(false, groupData.Msg));
  6304. }
  6305. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6306. }
  6307. /// <summary>
  6308. /// 商邀费用列表
  6309. /// 下载文件
  6310. /// </summary>
  6311. /// <param name="id"></param>
  6312. /// <returns></returns>
  6313. [HttpGet("{id}")]
  6314. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6315. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  6316. {
  6317. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  6318. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  6319. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  6320. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  6321. var filePaths = new List<string>();
  6322. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  6323. try
  6324. {
  6325. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  6326. }
  6327. catch (Exception ex)
  6328. {
  6329. filePaths.Add(info.Attachment);
  6330. }
  6331. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  6332. for (int i = 0; i < filePaths.Count; i++)
  6333. {
  6334. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  6335. }
  6336. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  6337. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  6338. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  6339. {
  6340. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  6341. {
  6342. foreach (string filePath in filePaths)
  6343. {
  6344. if (System.IO.File.Exists(filePath))
  6345. {
  6346. // 获取文件名
  6347. string fileName = Path.GetFileName(filePath);
  6348. // 将文件添加到ZIP归档中
  6349. zipArchive.CreateEntryFromFile(filePath, fileName);
  6350. }
  6351. }
  6352. }
  6353. }
  6354. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  6355. }
  6356. /// <summary>
  6357. /// 商邀费用 Info Page 基础数据源
  6358. /// </summary>
  6359. /// <returns></returns>
  6360. [HttpPost]
  6361. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6362. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  6363. {
  6364. try
  6365. {
  6366. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  6367. if (groupData.Code != 0)
  6368. {
  6369. return Ok(JsonView(false, groupData.Msg));
  6370. }
  6371. return Ok(JsonView(true, "操作成功", groupData.Data));
  6372. }
  6373. catch (Exception ex)
  6374. {
  6375. return Ok(JsonView(false, ex.Message));
  6376. throw;
  6377. }
  6378. }
  6379. /// <summary>
  6380. /// 根据商邀费用ID查询C表和商邀费用数据
  6381. /// </summary>
  6382. /// <param name="dto"></param>
  6383. /// <returns></returns>
  6384. [HttpPost]
  6385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6386. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  6387. {
  6388. try
  6389. {
  6390. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  6391. if (groupData.Code != 0)
  6392. {
  6393. return Ok(JsonView(false, groupData.Msg));
  6394. }
  6395. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6396. }
  6397. catch (Exception ex)
  6398. {
  6399. return Ok(JsonView(false, ex.Message));
  6400. throw;
  6401. }
  6402. }
  6403. /// <summary>
  6404. /// 商邀费用录入操作(Status:1.新增,2.修改)
  6405. /// </summary>
  6406. /// <param name="dto"></param>
  6407. /// <returns></returns>
  6408. [HttpPost]
  6409. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6410. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  6411. {
  6412. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  6413. if (groupData.Code != 0)
  6414. {
  6415. return Ok(JsonView(false, groupData.Msg));
  6416. }
  6417. #region 应用推送
  6418. try
  6419. {
  6420. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6421. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6422. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6423. //2024-10-21 新增LZ UID
  6424. var userIds = new List<int>() { 21 };
  6425. string title = $"系统通知";
  6426. string content = "";
  6427. var diId = dto.DiId;
  6428. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6429. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6430. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6431. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6432. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6433. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  6434. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6435. }
  6436. catch (Exception ex)
  6437. {
  6438. }
  6439. #endregion
  6440. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6441. }
  6442. /// <summary>
  6443. /// 商邀删除
  6444. /// </summary>
  6445. /// <param name="dto"></param>
  6446. /// <returns></returns>
  6447. [HttpPost]
  6448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6449. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  6450. {
  6451. try
  6452. {
  6453. _sqlSugar.BeginTran();
  6454. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  6455. .SetColumns(it => new Grp_InvitationOfficialActivities()
  6456. {
  6457. IsDel = 1,
  6458. DeleteUserId = dto.DeleteUserId,
  6459. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6460. })
  6461. .Where(it => it.Id == dto.Id)
  6462. .ExecuteCommand();
  6463. if (res1 > 0)
  6464. {
  6465. int _diId = 0;
  6466. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  6467. if (_ioaInfo != null)
  6468. {
  6469. _diId = _ioaInfo.DiId;
  6470. }
  6471. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6472. .SetColumns(a => new Grp_CreditCardPayment()
  6473. {
  6474. IsDel = 1,
  6475. DeleteUserId = dto.DeleteUserId,
  6476. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  6477. })
  6478. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  6479. .ExecuteCommand();
  6480. if (res2 > 0)
  6481. {
  6482. _sqlSugar.CommitTran();
  6483. return Ok(JsonView(true, "删除成功!"));
  6484. }
  6485. }
  6486. _sqlSugar.RollbackTran();
  6487. return Ok(JsonView(false, "删除失败"));
  6488. }
  6489. catch (Exception ex)
  6490. {
  6491. _sqlSugar.RollbackTran();
  6492. return Ok(JsonView(false, ex.Message));
  6493. }
  6494. }
  6495. #endregion
  6496. #region 票据上传
  6497. /// <summary>
  6498. /// 团组模块文件上传
  6499. /// </summary>
  6500. /// <param name="dto"></param>
  6501. /// <returns></returns>
  6502. [HttpPost]
  6503. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  6504. {
  6505. var jw = JsonView(false);
  6506. long M = 1024 * 1024;
  6507. if (dto.Files == null || dto.Files.Count == 0)
  6508. {
  6509. jw.Msg = "无文件信息!";
  6510. return Ok(jw);
  6511. }
  6512. if (dto.Files.Sum(x => x.Length) > 20 * M)
  6513. {
  6514. jw.Msg = "文件大小超过20M!";
  6515. return Ok(jw);
  6516. }
  6517. //var nameSp = dto.File.FileName.Split(".");
  6518. //if (nameSp.Length < 2)
  6519. //{
  6520. // jw.Msg = "拓展名称有误!";
  6521. // return Ok(jw);
  6522. //}
  6523. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  6524. //if (!existsName.Contains(nameSp[1].ToUpper()))
  6525. //{
  6526. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  6527. // return Ok(jw);
  6528. //}
  6529. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  6530. if (Ctable == null)
  6531. {
  6532. jw.Msg = "Ctable指向有误!";
  6533. return Ok(jw);
  6534. }
  6535. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  6536. if (groupInfo == null)
  6537. {
  6538. jw.Msg = "团组信息不存在!";
  6539. return Ok(jw);
  6540. }
  6541. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  6542. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6543. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6544. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6545. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  6546. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  6547. try
  6548. {
  6549. if (!Directory.Exists(fileBase))
  6550. {
  6551. Directory.CreateDirectory(fileBase);
  6552. }
  6553. var saveArr = new List<Grp_GroupModelFile>();
  6554. foreach (var fileStream in dto.Files)
  6555. {
  6556. var saveFilePath = fileBase + "\\" + fileStream.FileName;
  6557. var file = new Grp_GroupModelFile()
  6558. {
  6559. Cid = dto.Cid,
  6560. CreateTime = DateTime.Now,
  6561. CreateUserId = dto.Userid,
  6562. Ctable = dto.Ctable,
  6563. Diid = dto.Diid,
  6564. IsDel = 0,
  6565. FilePath = saveFilePath,
  6566. FileName = fileStream.FileName
  6567. };
  6568. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6569. {
  6570. fileStream.CopyTo(fs);
  6571. fs.Flush();
  6572. }
  6573. saveArr.Add(file);
  6574. }
  6575. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  6576. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  6577. jw = JsonView(true, "保存成功!", new
  6578. {
  6579. count = addResult,
  6580. filesName = saveArr.Select(x => x.FileName)
  6581. });
  6582. }
  6583. catch (Exception ex)
  6584. {
  6585. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  6586. {
  6587. count = 0,
  6588. filesName = Array.Empty<string>(),
  6589. });
  6590. }
  6591. return Ok(jw);
  6592. }
  6593. /// <summary>
  6594. /// 查询各模块已保存文件
  6595. /// </summary>
  6596. /// <param name="dto"></param>
  6597. /// <returns></returns>
  6598. [HttpPost]
  6599. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  6600. {
  6601. var expression = Expressionable.Create<Grp_GroupModelFile>()
  6602. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  6603. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  6604. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  6605. {
  6606. expression = Expressionable.Create<Grp_GroupModelFile>()
  6607. .And(x => visaIds.Contains(x.CreateUserId));
  6608. }
  6609. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  6610. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  6611. .Where(expression.ToExpression())
  6612. .ToList();
  6613. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  6614. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  6615. {
  6616. x.FileName,
  6617. x.Id,
  6618. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  6619. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  6620. })));
  6621. }
  6622. /// <summary>
  6623. /// 下载该团组下的所有文件
  6624. /// </summary>
  6625. /// <param name="dto"></param>
  6626. /// <returns></returns>
  6627. [HttpPost]
  6628. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  6629. {
  6630. var jw = JsonView(false);
  6631. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6632. if (groupInfo == null)
  6633. {
  6634. jw.Msg = "团组信息不存在!";
  6635. return Ok(jw);
  6636. }
  6637. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  6638. var isModule = Convert.ToBoolean(dto.isModule);
  6639. var Zips = new Dictionary<string, Stream>();
  6640. var io = new IOOperatorHelper();
  6641. if (isModule)
  6642. {
  6643. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  6644. foreach (var moduleArr in moduleGroup)
  6645. {
  6646. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  6647. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6648. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6649. var chiZips = new Dictionary<string, Stream>();
  6650. foreach (var item in moduleArr)
  6651. {
  6652. if (System.IO.File.Exists(item.FilePath))
  6653. {
  6654. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6655. {
  6656. byte[] bytes = new byte[fileStream.Length];
  6657. fileStream.Read(bytes, 0, bytes.Length);
  6658. fileStream.Close();
  6659. Stream stream = new MemoryStream(bytes);
  6660. chiZips.Add(item.FileName, stream);
  6661. }
  6662. }
  6663. }
  6664. if (chiZips.Count > 0)
  6665. {
  6666. var byts = io.ConvertZipStream(chiZips);
  6667. Stream stream = new MemoryStream(byts);
  6668. Zips.Add(key.Name + "_.zip", stream);
  6669. }
  6670. }
  6671. }
  6672. else
  6673. {
  6674. foreach (var item in dbQuery)
  6675. {
  6676. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6677. {
  6678. byte[] bytes = new byte[fileStream.Length];
  6679. fileStream.Read(bytes, 0, bytes.Length);
  6680. fileStream.Close();
  6681. var stream = new MemoryStream(bytes);
  6682. while (Zips.ContainsKey(item.FileName))
  6683. {
  6684. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6685. }
  6686. Zips.Add(item.FileName, stream);
  6687. }
  6688. }
  6689. }
  6690. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6691. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6692. if (Zips.Count > 0)
  6693. {
  6694. var byts = io.ConvertZipStream(Zips);
  6695. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6696. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  6697. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  6698. }
  6699. else
  6700. {
  6701. jw.Msg = "暂无生成文件!";
  6702. }
  6703. return Ok(jw);
  6704. }
  6705. /// <summary>
  6706. /// 下载该团组下此模块的所有文件
  6707. /// </summary>
  6708. /// <param name="dto"></param>
  6709. /// <returns></returns>
  6710. [HttpPost]
  6711. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  6712. {
  6713. var jw = JsonView(false);
  6714. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  6715. if (groupInfo == null)
  6716. {
  6717. jw.Msg = "团组信息不存在!";
  6718. return Ok(jw);
  6719. }
  6720. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  6721. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  6722. && x.IsDel == 0);
  6723. if (key == null)
  6724. {
  6725. jw.Msg = "Ctable指向错误!";
  6726. return Ok(jw);
  6727. }
  6728. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  6729. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6730. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  6731. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  6732. var io = new IOOperatorHelper();
  6733. var Zips = new Dictionary<string, Stream>();
  6734. foreach (var item in dbQuery)
  6735. {
  6736. if (System.IO.File.Exists(item.FilePath))
  6737. {
  6738. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  6739. {
  6740. byte[] bytes = new byte[fileStream.Length];
  6741. fileStream.Read(bytes, 0, bytes.Length);
  6742. fileStream.Close();
  6743. var stream = new MemoryStream(bytes);
  6744. while (Zips.ContainsKey(item.FileName))
  6745. {
  6746. item.FileName = new Random().Next(100) + "_" + item.FileName;
  6747. }
  6748. Zips.Add(item.FileName, stream);
  6749. }
  6750. }
  6751. }
  6752. if (Zips.Count > 0)
  6753. {
  6754. var byts = io.ConvertZipStream(Zips);
  6755. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  6756. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  6757. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  6758. }
  6759. else
  6760. {
  6761. jw.Msg = "暂无生成文件!";
  6762. }
  6763. return Ok(jw);
  6764. }
  6765. /// <summary>
  6766. /// 删除该团组下的指定文件
  6767. /// </summary>
  6768. /// <param name="dto"></param>
  6769. /// <returns></returns>
  6770. [HttpPost]
  6771. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  6772. {
  6773. var jw = JsonView(false);
  6774. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  6775. if (sing == null)
  6776. {
  6777. jw.Msg = "暂无";
  6778. return Ok(jw);
  6779. }
  6780. if (System.IO.File.Exists(sing.FilePath))
  6781. {
  6782. try
  6783. {
  6784. System.IO.File.Delete(sing.FilePath);
  6785. }
  6786. catch (Exception ex)
  6787. {
  6788. jw.Msg = "删除失败!" + ex.Message;
  6789. return Ok(jw);
  6790. }
  6791. }
  6792. sing.IsDel = 1;
  6793. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  6794. sing.DeleteUserId = dto.UserId;
  6795. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  6796. jw = JsonView(true, "删除成功!");
  6797. return Ok(jw);
  6798. }
  6799. #endregion
  6800. #region 共享文件上传
  6801. /// <summary>
  6802. /// 共享文件数据初始化
  6803. /// </summary>
  6804. /// <returns></returns>
  6805. [HttpGet]
  6806. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  6807. {
  6808. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  6809. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  6810. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  6811. .Select(x => x.Id)
  6812. .ToList()
  6813. .Contains(userid);
  6814. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  6815. .Where(x => x.STid == 111 && x.IsDel == 0)
  6816. .Select(x => new
  6817. {
  6818. x.Name,
  6819. x.Id,
  6820. }).ToList();
  6821. if (isMarketingDepartment)
  6822. {
  6823. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  6824. }
  6825. if (portType == 1)
  6826. {
  6827. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  6828. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  6829. .Where(x => x.IsDel == 0)
  6830. .OrderByDescending(x => x.VisitDate)
  6831. .Select(x => new
  6832. {
  6833. x.TeamName,
  6834. x.Id,
  6835. x.CityId,
  6836. })
  6837. .ToList()
  6838. .Select(x =>
  6839. {
  6840. var provinceId = x.CityId;
  6841. var isDefualtVal = true;
  6842. if (provinceId > 0)
  6843. {
  6844. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  6845. if (parentId != null)
  6846. {
  6847. isDefualtVal = false;
  6848. provinceId = (int)parentId;
  6849. }
  6850. }
  6851. if (isDefualtVal)
  6852. {
  6853. provinceId = 122; //默认四川
  6854. }
  6855. return new
  6856. {
  6857. x.TeamName,
  6858. x.Id,
  6859. provinceId,
  6860. };
  6861. })
  6862. .ToList();
  6863. return Ok(JsonView(true, "SUCCESS!", new
  6864. {
  6865. dropDownType,
  6866. dropDownGroupList,
  6867. isMarketingDepartment
  6868. }));
  6869. }
  6870. else if (portType == 2 || portType == 3)
  6871. {
  6872. return Ok(JsonView(true, "SUCCESS!", new
  6873. {
  6874. dropDownType,
  6875. isMarketingDepartment
  6876. }));
  6877. }
  6878. else
  6879. {
  6880. return Ok(JsonView(false, "portType有误!"));
  6881. }
  6882. }
  6883. /// <summary>
  6884. /// 共享文件上传
  6885. /// </summary>
  6886. /// <param name="dto"></param>
  6887. /// <returns></returns>
  6888. [HttpPost]
  6889. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  6890. {
  6891. var isGroup = new List<int> { 1412 };
  6892. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  6893. {
  6894. return Ok(JsonView(false, "该文件需要关联团组!"));
  6895. }
  6896. if (dto.Files == null || dto.Files.Count == 0)
  6897. {
  6898. return Ok(JsonView(false, "无文件信息!"));
  6899. }
  6900. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  6901. {
  6902. return Ok(JsonView(false, "文件大小超过20M!"));
  6903. }
  6904. if (dto.Userid < 1)
  6905. {
  6906. return Ok(JsonView(false, "请传入有效的Userid!"));
  6907. }
  6908. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  6909. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  6910. .Select((u, j) => new
  6911. {
  6912. u.CnName,
  6913. UserId = u.Id,
  6914. j.JobName,
  6915. })
  6916. .First();
  6917. if (jobInfo == null)
  6918. {
  6919. return Ok(JsonView(false, "请传入有效的Userid!"));
  6920. }
  6921. var commonFileExtensions = new List<string>
  6922. {
  6923. // 文本文件
  6924. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  6925. // 图片文件
  6926. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  6927. // 视频文件
  6928. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  6929. // 音频文件
  6930. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  6931. // 压缩文件
  6932. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  6933. // 数据文件
  6934. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  6935. };
  6936. try
  6937. {
  6938. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  6939. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  6940. commonFileExtensions.AddRange(settingExtend);
  6941. }
  6942. catch (Exception)
  6943. { }
  6944. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  6945. if (setdata == null)
  6946. {
  6947. return Ok(JsonView(false, "请传入有效的FileType!"));
  6948. }
  6949. var insertList = new List<Grp_GroupShareFile>();
  6950. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  6951. if (!Directory.Exists(winPath))
  6952. {
  6953. Directory.CreateDirectory(winPath);
  6954. }
  6955. foreach (var item in dto.Files)
  6956. {
  6957. var houzui = Path.GetExtension(item.FileName);
  6958. if (!commonFileExtensions.Contains(houzui))
  6959. {
  6960. return Ok(JsonView(false, "未知后缀名称!"));
  6961. }
  6962. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  6963. var saveFilePath = winPath + fileName;
  6964. using (FileStream fs = System.IO.File.Create(saveFilePath))
  6965. {
  6966. item.CopyTo(fs);
  6967. fs.Flush();
  6968. }
  6969. var fileDetail = new Grp_GroupShareFile()
  6970. {
  6971. CreateUserId = dto.Userid,
  6972. CreateTime = DateTime.Now,
  6973. UploadJob = jobInfo.JobName,
  6974. FileName = fileName,
  6975. FileType = dto.FileType,
  6976. Diid = dto.Diid,
  6977. FilePath = winPath + fileName,
  6978. };
  6979. insertList.Add(fileDetail);
  6980. }
  6981. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  6982. return Ok(JsonView(true, "保存成功!"));
  6983. }
  6984. /// <summary>
  6985. /// 查询共享文件列表
  6986. /// </summary>
  6987. /// <param name="dto"></param>
  6988. /// <returns></returns>
  6989. [HttpPost]
  6990. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  6991. {
  6992. var isGroup = new List<int> { 1412 };
  6993. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  6994. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  6995. .And(x => x.Diid == dto.Diid)
  6996. .And(x => x.FileType == dto.FileType)
  6997. .And(x => x.IsDel == 0)
  6998. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  6999. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  7000. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  7001. int totalCount = 0;
  7002. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  7003. .Where(queryExpression.ToExpression())
  7004. .OrderBy(x => x.UploadJob)
  7005. .Select(x => new
  7006. {
  7007. x.Id,
  7008. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  7009. x.FileName,
  7010. x.FileType,
  7011. x.CreateTime,
  7012. })
  7013. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  7014. return Ok(JsonView(true, "SUCCESS!", new
  7015. {
  7016. FileList = dbQuery,
  7017. dto.PageSize,
  7018. dto.PageIndex,
  7019. totalCount
  7020. }));
  7021. }
  7022. /// <summary>
  7023. /// 删除共享文件模块下的指定文件
  7024. /// </summary>
  7025. /// <param name="dto"></param>
  7026. /// <returns></returns>
  7027. [HttpPost]
  7028. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  7029. {
  7030. var jw = JsonView(false);
  7031. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  7032. if (sing == null)
  7033. {
  7034. jw.Msg = "暂无文件信息!";
  7035. return Ok(jw);
  7036. }
  7037. if (sing.CreateUserId != dto.UserId)
  7038. {
  7039. jw.Msg = "只能删除自己上传的文件!";
  7040. return Ok(jw);
  7041. }
  7042. if (System.IO.File.Exists(sing.FilePath))
  7043. {
  7044. try
  7045. {
  7046. System.IO.File.Delete(sing.FilePath);
  7047. }
  7048. catch (Exception ex)
  7049. {
  7050. jw.Msg = "删除失败!" + ex.Message;
  7051. return Ok(jw);
  7052. }
  7053. }
  7054. sing.IsDel = 1;
  7055. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  7056. sing.DeleteUserId = dto.UserId;
  7057. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  7058. jw = JsonView(true, "删除成功!");
  7059. return Ok(jw);
  7060. }
  7061. #endregion
  7062. #region 团组英文资料
  7063. /// <summary>
  7064. /// 查询团组英文所有资料
  7065. /// </summary>
  7066. /// <param name="dto"></param>
  7067. /// <returns></returns>
  7068. [HttpPost]
  7069. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7070. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  7071. {
  7072. try
  7073. {
  7074. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  7075. if (groupData.Code != 0)
  7076. {
  7077. return Ok(JsonView(false, groupData.Msg));
  7078. }
  7079. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7080. }
  7081. catch (Exception ex)
  7082. {
  7083. return Ok(JsonView(false, ex.Message));
  7084. throw;
  7085. }
  7086. }
  7087. /// <summary>
  7088. /// 团组英文资料操作(Status:1.新增,2.修改)
  7089. /// </summary>
  7090. /// <param name="dto"></param>
  7091. /// <returns></returns>
  7092. [HttpPost]
  7093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7094. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  7095. {
  7096. try
  7097. {
  7098. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  7099. if (groupData.Code != 0)
  7100. {
  7101. return Ok(JsonView(false, groupData.Msg));
  7102. }
  7103. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7104. }
  7105. catch (Exception ex)
  7106. {
  7107. return Ok(JsonView(false, ex.Message));
  7108. throw;
  7109. }
  7110. }
  7111. /// <summary>
  7112. /// 团组英文资料Id查询数据
  7113. /// </summary>
  7114. /// <param name="dto"></param>
  7115. /// <returns></returns>
  7116. [HttpPost]
  7117. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7118. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  7119. {
  7120. try
  7121. {
  7122. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  7123. if (_DelegationEnData != null)
  7124. {
  7125. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  7126. }
  7127. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  7128. }
  7129. catch (Exception ex)
  7130. {
  7131. return Ok(JsonView(false, "程序错误!"));
  7132. throw;
  7133. }
  7134. }
  7135. /// <summary>
  7136. /// 团组英文资料删除
  7137. /// </summary>
  7138. /// <param name="dto"></param>
  7139. /// <returns></returns>
  7140. [HttpPost]
  7141. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7142. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  7143. {
  7144. try
  7145. {
  7146. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  7147. if (!res)
  7148. {
  7149. return Ok(JsonView(false, "删除失败"));
  7150. }
  7151. return Ok(JsonView(true, "删除成功!"));
  7152. }
  7153. catch (Exception ex)
  7154. {
  7155. return Ok(JsonView(false, ex.Message));
  7156. throw;
  7157. }
  7158. }
  7159. #endregion
  7160. #region 导出邀请函
  7161. /// <summary>
  7162. /// 导出邀请函页面初始化
  7163. /// </summary>
  7164. /// <param name="dto"></param>
  7165. /// <returns></returns>
  7166. [HttpPost]
  7167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7168. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  7169. {
  7170. try
  7171. {
  7172. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  7173. var crm_Deles = new List<Crm_DeleClient>();
  7174. if (dto.DiId == 0)
  7175. {
  7176. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  7177. }
  7178. else
  7179. {
  7180. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  7181. }
  7182. return Ok(JsonView(true, "查询成功!", new
  7183. {
  7184. deleClient = crm_Deles,
  7185. delegations = grp_Delegations
  7186. }));
  7187. }
  7188. catch (Exception ex)
  7189. {
  7190. return Ok(JsonView(false, "程序错误!"));
  7191. throw;
  7192. }
  7193. }
  7194. /// <summary>
  7195. /// 导出邀请函
  7196. /// </summary>
  7197. /// <param name="dto"></param>
  7198. /// <returns></returns>
  7199. [HttpPost]
  7200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7201. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  7202. {
  7203. #region 参数验证
  7204. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7205. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7206. #endregion
  7207. try
  7208. {
  7209. var transDic = new Dictionary<string, string>();
  7210. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  7211. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  7212. From Grp_TourClientList tcl
  7213. Left Join
  7214. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  7215. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  7216. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  7217. From Crm_DeleClient dc
  7218. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  7219. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  7220. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  7221. Where dc.IsDel = 0) temp
  7222. On temp.DcId =tcl.ClientId
  7223. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  7224. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  7225. var texts = new List<string>();
  7226. if (datas.Count != 0)
  7227. {
  7228. foreach (TourClientListDetailsView item in datas)
  7229. {
  7230. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  7231. {
  7232. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  7233. }
  7234. else
  7235. {
  7236. string name = item.LastName + item.FirstName;
  7237. texts.Add(name);
  7238. }
  7239. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  7240. {
  7241. if (!transDic.ContainsKey(item.Job))
  7242. {
  7243. texts.Add(item.Job);
  7244. }
  7245. }
  7246. if (!string.IsNullOrEmpty(item.CompanyFullName))
  7247. {
  7248. texts.Add(item.CompanyFullName);
  7249. }
  7250. }
  7251. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  7252. if (transData.Count > 0)
  7253. {
  7254. foreach (TranslateResult item in transData)
  7255. {
  7256. if (!transDic.ContainsKey(item.Query))
  7257. {
  7258. transDic.Add(item.Query, item.Translation);
  7259. }
  7260. }
  7261. }
  7262. var list = new List<GuestList>();
  7263. foreach (var dele in datas)
  7264. {
  7265. var guestList = new GuestList();
  7266. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  7267. {
  7268. guestList.Name = dele.Pinyin;
  7269. }
  7270. else
  7271. {
  7272. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  7273. guestList.Name = Name;
  7274. }
  7275. if (dele.Sex == 0)
  7276. {
  7277. guestList.Sex = "Male";
  7278. }
  7279. else if (dele.Sex == 1)
  7280. {
  7281. guestList.Sex = "Female";
  7282. }
  7283. guestList.DOB = dele.BirthDay.Replace('-', '.');
  7284. if (!string.IsNullOrEmpty(dele.Job))
  7285. {
  7286. guestList.Job = dele.Job;
  7287. }
  7288. list.Add(guestList);
  7289. }
  7290. //载入模板
  7291. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  7292. var builder = new DocumentBuilder(doc);
  7293. //获取word里所有表格
  7294. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7295. //获取所填表格的序数
  7296. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  7297. var rowStart = tableOne.Rows[0]; //获取第1行
  7298. //循环赋值
  7299. for (int i = 0; i < list.Count; i++)
  7300. {
  7301. builder.MoveToCell(0, i + 1, 0, 0);
  7302. builder.Write(list[i].Name.ToString());
  7303. builder.MoveToCell(0, i + 1, 1, 0);
  7304. builder.Write(list[i].Sex.ToString());
  7305. builder.MoveToCell(0, i + 1, 2, 0);
  7306. builder.Write(list[i].DOB.ToString());
  7307. builder.MoveToCell(0, i + 1, 3, 0);
  7308. builder.Write(list[i].Job.ToString());
  7309. }
  7310. //删除多余行
  7311. while (tableOne.Rows.Count > list.Count + 1)
  7312. {
  7313. tableOne.Rows.RemoveAt(list.Count + 1);
  7314. }
  7315. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7316. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  7317. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  7318. doc.Save(filePath);
  7319. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  7320. return Ok(JsonView(true, "操作成功!", Url));
  7321. }
  7322. else
  7323. {
  7324. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  7325. }
  7326. }
  7327. catch (Exception ex)
  7328. {
  7329. return Ok(JsonView(false, ex.Message));
  7330. throw;
  7331. }
  7332. }
  7333. #endregion
  7334. #region 团组经理模块 出入境费用
  7335. /// <summary>
  7336. /// 团组模块 - 出入境费用 - 省份基础数据源
  7337. /// </summary>
  7338. /// <returns></returns>
  7339. [HttpGet]
  7340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7341. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  7342. {
  7343. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  7344. }
  7345. /// <summary>
  7346. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  7347. /// </summary>
  7348. /// <param name="dto"></param>
  7349. /// <returns></returns>
  7350. [HttpPost]
  7351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7352. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  7353. {
  7354. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  7355. var groupNamFirst = groupNameData.FirstOrDefault();
  7356. //SetDataInfoView
  7357. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  7358. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  7359. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  7360. //验证城市归属并给默认值
  7361. int provinceId = 122;
  7362. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  7363. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  7364. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  7365. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  7366. return Ok(JsonView(true, "查询成功!", new
  7367. {
  7368. GroupNameData = groupNameData,
  7369. CurrencyData = _CurrencyData,
  7370. WordTypeData = wordTypeData,
  7371. ExcelTypeData = excelTypeData,
  7372. CurrencyInit = _currencyInfos,
  7373. ViewPermissionData = viewPermissionData
  7374. }));
  7375. }
  7376. /// <summary>
  7377. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  7378. /// </summary>
  7379. /// <returns></returns>
  7380. [HttpGet("{provinceId}")]
  7381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7382. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  7383. {
  7384. //验证城市归属并给默认值
  7385. if (provinceId < 1) provinceId = 122;
  7386. /*
  7387. * 122 四川
  7388. * 108 贵州
  7389. * 103 重庆
  7390. * 132 云南
  7391. */
  7392. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  7393. return Ok(JsonView(true, "查询成功!", new
  7394. {
  7395. WordTypeData = wordTypeData,
  7396. ExcelTypeData = excelTypeData,
  7397. }));
  7398. }
  7399. /// <summary>
  7400. /// 团组模块 - 出入境费用
  7401. /// 实时汇率 tips
  7402. /// 签证费用 tips
  7403. /// 机票费用 tips
  7404. /// </summary>
  7405. /// <returns></returns>
  7406. [HttpPost]
  7407. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7408. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  7409. {
  7410. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  7411. //默认币种显示
  7412. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  7413. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  7414. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  7415. return Ok(JsonView(true, "查询成功!", new
  7416. {
  7417. //GroupNameData = groupNameData.Data,
  7418. visaData = visaData.Data,
  7419. airData,
  7420. reteInfos
  7421. }));
  7422. }
  7423. /// <summary>
  7424. /// 团组模块 - 出入境费用 - Info
  7425. /// </summary>
  7426. /// <param name="dto"></param>
  7427. /// <returns></returns>
  7428. [HttpPost]
  7429. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  7430. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7431. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  7432. {
  7433. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7434. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7435. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  7436. }
  7437. /// <summary>
  7438. /// 团组模块 - 出入境费用 - 设置view权限
  7439. /// </summary>
  7440. /// <returns></returns>
  7441. [HttpPost]
  7442. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7443. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  7444. {
  7445. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  7446. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  7447. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  7448. var permissions = new List<Grp_EnterExitCostPermission>();
  7449. foreach (var userId in dto.UserIds)
  7450. {
  7451. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  7452. }
  7453. if (permissions.Any())
  7454. {
  7455. _sqlSugar.BeginTran();
  7456. try
  7457. {
  7458. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  7459. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  7460. if (result < 1)
  7461. {
  7462. _sqlSugar.RollbackTran();
  7463. return Ok(JsonView(false));
  7464. }
  7465. }
  7466. catch (Exception ex)
  7467. {
  7468. _sqlSugar.RollbackTran();
  7469. return Ok(JsonView(false, ex.Message));
  7470. }
  7471. _sqlSugar.CommitTran();
  7472. return Ok(JsonView(true));
  7473. }
  7474. return Ok(JsonView(false));
  7475. }
  7476. /// <summary>
  7477. /// 团组模块 - 出入境费用 - Add And Update
  7478. /// </summary>
  7479. /// <returns></returns>
  7480. [HttpPost]
  7481. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  7482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7483. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  7484. {
  7485. try
  7486. {
  7487. var rateRecords = new List<RateRecordInfo>();
  7488. #region 汇率保存前存储
  7489. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  7490. if (info != null)
  7491. {
  7492. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  7493. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  7494. {
  7495. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  7496. {
  7497. CurrencyCode = x.CurrencyCode,
  7498. CurrencyName = x.CurrencyName,
  7499. UpdatePreRate = x.Rate,
  7500. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  7501. }).ToList();
  7502. }
  7503. else
  7504. {
  7505. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7506. {
  7507. CurrencyCode = x.CurrencyCode,
  7508. CurrencyName = x.CurrencyName,
  7509. UpdatePreRate = 0.00M,
  7510. UpdateBreRate = x.Rate
  7511. }).ToList();
  7512. }
  7513. }
  7514. else
  7515. {
  7516. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  7517. {
  7518. CurrencyCode = x.CurrencyCode,
  7519. CurrencyName = x.CurrencyName,
  7520. UpdatePreRate = 0.00M,
  7521. UpdateBreRate = x.Rate
  7522. }).ToList();
  7523. }
  7524. #endregion
  7525. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  7526. if (dto.DayOtherPriceData.Any())
  7527. {
  7528. var inserList = dto.DayOtherPriceData
  7529. .Where(x => x.Id == 0)
  7530. .Select(x => new Grp_DayOtherPrice
  7531. {
  7532. Cost = x.Cost,
  7533. Id = x.Id,
  7534. CreateTime = DateTime.Now,
  7535. CreateUserId = dto.UserId,
  7536. Currency = x.Currency,
  7537. Diid = x.DiId,
  7538. Index = x.Index,
  7539. IsDel = 0,
  7540. SetDataId = x.SetDataId,
  7541. SubTotal = x.SubTotal,
  7542. Remark = x.Remark
  7543. })
  7544. .ToList();
  7545. var updateList = dto.DayOtherPriceData
  7546. .Where(x => x.Id != 0)
  7547. .Select(x => new Grp_DayOtherPrice
  7548. {
  7549. Cost = x.Cost,
  7550. Id = x.Id,
  7551. CreateTime = DateTime.Now,
  7552. CreateUserId = dto.UserId,
  7553. Currency = x.Currency,
  7554. Diid = x.DiId,
  7555. Index = x.Index,
  7556. IsDel = 0,
  7557. SetDataId = x.SetDataId,
  7558. SubTotal = x.SubTotal,
  7559. Remark = x.Remark
  7560. })
  7561. .ToList();
  7562. //添加
  7563. _sqlSugar.BeginTran();
  7564. if (inserList.Any())
  7565. {
  7566. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  7567. }
  7568. if (updateList.Any())
  7569. {
  7570. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  7571. }
  7572. _sqlSugar.CommitTran();
  7573. }
  7574. if (data.Code != 0)
  7575. {
  7576. return Ok(JsonView(false, data.Msg));
  7577. }
  7578. //生成默认文件pdf并且通知人员
  7579. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  7580. {
  7581. DiId = dto.DiId,
  7582. ExportType = 1,
  7583. SubTypeId = 1005
  7584. }, "pdf");
  7585. //发送通知
  7586. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  7587. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  7588. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  7589. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  7590. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  7591. //汇率信息记录
  7592. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  7593. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  7594. //汇率验证、反推
  7595. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  7596. if (isSendMsg)
  7597. {
  7598. //消息推送
  7599. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  7600. }
  7601. #region //日志汇率记录
  7602. //按照已使用币种记录
  7603. if (checkCurrencys != null && checkCurrencys.Count > 0)
  7604. {
  7605. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  7606. //汇率记录中加入实时汇率
  7607. if (liveRates != null && liveRates.Count > 0)
  7608. {
  7609. foreach (var item in rateRecords)
  7610. {
  7611. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  7612. }
  7613. }
  7614. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  7615. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  7616. var logContent = new StringBuilder();
  7617. foreach (var item in rateRecords)
  7618. {
  7619. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  7620. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  7621. logContent.AppendLine(msg);
  7622. }
  7623. _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());
  7624. }
  7625. #endregion
  7626. return Ok(JsonView(true, data.Msg, data.Data));
  7627. }
  7628. catch (Exception ex)
  7629. {
  7630. return Ok(JsonView(false, ex.Message));
  7631. }
  7632. }
  7633. /// <summary>
  7634. /// 团组模块 - 出入境费用 - Confirm 费用
  7635. /// </summary>
  7636. /// <returns></returns>
  7637. [HttpPost]
  7638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7639. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  7640. {
  7641. //TODO:测试完毕需把对应的用户ID更改
  7642. //1、数据表添加字段
  7643. //2、更改字段接口()
  7644. var _view = await _enterExitCostRep.ConfirmCost(dto);
  7645. //3、确认成功 给财务发送消息
  7646. if (_view.Code == 200)
  7647. {
  7648. if (dto.Type == 1)
  7649. {
  7650. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  7651. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  7652. }
  7653. }
  7654. return Ok(_view);
  7655. }
  7656. /// <summary>
  7657. /// 团组模块 - 出入境费用 - File download
  7658. /// </summary>
  7659. /// <param name="dto"></param>
  7660. /// <returns></returns>
  7661. [HttpPost]
  7662. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  7663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7664. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  7665. {
  7666. try
  7667. {
  7668. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  7669. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  7670. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  7671. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  7672. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  7673. 3 团组成员名单 1 团组成员名单", ""));
  7674. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  7675. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  7676. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  7677. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  7678. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  7679. //数据源
  7680. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  7681. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  7682. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  7683. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  7684. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  7685. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  7686. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  7687. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  7688. .Select((x, a, b) => new
  7689. {
  7690. x.Index,
  7691. itemName = a.Name,
  7692. CurrencyStr = b.Name,
  7693. x.Cost,
  7694. x.SubTotal,
  7695. x.Remark
  7696. })
  7697. .OrderBy((x) => x.Index)
  7698. .ToList(); //其他款项费用
  7699. var peiceItemCurrencys = new List<string>();
  7700. if (_DayAndCosts.Any())
  7701. {
  7702. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  7703. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  7704. }
  7705. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  7706. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  7707. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  7708. {
  7709. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  7710. }
  7711. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  7712. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  7713. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  7714. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  7715. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  7716. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  7717. .Select((tcl, dc, cc) => new ClientInfo
  7718. {
  7719. LastName = dc.LastName,
  7720. FirstName = dc.FirstName,
  7721. Sex = dc.Sex,
  7722. Birthday = dc.BirthDay,
  7723. Company = cc.CompanyFullName,
  7724. Job = dc.Job
  7725. })
  7726. .ToList();
  7727. foreach (var item in DeleClientList)
  7728. {
  7729. EncryptionProcessor.DecryptProperties(item);
  7730. }
  7731. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  7732. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  7733. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  7734. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  7735. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  7736. if (dto.ExportType == 1) //明细表
  7737. {
  7738. if (dto.SubTypeId == 1005) //1005(默认明细表)
  7739. {
  7740. //获取模板
  7741. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  7742. //载入模板
  7743. var doc = new Document(tempPath);
  7744. var builder = new DocumentBuilder(doc);
  7745. var dic = new Dictionary<string, string>();
  7746. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  7747. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  7748. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  7749. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  7750. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  7751. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  7752. //境内费用(其他费用)
  7753. if (_EnterExitCosts.ChoiceOne == 1)
  7754. {
  7755. string row1_1 = "";
  7756. if (_EnterExitCosts.Visa > 0)
  7757. {
  7758. //insidePayTotal += _EnterExitCosts.Visa;
  7759. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  7760. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  7761. //{
  7762. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  7763. //}
  7764. }
  7765. string row1_2 = "";
  7766. if (_EnterExitCosts.YiMiao > 0)
  7767. {
  7768. //insidePayTotal += _EnterExitCosts.YiMiao;
  7769. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  7770. }
  7771. if (_EnterExitCosts.HeSuan > 0)
  7772. {
  7773. //insidePayTotal += _EnterExitCosts.HeSuan;
  7774. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  7775. }
  7776. if (_EnterExitCosts.Service > 0)
  7777. {
  7778. //insidePayTotal += _EnterExitCosts.Service;
  7779. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  7780. }
  7781. string row1_3 = "";
  7782. if (_EnterExitCosts.Safe > 0)
  7783. {
  7784. //insidePayTotal += _EnterExitCosts.Safe;
  7785. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  7786. }
  7787. if (_EnterExitCosts.Ticket > 0)
  7788. {
  7789. //insidePayTotal += _EnterExitCosts.Ticket;
  7790. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  7791. }
  7792. string row1 = "";
  7793. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  7794. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  7795. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  7796. row1 += $"备注:{_EnterExitCosts.Remark}";
  7797. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  7798. dic.Add("Row1Str", row1);
  7799. }
  7800. string airTotalStr = string.Empty,
  7801. airPriceStr = string.Empty;
  7802. //经济舱
  7803. if (_EnterExitCosts.SumJJC == 1)
  7804. {
  7805. airTotalStr += $"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)";
  7806. airPriceStr += $"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)";
  7807. }
  7808. //公务舱
  7809. if (_EnterExitCosts.SumGWC == 1)
  7810. {
  7811. airTotalStr += $" {_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)";
  7812. airPriceStr += $" {_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)";
  7813. }
  7814. //头等舱
  7815. if (_EnterExitCosts.SumTDC == 1)
  7816. {
  7817. airTotalStr += $" {_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)";
  7818. airPriceStr += $" {_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)";
  7819. }
  7820. //汇率描述
  7821. string rateStr = "";
  7822. if (peiceItemCurrencyInfos.Any())
  7823. {
  7824. rateStr = "\r\n汇率描述:";
  7825. foreach (var item in peiceItemCurrencyInfos)
  7826. {
  7827. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ";
  7828. }
  7829. }
  7830. string twoItemRemark = "备注:";
  7831. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  7832. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  7833. dic.Add("AirTotalStr", airTotalStr);
  7834. dic.Add("AirPriceStr", airPriceStr);
  7835. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  7836. dic.Add("TwoItemRemark", twoItemRemark);
  7837. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  7838. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  7839. int table1Row = 0,
  7840. table2Row = 0,
  7841. table3Row = 0,
  7842. table4Row = 0,
  7843. table5Row = 0;
  7844. //住宿费
  7845. if (_EnterExitCosts.ChoiceThree == 1)
  7846. {
  7847. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  7848. table1Row = dac1.Count;
  7849. #region 填充word表格内容
  7850. for (int i = 0; i < dac1.Count; i++)
  7851. {
  7852. Grp_DayAndCost dac = dac1[i];
  7853. if (dac == null) continue;
  7854. builder.MoveToCell(0, i, 0, 0);
  7855. builder.Write("第" + dac.Days.ToString() + "晚:");
  7856. builder.MoveToCell(0, i, 1, 0);
  7857. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  7858. //builder.Write(dac.Place == null ? "" : dac.Place);
  7859. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7860. builder.MoveToCell(0, i, 2, 0);
  7861. builder.Write("费用标准:");
  7862. string curr = "";
  7863. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7864. if (currData != null)
  7865. {
  7866. curr = currData.Name;
  7867. }
  7868. builder.MoveToCell(0, i, 3, 0);
  7869. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7870. builder.MoveToCell(0, i, 4, 0);
  7871. builder.Write("费用小计:");
  7872. builder.MoveToCell(0, i, 5, 0);
  7873. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7874. }
  7875. #endregion
  7876. }
  7877. else dic.Add("SubZS", "0.00");
  7878. //删除多余行
  7879. while (table1.Rows.Count > table1Row)
  7880. {
  7881. table1.Rows.RemoveAt(table1Row);
  7882. }
  7883. //伙食费
  7884. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  7885. if (_EnterExitCosts.ChoiceFour == 1)
  7886. {
  7887. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  7888. table2Row = dac2.Count;
  7889. #region 填充word表格内容
  7890. for (int i = 0; i < dac2.Count; i++)
  7891. {
  7892. Grp_DayAndCost dac = dac2[i];
  7893. if (dac == null) continue;
  7894. builder.MoveToCell(1, i, 0, 0);
  7895. builder.Write("第" + dac.Days.ToString() + "天:");
  7896. builder.MoveToCell(1, i, 1, 0);
  7897. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7898. builder.MoveToCell(1, i, 2, 0);
  7899. builder.Write("费用标准:");
  7900. string curr = "";
  7901. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7902. if (currData != null)
  7903. {
  7904. curr = currData.Name;
  7905. }
  7906. builder.MoveToCell(1, i, 3, 0);
  7907. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7908. builder.MoveToCell(1, i, 4, 0);
  7909. builder.Write("费用小计:");
  7910. builder.MoveToCell(1, i, 5, 0);
  7911. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7912. }
  7913. #endregion
  7914. }
  7915. else dic.Add("SubHS", "0.00");
  7916. //删除多余行
  7917. while (table2.Rows.Count > table2Row)
  7918. {
  7919. table2.Rows.RemoveAt(table2Row);
  7920. }
  7921. //公杂费
  7922. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  7923. if (_EnterExitCosts.ChoiceFive == 1)
  7924. {
  7925. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  7926. table3Row = dac3.Count;
  7927. #region 填充word表格内容
  7928. for (int i = 0; i < dac3.Count; i++)
  7929. {
  7930. Grp_DayAndCost dac = dac3[i];
  7931. if (dac == null) continue;
  7932. builder.MoveToCell(2, i, 0, 0);
  7933. builder.Write("第" + dac.Days.ToString() + "天:");
  7934. builder.MoveToCell(2, i, 1, 0);
  7935. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7936. builder.MoveToCell(2, i, 2, 0);
  7937. builder.Write("费用标准:");
  7938. string curr = "";
  7939. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7940. if (currData != null)
  7941. {
  7942. curr = currData.Name;
  7943. }
  7944. builder.MoveToCell(2, i, 3, 0);
  7945. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7946. builder.MoveToCell(2, i, 4, 0);
  7947. builder.Write("费用小计:");
  7948. builder.MoveToCell(2, i, 5, 0);
  7949. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7950. }
  7951. //删除多余行
  7952. while (table3.Rows.Count > table3Row)
  7953. {
  7954. table3.Rows.RemoveAt(table3Row);
  7955. }
  7956. #endregion
  7957. }
  7958. else dic.Add("SubGZF", "0.00");
  7959. //删除多余行
  7960. while (table3.Rows.Count > table3Row)
  7961. {
  7962. table3.Rows.RemoveAt(table3Row);
  7963. }
  7964. //培训费
  7965. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  7966. if (_EnterExitCosts.ChoiceSix == 1)
  7967. {
  7968. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  7969. dic.Add("SubPX", pxStr);
  7970. table4Row = dac4.Count;
  7971. #region 填充word表格内容
  7972. for (int i = 0; i < dac4.Count; i++)
  7973. {
  7974. Grp_DayAndCost dac = dac4[i];
  7975. if (dac == null) continue;
  7976. builder.MoveToCell(3, i, 0, 0);
  7977. builder.Write("第" + dac.Days.ToString() + "天:");
  7978. builder.MoveToCell(3, i, 1, 0);
  7979. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  7980. builder.MoveToCell(3, i, 2, 0);
  7981. builder.Write("费用标准:");
  7982. string curr = "";
  7983. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  7984. if (currData != null)
  7985. {
  7986. curr = currData.Name;
  7987. }
  7988. builder.MoveToCell(3, i, 3, 0);
  7989. builder.Write(dac.Cost.ToString("#0.00") + curr);
  7990. builder.MoveToCell(3, i, 4, 0);
  7991. builder.Write("费用小计:");
  7992. builder.MoveToCell(3, i, 5, 0);
  7993. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  7994. }
  7995. #endregion
  7996. }
  7997. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  7998. //删除多余行
  7999. while (table4.Rows.Count > table4Row)
  8000. {
  8001. table4.Rows.RemoveAt(table4Row);
  8002. }
  8003. //其他费用
  8004. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  8005. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  8006. {
  8007. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  8008. dic.Add("titleQi", qtStr);
  8009. table5Row = dac5.Count;
  8010. #region 填充word表格内容
  8011. for (int i = 0; i < dac5.Count; i++)
  8012. {
  8013. var dac = dac5[i];
  8014. if (dac == null) continue;
  8015. builder.MoveToCell(4, i, 0, 0);
  8016. builder.Write("第" + dac.Index.ToString() + "项:");
  8017. builder.MoveToCell(4, i, 1, 0);
  8018. builder.Write(dac.itemName);
  8019. builder.MoveToCell(4, i, 2, 0);
  8020. builder.Write("费用标准:");
  8021. builder.MoveToCell(4, i, 3, 0);
  8022. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  8023. builder.MoveToCell(4, i, 4, 0);
  8024. builder.Write("费用小计:");
  8025. builder.MoveToCell(4, i, 5, 0);
  8026. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  8027. builder.MoveToCell(4, i, 6, 0);
  8028. builder.Write("备注:");
  8029. builder.MoveToCell(4, i, 7, 0);
  8030. builder.Write(dac.Remark);
  8031. }
  8032. #endregion
  8033. }
  8034. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  8035. //删除多余行
  8036. while (table5.Rows.Count > table5Row)
  8037. {
  8038. table5.Rows.RemoveAt(table5Row);
  8039. }
  8040. //加上其他费用
  8041. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  8042. decimal subJJC = 0.00M,
  8043. subGWC = 0.00M,
  8044. subTDC = 0.00M;
  8045. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  8046. string totalLabel = string.Format("全部费用总计:");
  8047. //经济舱
  8048. if (_EnterExitCosts.SumJJC == 1)
  8049. {
  8050. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  8051. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  8052. }
  8053. //公务舱
  8054. if (_EnterExitCosts.SumGWC == 1)
  8055. {
  8056. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  8057. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  8058. }
  8059. //头等舱
  8060. if (_EnterExitCosts.SumTDC == 1)
  8061. {
  8062. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  8063. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  8064. }
  8065. //TotalLabel
  8066. dic.Add("TotalLabel", totalLabel);
  8067. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  8068. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  8069. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  8070. #region 填充word模板书签内容
  8071. foreach (var key in dic.Keys)
  8072. {
  8073. Bookmark bookmark = doc.Range.Bookmarks[key];
  8074. if (bookmark != null)
  8075. {
  8076. builder.MoveToBookmark(key);
  8077. builder.Write(dic[key]);
  8078. }
  8079. }
  8080. #endregion
  8081. #region 设置页眉
  8082. string userLabel = string.Empty;
  8083. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  8084. if (currUserInfo != null)
  8085. {
  8086. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  8087. if (userInfo != null)
  8088. {
  8089. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  8090. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  8091. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  8092. }
  8093. }
  8094. //设置页脚
  8095. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  8096. #endregion
  8097. var guid = CommonFun.GUID.Substring(0, 8);
  8098. //文件名
  8099. string strFileName = CommonFun.ValidFileName($"{_DelegationInfo.TeamName}出入境费用{guid}.docx");
  8100. AsposeHelper.removewatermark_v2180();
  8101. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8102. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8103. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8104. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8105. }
  8106. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  8107. {
  8108. //获取模板
  8109. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  8110. //载入模板
  8111. var doc = new Document(tempPath);
  8112. var builder = new DocumentBuilder(doc);
  8113. var dic = new Dictionary<string, string>();
  8114. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8115. {
  8116. var list = new List<string>();
  8117. try
  8118. {
  8119. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8120. foreach (var item in spilitArr)
  8121. {
  8122. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8123. var depCode = spDotandEmpty[2].Substring(0, 3);
  8124. var arrCode = spDotandEmpty[2].Substring(3, 3);
  8125. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  8126. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  8127. list.Add(depName);
  8128. list.Add(arrName);
  8129. }
  8130. list = list.Distinct().ToList();
  8131. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8132. }
  8133. catch (Exception)
  8134. {
  8135. dic.Add("ReturnCode", "行程录入不正确!");
  8136. }
  8137. }
  8138. else
  8139. {
  8140. dic.Add("ReturnCode", "未录入行程!");
  8141. }
  8142. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8143. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8144. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8145. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8146. {
  8147. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8148. dic.Add("Day", sp.Days.ToString());
  8149. }
  8150. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8151. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8152. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8153. //dic.Add("Names", Names);
  8154. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8155. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8156. decimal dac1totalPrice = 0.00M;
  8157. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  8158. foreach (var dac in dac1)
  8159. {
  8160. if (dac.SubTotal == 0.00M)
  8161. {
  8162. continue;
  8163. }
  8164. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8165. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8166. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8167. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8168. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8169. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8170. builder.Write(currency);//币种
  8171. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8172. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8173. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8174. builder.Write("");//人数
  8175. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8176. builder.Write("");//天数
  8177. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8178. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8179. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8180. decimal rate = 0.00M;
  8181. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8182. builder.Write(rate.ToString("#0.0000"));//汇率
  8183. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8184. decimal rbmPrice = dac.SubTotal;
  8185. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8186. accommodationStartIndex++;
  8187. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8188. }
  8189. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8190. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  8191. {
  8192. table1.Rows.RemoveAt(i - 1);
  8193. foodandotherStartIndex--;
  8194. }
  8195. if (dac2.Count == dac3.Count)//国家 币种 金额
  8196. {
  8197. for (int i = 0; i < dac2.Count; i++)
  8198. {
  8199. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8200. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8201. }
  8202. }
  8203. decimal dac2totalPrice = 0.00M;
  8204. foreach (var dac in dac2)
  8205. {
  8206. if (dac.SubTotal == 0)
  8207. {
  8208. continue;
  8209. }
  8210. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8211. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  8212. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8213. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  8214. builder.Write(currency);//币种
  8215. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8216. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8217. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8218. builder.Write("");//人数
  8219. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8220. builder.Write("");//天数
  8221. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8222. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8223. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8224. decimal rate = 0.00M;
  8225. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  8226. builder.Write(rate.ToString("#0.0000"));//汇率
  8227. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8228. decimal rbmPrice = dac.SubTotal;
  8229. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8230. foodandotherStartIndex++;
  8231. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  8232. }
  8233. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8234. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  8235. {
  8236. table1.Rows.RemoveAt(i - 1);
  8237. }
  8238. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8239. string otherFeeStr = "";
  8240. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  8241. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  8242. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  8243. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8244. foreach (var otherInfo in dac5)
  8245. {
  8246. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8247. }
  8248. #endregion
  8249. if (otherFeeStr.Length > 0)
  8250. {
  8251. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8252. otherFeeStr = $"({otherFeeStr})";
  8253. dic.Add("OtherFeeStr", otherFeeStr);
  8254. }
  8255. //总计
  8256. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  8257. //国际旅费
  8258. string outsideAir = string.Empty;
  8259. string allPriceAir = string.Empty;
  8260. if (_EnterExitCosts.SumJJC == 1)
  8261. {
  8262. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8263. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  8264. }
  8265. if (_EnterExitCosts.SumGWC == 1)
  8266. {
  8267. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  8268. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8269. }
  8270. if (_EnterExitCosts.SumTDC == 1)
  8271. {
  8272. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  8273. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  8274. }
  8275. dic.Add("InTravelPrice", $"({outsideAir})");
  8276. dic.Add("FinalSumPrice", $"({allPriceAir})");
  8277. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  8278. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  8279. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  8280. foreach (var key in dic.Keys)
  8281. {
  8282. builder.MoveToBookmark(key);
  8283. builder.Write(dic[key]);
  8284. }
  8285. //模板文件名
  8286. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8287. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8288. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8289. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8290. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8291. }
  8292. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  8293. {
  8294. //获取模板
  8295. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  8296. //载入模板
  8297. var designer = new WorkbookDesigner
  8298. {
  8299. Workbook = new Workbook(tempPath)
  8300. };
  8301. var dic = new Dictionary<string, string>();
  8302. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8303. {
  8304. var list = new List<string>();
  8305. try
  8306. {
  8307. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8308. foreach (var item in spilitArr)
  8309. {
  8310. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8311. var depCode = spDotandEmpty[2].Substring(0, 3);
  8312. var arrCode = spDotandEmpty[2].Substring(3, 3);
  8313. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  8314. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  8315. list.Add(depName);
  8316. list.Add(arrName);
  8317. }
  8318. list = list.Distinct().ToList();
  8319. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8320. }
  8321. catch (Exception)
  8322. {
  8323. dic.Add("ReturnCode", "行程录入不正确!");
  8324. }
  8325. }
  8326. else
  8327. {
  8328. dic.Add("ReturnCode", "未录入行程!");
  8329. }
  8330. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8331. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8332. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8333. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8334. {
  8335. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8336. dic.Add("Day", sp.Days.ToString());
  8337. }
  8338. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8339. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8340. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  8341. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  8342. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  8343. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  8344. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  8345. designer.SetDataSource("Name", Names);
  8346. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  8347. designer.SetDataSource("Day", dic["Day"] + "天");
  8348. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  8349. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  8350. int startIndex = 10;
  8351. const int startIndexcopy = 10;
  8352. if (dac2.Count == dac3.Count)//国家 币种 金额
  8353. {
  8354. for (int i = 0; i < dac2.Count; i++)
  8355. {
  8356. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8357. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8358. }
  8359. }
  8360. var dtdac1 = new DataTable();
  8361. var place = new List<string>();
  8362. dtdac1.Columns.AddRange(new DataColumn[] {
  8363. new(){ ColumnName = "city"},
  8364. new(){ ColumnName = "curr"},
  8365. new(){ ColumnName = "criterion"},
  8366. new(){ ColumnName = "number",DataType = typeof(int)},
  8367. new(){ ColumnName = "day",DataType = typeof(int)},
  8368. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8369. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8370. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  8371. });
  8372. var dtdac2 = new DataTable();
  8373. dtdac2.Columns.AddRange(new DataColumn[] {
  8374. new(){ ColumnName = "city"},
  8375. new(){ ColumnName = "curr"},
  8376. new(){ ColumnName = "criterion"},
  8377. new(){ ColumnName = "number",DataType = typeof(int)},
  8378. new(){ ColumnName = "day",DataType = typeof(int)},
  8379. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  8380. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  8381. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  8382. });
  8383. dtdac1.TableName = "tb1";
  8384. dtdac2.TableName = "tb2";
  8385. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  8386. foreach (var item in dac1)
  8387. {
  8388. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8389. if (place.Contains(item.Place))
  8390. {
  8391. continue;
  8392. }
  8393. DataRow row = dtdac1.NewRow();
  8394. row["city"] = item.Place;
  8395. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8396. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8397. row["curr"] = currency;
  8398. row["rate"] = rate.ToString("#0.0000");
  8399. row["criterion"] = item.Cost.ToString("#0.00");
  8400. row["number"] = 1;
  8401. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8402. //row["costRMB"] = rbmPrice;
  8403. dtdac1.Rows.Add(row);
  8404. place.Add(item.Place);
  8405. }
  8406. place = new List<string>();
  8407. foreach (var item in dac2)
  8408. {
  8409. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  8410. if (place.Contains(item.Place))
  8411. {
  8412. continue;
  8413. }
  8414. DataRow row = dtdac2.NewRow();
  8415. row["city"] = item.Place;
  8416. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  8417. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8418. row["curr"] = currency;
  8419. row["rate"] = rate.ToString("#0.0000");
  8420. row["criterion"] = item.Cost.ToString("#0.00");
  8421. row["number"] = 1;
  8422. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  8423. //row["cost"] = item.SubTotal;
  8424. //row["costRMB"] = rbmPrice;
  8425. dtdac2.Rows.Add(row);
  8426. place.Add(item.Place);
  8427. //dac2totalPrice += rbmPrice;
  8428. }
  8429. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  8430. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  8431. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8432. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  8433. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  8434. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  8435. string cell4Str1 = string.Empty;
  8436. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  8437. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  8438. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  8439. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  8440. string cellStr = $" 5.其他费用(";
  8441. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8442. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8443. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8444. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8445. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8446. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8447. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  8448. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  8449. foreach (var otherInfo in dac5)
  8450. {
  8451. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  8452. }
  8453. #endregion
  8454. if (cellStr.Length > 8)
  8455. {
  8456. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  8457. }
  8458. cellStr += ")";
  8459. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  8460. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  8461. decimal pxFee = dac4.Sum(it => it.Cost);
  8462. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  8463. string celllastStr1 = "";
  8464. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  8465. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  8466. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  8467. celllastStr1 += $",国际旅费 元";
  8468. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  8469. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  8470. designer.SetDataSource("cell4Str", cell4Str);
  8471. designer.SetDataSource("cellStr", cellStr);
  8472. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  8473. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  8474. designer.SetDataSource("celllastStr", celllastStr);
  8475. Workbook wb = designer.Workbook;
  8476. var sheet = wb.Worksheets[0];
  8477. //绑定datatable数据集
  8478. designer.SetDataSource(dtdac1);
  8479. designer.SetDataSource(dtdac2);
  8480. designer.Process();
  8481. var rowStart = dtdac1.Rows.Count;
  8482. while (rowStart > 0)
  8483. {
  8484. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  8485. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8486. startIndex++;
  8487. rowStart--;
  8488. }
  8489. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  8490. startIndex += 1; //总计行
  8491. rowStart = dtdac2.Rows.Count;
  8492. while (rowStart > 0)
  8493. {
  8494. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  8495. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  8496. startIndex++;
  8497. rowStart--;
  8498. }
  8499. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  8500. wb.CalculateFormula(true);
  8501. //模板文件名
  8502. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  8503. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8504. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8505. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8506. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8507. }
  8508. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  8509. {
  8510. //获取模板
  8511. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  8512. //载入模板
  8513. var doc = new Document(tempPath);
  8514. var builder = new DocumentBuilder(doc);
  8515. var dic = new Dictionary<string, string>
  8516. {
  8517. { "GroupName", _DelegationInfo.TeamName },
  8518. { "ClientUnit", _DelegationInfo.ClientUnit }
  8519. };
  8520. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  8521. string missionLeaderJob = "";//负责人job
  8522. //int groupNumber = 0; //团人数
  8523. if (DeleClientList.Count > 0)
  8524. {
  8525. missionLeader = DeleClientList[0]?.Name ?? "";
  8526. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  8527. }
  8528. dic.Add("MissionLeader", missionLeader); //团负责人
  8529. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  8530. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  8531. #region MyRegion
  8532. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  8533. //{
  8534. // List<string> list = new List<string>();
  8535. // try
  8536. // {
  8537. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  8538. // foreach (var item in spilitArr)
  8539. // {
  8540. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  8541. // var depCode = spDotandEmpty[2].Substring(0, 3);
  8542. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  8543. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  8544. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  8545. // list.Add(depName);
  8546. // list.Add(arrName);
  8547. // }
  8548. // list = list.Distinct().ToList();
  8549. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  8550. // }
  8551. // catch (Exception)
  8552. // {
  8553. // dic.Add("ReturnCode", "行程录入不正确!");
  8554. // }
  8555. //}
  8556. //else
  8557. //{
  8558. // dic.Add("ReturnCode", "未录入行程!");
  8559. //}
  8560. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  8561. dic.Add("ReturnCode", string.Join("、", countrys));
  8562. #endregion
  8563. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  8564. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8565. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8566. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  8567. //{
  8568. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8569. // dic.Add("Day", sp.Days.ToString());
  8570. //}
  8571. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  8572. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  8573. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8574. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8575. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8576. //培训人员名单
  8577. int cultivateRowIndex = 7;
  8578. foreach (var item in DeleClientList)
  8579. {
  8580. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  8581. builder.Write(item.Name);
  8582. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  8583. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  8584. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  8585. string birthDay = "";
  8586. if (item.Birthday != null)
  8587. {
  8588. DateTime dt = Convert.ToDateTime(item.Birthday);
  8589. birthDay = $"{dt.Year}.{dt.Month}";
  8590. }
  8591. builder.Write(birthDay);
  8592. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  8593. builder.Write(item.Company);
  8594. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  8595. builder.Write(item.Job);
  8596. cultivateRowIndex++;
  8597. }
  8598. //删除多余行
  8599. //cultivateRowIndex -= 2;
  8600. int delRows = 10 + 7 - cultivateRowIndex;
  8601. if (delRows > 0)
  8602. {
  8603. for (int i = 0; i < delRows; i++)
  8604. {
  8605. table1.Rows.RemoveAt(cultivateRowIndex);
  8606. //cultivateRowIndex++;
  8607. }
  8608. }
  8609. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  8610. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  8611. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  8612. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  8613. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  8614. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  8615. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  8616. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  8617. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  8618. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  8619. //其他费用
  8620. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  8621. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  8622. //其他费用合计
  8623. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  8624. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  8625. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  8626. //公务舱合计
  8627. //国际旅费
  8628. //string outsideJJ = "";
  8629. //string allPriceJJ = "";
  8630. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  8631. {
  8632. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  8633. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  8634. }
  8635. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  8636. {
  8637. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  8638. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  8639. }
  8640. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  8641. {
  8642. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  8643. dic.Add("AirFeeTotal", airFeeTotalStr);
  8644. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  8645. dic.Add("FeeTotal", feeTotalStr);
  8646. }
  8647. foreach (var key in dic.Keys)
  8648. {
  8649. builder.MoveToBookmark(key);
  8650. builder.Write(dic[key]);
  8651. }
  8652. //模板文件名
  8653. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  8654. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8655. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8656. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8657. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8658. }
  8659. }
  8660. else if (dto.ExportType == 2) //表格
  8661. {
  8662. //利用键值对存放数据
  8663. Dictionary<string, string> dic = new Dictionary<string, string>();
  8664. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  8665. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  8666. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  8667. dic.Add("Day", sp.Days.ToString());
  8668. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  8669. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  8670. {
  8671. //获取模板
  8672. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  8673. //载入模板
  8674. var doc = new Document(tempPath);
  8675. var builder = new DocumentBuilder(doc);
  8676. dic.Add("TeamName", _DelegationInfo.TeamName);
  8677. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  8678. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  8679. string missionLeaderName = "",
  8680. missionLeaderJob = "";
  8681. if (DeleClientList.Count > 0)
  8682. {
  8683. missionLeaderName = DeleClientList[0].Name;
  8684. missionLeaderJob = DeleClientList[0].Job;
  8685. }
  8686. dic.Add("MissionLeaderName", missionLeaderName);
  8687. dic.Add("MissionLeaderJob", missionLeaderJob);
  8688. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  8689. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  8690. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8691. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8692. int rowCount = 10;//总人数行
  8693. int startRowIndex = 7; //起始行
  8694. for (int i = 0; i < DeleClientList.Count; i++)
  8695. {
  8696. builder.MoveToCell(0, startRowIndex, 0, 0);
  8697. builder.Write(DeleClientList[i].Name); //出国人员姓名
  8698. builder.MoveToCell(0, startRowIndex, 1, 0);
  8699. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8700. builder.Write(sex);//性别
  8701. builder.MoveToCell(0, startRowIndex, 2, 0);
  8702. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  8703. builder.MoveToCell(0, startRowIndex, 3, 0);
  8704. builder.Write(DeleClientList[i].Company);//工作单位
  8705. builder.MoveToCell(0, startRowIndex, 4, 0);
  8706. builder.Write(DeleClientList[i].Job);//职务及级别
  8707. builder.MoveToCell(0, startRowIndex, 5, 0);
  8708. builder.Write("");//人员属性
  8709. builder.MoveToCell(0, startRowIndex, 6, 0);
  8710. builder.Write("");//上次出国时间
  8711. startRowIndex++;
  8712. }
  8713. int nullRow = rowCount - DeleClientList.Count;//空行
  8714. for (int i = 0; i < nullRow; i++)
  8715. {
  8716. table1.Rows.Remove(table1.Rows[startRowIndex]);
  8717. }
  8718. foreach (var key in dic.Keys)
  8719. {
  8720. builder.MoveToBookmark(key);
  8721. builder.Write(dic[key]);
  8722. }
  8723. //模板文件名
  8724. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  8725. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8726. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8727. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  8728. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  8729. }
  8730. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  8731. {
  8732. //获取模板
  8733. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  8734. //载入模板
  8735. var doc = new Document(tempPath);
  8736. var builder = new DocumentBuilder(doc);
  8737. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  8738. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  8739. dic.Add("Names", Names);
  8740. int accommodationRows = 12;
  8741. //int foodandotherRows = 12;
  8742. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8743. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  8744. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8745. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  8746. int accommodationStartIndex = 6;
  8747. decimal dac1totalPrice = 0.00M;
  8748. foreach (var dac in dac1)
  8749. {
  8750. if (dac.SubTotal == 0)
  8751. {
  8752. continue;
  8753. }
  8754. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  8755. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  8756. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8757. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8758. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  8759. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8760. builder.Write(currency);//币种
  8761. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  8762. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8763. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  8764. builder.Write("");//人数
  8765. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  8766. builder.Write("");//天数
  8767. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  8768. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8769. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  8770. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8771. builder.Write(rate.ToString("#0.0000"));//汇率
  8772. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8773. decimal rbmPrice = rate * dac.SubTotal;
  8774. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8775. accommodationStartIndex++;
  8776. dac1totalPrice += rbmPrice;
  8777. }
  8778. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  8779. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  8780. builder.Write("小计");
  8781. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  8782. builder.Write(dac1totalPrice.ToString("#0.00"));
  8783. accommodationStartIndex++;
  8784. int nullRow = accommodationRows - dac1.Count;
  8785. //删除空行
  8786. //if (nullRow > 0)
  8787. //{
  8788. // int rowIndex = accommodationStartIndex;
  8789. // for (int i = 0; i < nullRow; i++)
  8790. // {
  8791. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  8792. // row.Remove();
  8793. // rowIndex++;
  8794. // }
  8795. //}
  8796. if (dac2.Count == dac3.Count)//国家 币种 金额
  8797. {
  8798. for (int i = 0; i < dac2.Count; i++)
  8799. {
  8800. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  8801. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  8802. }
  8803. }
  8804. int foodandotherStartIndex = 19;//
  8805. decimal dac2totalPrice = 0.00M;
  8806. foreach (var dac in dac2)
  8807. {
  8808. if (dac.SubTotal == 0)
  8809. {
  8810. continue;
  8811. }
  8812. //foodandotherStartIndex = 12;
  8813. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  8814. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  8815. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  8816. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  8817. builder.Write(currency);//币种
  8818. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  8819. builder.Write(dac.Cost.ToString("#0.00"));//标准
  8820. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  8821. builder.Write("");//人数
  8822. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  8823. builder.Write("");//天数
  8824. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  8825. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  8826. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  8827. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  8828. builder.Write(rate.ToString("#0.0000"));//汇率
  8829. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  8830. decimal rbmPrice = rate * dac.SubTotal;
  8831. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  8832. foodandotherStartIndex++;
  8833. dac2totalPrice += rbmPrice;
  8834. }
  8835. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  8836. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  8837. //删除空行
  8838. //if (dac2.Count < foodandotherRows)
  8839. //{
  8840. // while (table2.Rows.Count > dac2.Count)
  8841. // {
  8842. // table2.Rows.RemoveAt(dac2.Count);
  8843. // }
  8844. //}
  8845. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  8846. string otherFeeStr = "";
  8847. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  8848. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  8849. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  8850. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  8851. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  8852. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  8853. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  8854. foreach (var otherInfo in dac5)
  8855. {
  8856. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  8857. }
  8858. #endregion
  8859. if (otherFeeStr.Length > 0)
  8860. {
  8861. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  8862. otherFeeStr = $"({otherFeeStr})";
  8863. dic.Add("OtherFeeStr", otherFeeStr);
  8864. }
  8865. foreach (var key in dic.Keys)
  8866. {
  8867. builder.MoveToBookmark(key);
  8868. builder.Write(dic[key]);
  8869. }
  8870. //模板文件名
  8871. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  8872. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8873. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8874. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8875. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8876. }
  8877. }
  8878. else if (dto.ExportType == 3)
  8879. {
  8880. if (dto.SubTypeId == 1) //团组成员名单
  8881. {
  8882. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  8883. //获取模板
  8884. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  8885. //载入模板
  8886. var doc = new Document(tempPath);
  8887. var builder = new DocumentBuilder(doc);
  8888. //获取word里所有表格
  8889. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  8890. //获取所填表格的序数
  8891. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  8892. var rowStart = tableOne.Rows[0]; //获取第1行
  8893. //循环赋值
  8894. for (int i = 0; i < DeleClientList.Count; i++)
  8895. {
  8896. builder.MoveToCell(0, i + 1, 0, 0);
  8897. builder.Write(DeleClientList[i].Name);
  8898. builder.MoveToCell(0, i + 1, 1, 0);
  8899. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  8900. builder.Write(sex);
  8901. builder.MoveToCell(0, i + 1, 2, 0);
  8902. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  8903. builder.MoveToCell(0, i + 1, 3, 0);
  8904. builder.Write(DeleClientList[i].Company);
  8905. builder.MoveToCell(0, i + 1, 4, 0);
  8906. builder.Write(DeleClientList[i].Job);
  8907. }
  8908. //删除多余行
  8909. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  8910. {
  8911. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  8912. }
  8913. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  8914. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  8915. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  8916. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  8917. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  8918. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  8919. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  8920. }
  8921. }
  8922. return Ok(JsonView(400, "操作失败!", ""));
  8923. }
  8924. catch (Exception ex)
  8925. {
  8926. return Ok(JsonView(400, ex.Message, ""));
  8927. }
  8928. }
  8929. /// <summary>
  8930. /// 获取三公费用标准city
  8931. /// </summary>
  8932. /// <param name="placeData"></param>
  8933. /// <param name="nationalTravelFeeId"></param>
  8934. /// <returns></returns>
  8935. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  8936. {
  8937. string _city = string.Empty;
  8938. if (placeData.Count < 1) return _city;
  8939. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  8940. if (data == null) return _city;
  8941. string country = data.Country;
  8942. string city = data.City;
  8943. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  8944. else _city = city;
  8945. return _city;
  8946. }
  8947. ///// <summary>
  8948. ///// 团组模块 - 出入境费用 - 明细表导出
  8949. ///// </summary>
  8950. ///// <returns></returns>
  8951. //[HttpPost]
  8952. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8953. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  8954. //{
  8955. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  8956. // if (data.Code != 0)
  8957. // {
  8958. // return Ok(JsonView(false, data.Msg));
  8959. // }
  8960. // return Ok(JsonView(true, data.Msg, data.Data));
  8961. //}
  8962. /// <summary>
  8963. /// 团组模块 - 出入境费用 - 一键清空
  8964. /// </summary>
  8965. /// <returns></returns>
  8966. [HttpPost]
  8967. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8969. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  8970. {
  8971. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  8972. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  8973. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  8974. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  8975. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  8976. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  8977. .SetColumns(x => new Grp_DayOtherPrice
  8978. {
  8979. IsDel = 1,
  8980. DeleteUserId = dto.UserId,
  8981. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8982. })
  8983. .ExecuteCommandAsync();
  8984. if (_view.Code == 0)
  8985. {
  8986. return Ok(JsonView(true, "操作成功"));
  8987. }
  8988. return Ok(JsonView(false, "操作失败"));
  8989. }
  8990. /// <summary>
  8991. /// 团组模块 - 出入境费用 - 子项删除
  8992. /// </summary>
  8993. /// <returns></returns>
  8994. [HttpPost]
  8995. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  8996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8997. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  8998. {
  8999. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  9000. if (data.Code != 0)
  9001. {
  9002. return Ok(JsonView(false, data.Msg));
  9003. }
  9004. return Ok(JsonView(true, "操作成功!", data.Data));
  9005. }
  9006. /// <summary>
  9007. /// 删除三公其他费用
  9008. /// </summary>
  9009. /// <param name="dto"></param>
  9010. /// <returns></returns>
  9011. [HttpPost]
  9012. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  9013. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  9014. {
  9015. var jw = JsonView(false, "删除失败!");
  9016. var data = new Grp_DayOtherPrice()
  9017. {
  9018. Id = dto.Id,
  9019. IsDel = 1,
  9020. DeleteUserId = dto.DeleteUserId,
  9021. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  9022. };
  9023. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  9024. if (del > 0)
  9025. {
  9026. jw.Code = 200;
  9027. jw.Msg = "删除成功!";
  9028. }
  9029. return Ok(jw);
  9030. }
  9031. /// <summary>
  9032. /// 团组模块 - 出入境国家费用标准 List
  9033. /// </summary>
  9034. /// <returns></returns>
  9035. [HttpPost]
  9036. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9037. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  9038. {
  9039. int provinceId = dto.ProvinceId;
  9040. if (provinceId < 1) provinceId = 122; //默认四川省数据
  9041. var nftData = await _sqlSugar
  9042. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  9043. JoinType.Left, ntf.Currency == sd1.Id,
  9044. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  9045. JoinType.Left, ntf.ProvinceId == c.Id
  9046. ))
  9047. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  9048. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  9049. {
  9050. Id = ntf.Id,
  9051. ProvinceId = ntf.ProvinceId,
  9052. ProvinceName = c.Name_CN,
  9053. Continent = ntf.Continent,
  9054. Country = ntf.Country,
  9055. City = ntf.City,
  9056. Currency = ntf.Currency,
  9057. CurrencyCode = sd1.Name,
  9058. CurrencyName = sd1.Remark,
  9059. RoomCost = ntf.RoomCost,
  9060. FoodCost = ntf.FoodCost,
  9061. PublicCost = ntf.PublicCost,
  9062. LastUpdateUserId = ntf.LastUpdateUserId,
  9063. LastUpdateUserName = u.CnName,
  9064. LastUpdateTime = ntf.LastUpdateTime
  9065. })
  9066. .ToListAsync();
  9067. return Ok(JsonView(true, "查询成功!", nftData));
  9068. }
  9069. /// <summary>
  9070. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  9071. /// </summary>
  9072. /// <returns></returns>
  9073. [HttpPost]
  9074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9075. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  9076. {
  9077. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  9078. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  9079. List<string> countryData = new List<string>();
  9080. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  9081. countryData = countryData.Distinct().ToList();
  9082. List<dynamic> dataSource = new List<dynamic>();
  9083. foreach (var item in countryData)
  9084. {
  9085. var cityData1 = new List<string>();
  9086. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  9087. var countryData2 = new
  9088. {
  9089. CountryName = item,
  9090. CityData = cityData1
  9091. };
  9092. if (!dataSource.Contains(countryData2))
  9093. {
  9094. dataSource.Add(countryData2);
  9095. }
  9096. }
  9097. return Ok(JsonView(true, "查询成功!", dataSource));
  9098. }
  9099. /// <summary>
  9100. /// 团组模块 - 出入境国家费用标准 Page List
  9101. /// </summary>
  9102. /// <returns></returns>
  9103. [HttpPost]
  9104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9105. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  9106. {
  9107. int portId = dto.PortType,
  9108. pageIndex = dto.PageIndex,
  9109. pageSize = dto.PageSize;
  9110. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  9111. if (pageIndex == 0) pageIndex = 1;
  9112. if (pageSize == 0) pageSize = 10;
  9113. RefAsync<int> total = 0;
  9114. var nationalTravelFeeData = await _sqlSugar
  9115. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  9116. JoinType.Left, ntf.Currency == sd1.Id,
  9117. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  9118. JoinType.Left, ntf.ProvinceId == sd2.Id
  9119. ))
  9120. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  9121. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  9122. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  9123. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  9124. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  9125. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  9126. {
  9127. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  9128. Id = ntf.Id,
  9129. ProvinceId = ntf.ProvinceId,
  9130. ProvinceName = sd2.Name_CN,
  9131. Continent = ntf.Continent,
  9132. Country = ntf.Country,
  9133. City = ntf.City,
  9134. Currency = ntf.Currency,
  9135. CurrencyCode = sd1.Name,
  9136. CurrencyName = sd1.Remark,
  9137. RoomCost = ntf.RoomCost,
  9138. FoodCost = ntf.FoodCost,
  9139. PublicCost = ntf.PublicCost,
  9140. LastUpdateUserId = ntf.LastUpdateUserId,
  9141. LastUpdateUserName = u.CnName,
  9142. LastUpdateTime = ntf.LastUpdateTime,
  9143. Remark = ntf.Remark
  9144. })
  9145. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  9146. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  9147. }
  9148. /// <summary>
  9149. /// 团组模块 - 出入境国家费用标准 根据城市查询
  9150. /// </summary>
  9151. /// <returns></returns>
  9152. [HttpPost]
  9153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9154. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  9155. {
  9156. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  9157. int portId = dto.PortType;
  9158. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  9159. string whereSql = string.Empty;
  9160. if (!string.IsNullOrEmpty(dto.Country))
  9161. {
  9162. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  9163. }
  9164. if (!string.IsNullOrEmpty(dto.City))
  9165. {
  9166. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  9167. }
  9168. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  9169. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  9170. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  9171. From Grp_NationalTravelFee gntf
  9172. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  9173. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  9174. Where gntf.Isdel = 0 {0} ", whereSql);
  9175. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  9176. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  9177. }
  9178. /// <summary>
  9179. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  9180. /// </summary>
  9181. /// <returns></returns>
  9182. [HttpPost]
  9183. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9184. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  9185. {
  9186. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  9187. }
  9188. /// <summary>
  9189. /// 团组模块 - 出入境国家费用标准 - Del
  9190. /// </summary>
  9191. /// <returns></returns>
  9192. [HttpPost]
  9193. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9194. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  9195. {
  9196. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  9197. {
  9198. Id = dto.Id,
  9199. DeleteUserId = dto.DeleteUserId,
  9200. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  9201. IsDel = 1
  9202. };
  9203. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  9204. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  9205. .WhereColumns(it => new { it.Id })
  9206. .ExecuteCommandAsync();
  9207. if (delStatus <= 0)
  9208. {
  9209. return Ok(JsonView(false, "删除失败!"));
  9210. }
  9211. return Ok(JsonView(true, "操作成功!"));
  9212. }
  9213. /// <summary>
  9214. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  9215. /// 注:Get 请求Headers 加 Token
  9216. /// </summary>
  9217. /// <param name="groupId"></param>
  9218. /// <returns></returns>
  9219. [HttpGet("{groupId}")]
  9220. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9221. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  9222. {
  9223. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  9224. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  9225. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  9226. data.ForEach(x =>
  9227. {
  9228. x.CreateUserId = _currUserInfo.UserId;
  9229. });
  9230. if (data.Any())
  9231. {
  9232. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  9233. if (add > 0)
  9234. {
  9235. return Ok(JsonView(true, "操作成功!"));
  9236. }
  9237. }
  9238. return Ok(JsonView(false, "未操作!"));
  9239. }
  9240. #endregion
  9241. #region 团组经理模块 出入境费用-草稿
  9242. /// <summary>
  9243. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  9244. /// </summary>
  9245. /// <returns></returns>
  9246. [HttpGet]
  9247. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9248. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  9249. {
  9250. var provData = await _groupRepository.ProvinceBasicSource();
  9251. return Ok(JsonView(true, "查询成功!", provData));
  9252. }
  9253. /// <summary>
  9254. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  9255. /// </summary>
  9256. /// <returns></returns>
  9257. [HttpGet("{provinceId}")]
  9258. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9259. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  9260. {
  9261. //验证城市归属并给默认值
  9262. if (provinceId < 1) provinceId = 122;
  9263. /*
  9264. * 122 四川
  9265. * 108 贵州
  9266. * 103 重庆
  9267. * 132 云南
  9268. */
  9269. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  9270. return Ok(JsonView(true, "查询成功!", new
  9271. {
  9272. WordTypeData = wordTypeData,
  9273. ExcelTypeData = excelTypeData,
  9274. }));
  9275. }
  9276. /// <summary>
  9277. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  9278. /// </summary>
  9279. /// <returns></returns>
  9280. [HttpPost]
  9281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9282. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  9283. {
  9284. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  9285. .Where(x => x.IsDel == 0)
  9286. .OrderByDescending(x => x.CreateTime)
  9287. .Select(x => new { x.Id, x.DraftName })
  9288. .ToListAsync();
  9289. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  9290. //SetDataInfoView
  9291. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  9292. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  9293. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  9294. int provinceId = dto.ProvinceId;
  9295. if (provinceId < 1) provinceId = 122;
  9296. /*
  9297. * 122 四川
  9298. * 108 贵州
  9299. * 103 重庆
  9300. * 132 云南
  9301. */
  9302. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  9303. //默认币种显示
  9304. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  9305. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  9306. return Ok(JsonView(true, "查询成功!", new
  9307. {
  9308. DraftNameDatas = draftNameDatas,
  9309. CurrencyData = _CurrencyData,
  9310. WordTypeData = wordTypeData,
  9311. ExcelTypeData = excelTypeData,
  9312. CurrencyInit = _currencyInfos,
  9313. ViewPermissionData = viewPermissionData
  9314. }));
  9315. }
  9316. /// <summary>
  9317. /// 团组模块 - 出入境费用-草稿
  9318. /// 实时汇率 tips
  9319. /// 机票费用 tips
  9320. /// </summary>
  9321. /// <returns></returns>
  9322. [HttpPost]
  9323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9324. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  9325. {
  9326. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  9327. return Ok(JsonView(true, "查询成功!", new
  9328. {
  9329. //GroupNameData = groupNameData.Data,
  9330. //visaData = visaData.Data,
  9331. //airData = airData.Data,
  9332. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  9333. }));
  9334. }
  9335. /// <summary>
  9336. /// 团组模块 - 出入境费用-草稿
  9337. /// 签证费用 tips
  9338. /// </summary>
  9339. /// <returns></returns>
  9340. [HttpPost]
  9341. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9342. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  9343. {
  9344. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  9345. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  9346. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  9347. .Select(x => x.NationalTravelFeeId)
  9348. .Distinct()
  9349. .ToListAsync();
  9350. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9351. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  9352. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  9353. .Select(x => x.Country)
  9354. .Distinct()
  9355. .ToArrayAsync();
  9356. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  9357. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  9358. return Ok(JsonView(true, "查询成功!", new
  9359. {
  9360. totalAmt,
  9361. remark
  9362. }));
  9363. }
  9364. /// <summary>
  9365. /// 团组模块 - 出入境费用-草稿 - Info
  9366. /// </summary>
  9367. /// <returns></returns>
  9368. [HttpPost]
  9369. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  9370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9371. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  9372. {
  9373. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  9374. }
  9375. /// <summary>
  9376. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  9377. /// </summary>
  9378. /// <returns></returns>
  9379. [HttpPost]
  9380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9381. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  9382. {
  9383. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9384. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  9385. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9386. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  9387. foreach (var userId in dto.UserIds)
  9388. {
  9389. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  9390. }
  9391. if (permissions.Any())
  9392. {
  9393. _sqlSugar.BeginTran();
  9394. try
  9395. {
  9396. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  9397. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9398. if (result < 1)
  9399. {
  9400. _sqlSugar.RollbackTran();
  9401. return Ok(JsonView(false));
  9402. }
  9403. }
  9404. catch (Exception ex)
  9405. {
  9406. _sqlSugar.RollbackTran();
  9407. return Ok(JsonView(false, ex.Message));
  9408. }
  9409. _sqlSugar.CommitTran();
  9410. return Ok(JsonView(true));
  9411. }
  9412. return Ok(JsonView(false));
  9413. }
  9414. /// <summary>
  9415. /// 团组模块 - 出入境费用-草稿 - Add And Update
  9416. /// </summary>
  9417. /// <returns></returns>
  9418. [HttpPost]
  9419. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  9420. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9421. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  9422. {
  9423. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  9424. if (data.Code != 0)
  9425. {
  9426. return Ok(JsonView(false, data.Msg));
  9427. }
  9428. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9429. //汇率信息记录
  9430. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  9431. return Ok(JsonView(true, data.Msg, data.Data));
  9432. }
  9433. /// <summary>
  9434. /// 团组模块 - 出入境费用-草稿 - File downlaod
  9435. /// </summary>
  9436. /// <param name="dto"></param>
  9437. /// <returns></returns>
  9438. [HttpPost]
  9439. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  9440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9441. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  9442. {
  9443. try
  9444. {
  9445. var id = dto.Id;
  9446. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  9447. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  9448. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  9449. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  9450. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  9451. 3 团组成员名单 1 团组成员名单", ""));
  9452. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  9453. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  9454. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  9455. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  9456. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  9457. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  9458. //数据源
  9459. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  9460. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  9461. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  9462. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  9463. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  9464. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  9465. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  9466. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  9467. .Select((x, a, b) => new
  9468. {
  9469. x.Index,
  9470. itemName = a.Name,
  9471. CurrencyStr = b.Name,
  9472. x.Cost,
  9473. x.SubTotal,
  9474. x.Remark
  9475. })
  9476. .OrderBy((x) => x.Index)
  9477. .ToList(); //其他款项费用
  9478. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9479. var peiceItemCurrencys = new List<string>();
  9480. if (_DayAndCosts.Any())
  9481. {
  9482. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  9483. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  9484. }
  9485. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  9486. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  9487. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  9488. {
  9489. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  9490. }
  9491. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  9492. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  9493. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  9494. if (dto.ExportType == 1) //明细表
  9495. {
  9496. if (dto.SubTypeId == 1005) //1005(默认明细表)
  9497. {
  9498. //获取模板
  9499. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  9500. //载入模板
  9501. Document doc = new Document(tempPath);
  9502. DocumentBuilder builder = new DocumentBuilder(doc);
  9503. //利用键值对存放数据
  9504. Dictionary<string, string> dic = new Dictionary<string, string>();
  9505. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  9506. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  9507. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  9508. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  9509. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  9510. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  9511. //境内费用(其他费用)
  9512. if (_EnterExitCosts.ChoiceOne == 1)
  9513. {
  9514. string row1_1 = "";
  9515. if (_EnterExitCosts.Visa > 0)
  9516. {
  9517. //insidePayTotal += _EnterExitCosts.Visa;
  9518. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  9519. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  9520. //{
  9521. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  9522. //}
  9523. }
  9524. string row1_2 = "";
  9525. if (_EnterExitCosts.YiMiao > 0)
  9526. {
  9527. //insidePayTotal += _EnterExitCosts.YiMiao;
  9528. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  9529. }
  9530. if (_EnterExitCosts.HeSuan > 0)
  9531. {
  9532. //insidePayTotal += _EnterExitCosts.HeSuan;
  9533. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  9534. }
  9535. if (_EnterExitCosts.Service > 0)
  9536. {
  9537. //insidePayTotal += _EnterExitCosts.Service;
  9538. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  9539. }
  9540. string row1_3 = "";
  9541. if (_EnterExitCosts.Safe > 0)
  9542. {
  9543. //insidePayTotal += _EnterExitCosts.Safe;
  9544. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  9545. }
  9546. if (_EnterExitCosts.Ticket > 0)
  9547. {
  9548. //insidePayTotal += _EnterExitCosts.Ticket;
  9549. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  9550. }
  9551. string row1 = "";
  9552. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  9553. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  9554. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  9555. row1 += $"备注:{_EnterExitCosts.Remark}";
  9556. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  9557. dic.Add("Row1Str", row1);
  9558. }
  9559. string airTotalStr = string.Empty,
  9560. airPriceStr = string.Empty;
  9561. //经济舱
  9562. if (_EnterExitCosts.SumJJC == 1)
  9563. {
  9564. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  9565. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  9566. }
  9567. //公务舱
  9568. if (_EnterExitCosts.SumGWC == 1)
  9569. {
  9570. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  9571. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  9572. }
  9573. //头等舱
  9574. if (_EnterExitCosts.SumTDC == 1)
  9575. {
  9576. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  9577. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  9578. }
  9579. //汇率描述
  9580. string rateStr = "";
  9581. if (peiceItemCurrencyInfos.Any())
  9582. {
  9583. rateStr = "\r\n汇率描述:";
  9584. foreach (var item in peiceItemCurrencyInfos)
  9585. {
  9586. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  9587. }
  9588. }
  9589. string twoItemRemark = "备注:";
  9590. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  9591. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  9592. dic.Add("AirTotalStr", airTotalStr);
  9593. dic.Add("AirPriceStr", airPriceStr);
  9594. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9595. dic.Add("TwoItemRemark", twoItemRemark);
  9596. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9597. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9598. int table1Row = 0,
  9599. table2Row = 0,
  9600. table3Row = 0,
  9601. table4Row = 0,
  9602. table5Row = 0;
  9603. //住宿费
  9604. if (_EnterExitCosts.ChoiceThree == 1)
  9605. {
  9606. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  9607. table1Row = dac1.Count;
  9608. #region 填充word表格内容
  9609. for (int i = 0; i < dac1.Count; i++)
  9610. {
  9611. var dac = dac1[i];
  9612. if (dac == null) continue;
  9613. builder.MoveToCell(0, i, 0, 0);
  9614. builder.Write("第" + dac.Days.ToString() + "晚:");
  9615. builder.MoveToCell(0, i, 1, 0);
  9616. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  9617. //builder.Write(dac.Place == null ? "" : dac.Place);
  9618. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9619. builder.MoveToCell(0, i, 2, 0);
  9620. builder.Write("费用标准:");
  9621. string curr = "";
  9622. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9623. if (currData != null)
  9624. {
  9625. curr = currData.Name;
  9626. }
  9627. builder.MoveToCell(0, i, 3, 0);
  9628. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9629. builder.MoveToCell(0, i, 4, 0);
  9630. builder.Write("费用小计:");
  9631. builder.MoveToCell(0, i, 5, 0);
  9632. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9633. }
  9634. #endregion
  9635. }
  9636. else dic.Add("SubZS", "0.00");
  9637. //删除多余行
  9638. while (table1.Rows.Count > table1Row)
  9639. {
  9640. table1.Rows.RemoveAt(table1Row);
  9641. }
  9642. //伙食费
  9643. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  9644. if (_EnterExitCosts.ChoiceFour == 1)
  9645. {
  9646. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  9647. table2Row = dac2.Count;
  9648. #region 填充word表格内容
  9649. for (int i = 0; i < dac2.Count; i++)
  9650. {
  9651. var dac = dac2[i];
  9652. if (dac == null) continue;
  9653. builder.MoveToCell(1, i, 0, 0);
  9654. builder.Write("第" + dac.Days.ToString() + "天:");
  9655. builder.MoveToCell(1, i, 1, 0);
  9656. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9657. builder.MoveToCell(1, i, 2, 0);
  9658. builder.Write("费用标准:");
  9659. string curr = "";
  9660. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9661. if (currData != null)
  9662. {
  9663. curr = currData.Name;
  9664. }
  9665. builder.MoveToCell(1, i, 3, 0);
  9666. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9667. builder.MoveToCell(1, i, 4, 0);
  9668. builder.Write("费用小计:");
  9669. builder.MoveToCell(1, i, 5, 0);
  9670. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9671. }
  9672. #endregion
  9673. }
  9674. else dic.Add("SubHS", "0.00");
  9675. //删除多余行
  9676. while (table2.Rows.Count > table2Row)
  9677. {
  9678. table2.Rows.RemoveAt(table2Row);
  9679. }
  9680. //公杂费
  9681. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  9682. if (_EnterExitCosts.ChoiceFive == 1)
  9683. {
  9684. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  9685. table3Row = dac3.Count;
  9686. #region 填充word表格内容
  9687. for (int i = 0; i < dac3.Count; i++)
  9688. {
  9689. var dac = dac3[i];
  9690. if (dac == null) continue;
  9691. builder.MoveToCell(2, i, 0, 0);
  9692. builder.Write("第" + dac.Days.ToString() + "天:");
  9693. builder.MoveToCell(2, i, 1, 0);
  9694. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9695. builder.MoveToCell(2, i, 2, 0);
  9696. builder.Write("费用标准:");
  9697. string curr = "";
  9698. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9699. if (currData != null)
  9700. {
  9701. curr = currData.Name;
  9702. }
  9703. builder.MoveToCell(2, i, 3, 0);
  9704. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9705. builder.MoveToCell(2, i, 4, 0);
  9706. builder.Write("费用小计:");
  9707. builder.MoveToCell(2, i, 5, 0);
  9708. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9709. }
  9710. //删除多余行
  9711. while (table3.Rows.Count > table3Row)
  9712. {
  9713. table3.Rows.RemoveAt(table3Row);
  9714. }
  9715. #endregion
  9716. }
  9717. else dic.Add("SubGZF", "0.00");
  9718. //删除多余行
  9719. while (table3.Rows.Count > table3Row)
  9720. {
  9721. table3.Rows.RemoveAt(table3Row);
  9722. }
  9723. //培训费
  9724. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  9725. if (_EnterExitCosts.ChoiceSix == 1)
  9726. {
  9727. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  9728. dic.Add("SubPX", pxStr);
  9729. table4Row = dac4.Count;
  9730. #region 填充word表格内容
  9731. for (int i = 0; i < dac4.Count; i++)
  9732. {
  9733. var dac = dac4[i];
  9734. if (dac == null) continue;
  9735. builder.MoveToCell(3, i, 0, 0);
  9736. builder.Write("第" + dac.Days.ToString() + "天:");
  9737. builder.MoveToCell(3, i, 1, 0);
  9738. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  9739. builder.MoveToCell(3, i, 2, 0);
  9740. builder.Write("费用标准:");
  9741. string curr = "";
  9742. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9743. if (currData != null)
  9744. {
  9745. curr = currData.Name;
  9746. }
  9747. builder.MoveToCell(3, i, 3, 0);
  9748. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9749. builder.MoveToCell(3, i, 4, 0);
  9750. builder.Write("费用小计:");
  9751. builder.MoveToCell(3, i, 5, 0);
  9752. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9753. }
  9754. #endregion
  9755. }
  9756. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  9757. //删除多余行
  9758. while (table4.Rows.Count > table4Row)
  9759. {
  9760. table4.Rows.RemoveAt(table4Row);
  9761. }
  9762. //其他费用
  9763. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  9764. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  9765. {
  9766. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  9767. dic.Add("titleQi", qtStr);
  9768. table5Row = dac5.Count;
  9769. #region 填充word表格内容
  9770. for (int i = 0; i < dac5.Count; i++)
  9771. {
  9772. var dac = dac5[i];
  9773. if (dac == null) continue;
  9774. builder.MoveToCell(4, i, 0, 0);
  9775. builder.Write("第" + dac.Index.ToString() + "项:");
  9776. builder.MoveToCell(4, i, 1, 0);
  9777. builder.Write(dac.itemName);
  9778. builder.MoveToCell(4, i, 2, 0);
  9779. builder.Write("费用标准:");
  9780. builder.MoveToCell(4, i, 3, 0);
  9781. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  9782. builder.MoveToCell(4, i, 4, 0);
  9783. builder.Write("费用小计:");
  9784. builder.MoveToCell(4, i, 5, 0);
  9785. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9786. builder.MoveToCell(4, i, 6, 0);
  9787. builder.Write("备注:");
  9788. builder.MoveToCell(4, i, 7, 0);
  9789. builder.Write(dac.Remark);
  9790. }
  9791. #endregion
  9792. }
  9793. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  9794. //删除多余行
  9795. while (table5.Rows.Count > table5Row)
  9796. {
  9797. table5.Rows.RemoveAt(table5Row);
  9798. }
  9799. //加上其他费用
  9800. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  9801. decimal subJJC = 0.00M,
  9802. subGWC = 0.00M,
  9803. subTDC = 0.00M;
  9804. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  9805. string totalLabel = string.Format("全部费用总计:");
  9806. //经济舱
  9807. if (_EnterExitCosts.SumJJC == 1)
  9808. {
  9809. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9810. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  9811. }
  9812. //公务舱
  9813. if (_EnterExitCosts.SumGWC == 1)
  9814. {
  9815. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9816. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  9817. }
  9818. //头等舱
  9819. if (_EnterExitCosts.SumTDC == 1)
  9820. {
  9821. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9822. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  9823. }
  9824. //TotalLabel
  9825. dic.Add("TotalLabel", totalLabel);
  9826. #region 填充word模板书签内容
  9827. foreach (var key in dic.Keys)
  9828. {
  9829. Bookmark bookmark = doc.Range.Bookmarks[key];
  9830. if (bookmark != null)
  9831. {
  9832. builder.MoveToBookmark(key);
  9833. builder.Write(dic[key]);
  9834. }
  9835. }
  9836. #endregion
  9837. //文件名
  9838. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  9839. strFileName = CommonFun.ValidFileName(strFileName);
  9840. AsposeHelper.removewatermark_v2180();
  9841. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  9842. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  9843. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  9844. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  9845. }
  9846. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  9847. {
  9848. //获取模板
  9849. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  9850. //载入模板
  9851. Document doc = new Document(tempPath);
  9852. DocumentBuilder builder = new DocumentBuilder(doc);
  9853. Dictionary<string, string> dic = new Dictionary<string, string>();
  9854. string returnCodeLabel = string.Empty;
  9855. if (nationalTravelFeeData.Any())
  9856. {
  9857. List<string> list = new List<string>();
  9858. foreach (var item in nationalTravelFeeData)
  9859. {
  9860. list.Add($"{item.Country}({item.City})");
  9861. }
  9862. list = list.Distinct().ToList();
  9863. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  9864. }
  9865. var countryLabel = string.Empty;
  9866. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  9867. if (countryData.Any())
  9868. {
  9869. countryLabel = string.Join("、", countryData);
  9870. }
  9871. dic.Add("ReturnCodeAir", returnCodeLabel);
  9872. dic.Add("VisitStartDate", "-");
  9873. dic.Add("VisitEndDate", "-");
  9874. dic.Add("Day", "-");
  9875. dic.Add("VisitCountry", countryLabel);
  9876. dic.Add("ClientUnit", "-");
  9877. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  9878. //dic.Add("Names", Names);
  9879. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9880. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9881. decimal dac1totalPrice = 0.00M;
  9882. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  9883. foreach (var dac in dac1)
  9884. {
  9885. if (dac.SubTotal == 0.00M)
  9886. {
  9887. continue;
  9888. }
  9889. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  9890. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  9891. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  9892. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9893. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  9894. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9895. builder.Write(currency);//币种
  9896. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  9897. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9898. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  9899. builder.Write("");//人数
  9900. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  9901. builder.Write("");//天数
  9902. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  9903. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9904. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  9905. decimal rate = 0.00M;
  9906. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9907. builder.Write(rate.ToString("#0.0000"));//汇率
  9908. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  9909. decimal rbmPrice = dac.SubTotal;
  9910. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9911. accommodationStartIndex++;
  9912. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9913. }
  9914. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  9915. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  9916. {
  9917. table1.Rows.RemoveAt(i - 1);
  9918. foodandotherStartIndex--;
  9919. }
  9920. if (dac2.Count == dac3.Count)//国家 币种 金额
  9921. {
  9922. for (int i = 0; i < dac2.Count; i++)
  9923. {
  9924. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  9925. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  9926. }
  9927. }
  9928. decimal dac2totalPrice = 0.00M;
  9929. foreach (var dac in dac2)
  9930. {
  9931. if (dac.SubTotal == 0)
  9932. {
  9933. continue;
  9934. }
  9935. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  9936. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9937. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  9938. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  9939. builder.Write(currency);//币种
  9940. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  9941. builder.Write(dac.Cost.ToString("#0.00"));//标准
  9942. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  9943. builder.Write("");//人数
  9944. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  9945. builder.Write("");//天数
  9946. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  9947. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  9948. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  9949. decimal rate = 0.00M;
  9950. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  9951. builder.Write(rate.ToString("#0.0000"));//汇率
  9952. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  9953. decimal rbmPrice = dac.SubTotal;
  9954. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  9955. foodandotherStartIndex++;
  9956. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  9957. }
  9958. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  9959. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  9960. {
  9961. table1.Rows.RemoveAt(i - 1);
  9962. }
  9963. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  9964. string otherFeeStr = "";
  9965. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  9966. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  9967. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  9968. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  9969. foreach (var otherInfo in dac5)
  9970. {
  9971. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  9972. }
  9973. #endregion
  9974. if (otherFeeStr.Length > 0)
  9975. {
  9976. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  9977. otherFeeStr = $"({otherFeeStr})";
  9978. dic.Add("OtherFeeStr", otherFeeStr);
  9979. }
  9980. //总计
  9981. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  9982. //国际旅费
  9983. string outsideAir = string.Empty;
  9984. string allPriceAir = string.Empty;
  9985. if (_EnterExitCosts.SumJJC == 1)
  9986. {
  9987. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  9988. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  9989. }
  9990. if (_EnterExitCosts.SumGWC == 1)
  9991. {
  9992. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  9993. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  9994. }
  9995. if (_EnterExitCosts.SumTDC == 1)
  9996. {
  9997. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  9998. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  9999. }
  10000. dic.Add("InTravelPrice", $"({outsideAir})");
  10001. dic.Add("FinalSumPrice", $"({allPriceAir})");
  10002. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  10003. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  10004. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  10005. foreach (var key in dic.Keys)
  10006. {
  10007. builder.MoveToBookmark(key);
  10008. builder.Write(dic[key]);
  10009. }
  10010. //模板文件名
  10011. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10012. strFileName = CommonFun.ValidFileName(strFileName);
  10013. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10014. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10015. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10016. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10017. }
  10018. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  10019. {
  10020. //获取模板
  10021. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  10022. //载入模板
  10023. WorkbookDesigner designer = new WorkbookDesigner();
  10024. designer.Workbook = new Workbook(tempPath);
  10025. Dictionary<string, string> dic = new Dictionary<string, string>();
  10026. string returnCodeLabel = string.Empty;
  10027. if (nationalTravelFeeData.Any())
  10028. {
  10029. List<string> list = new List<string>();
  10030. foreach (var item in nationalTravelFeeData)
  10031. {
  10032. list.Add($"{item.Country}({item.City})");
  10033. }
  10034. list = list.Distinct().ToList();
  10035. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  10036. }
  10037. var countryLabel = string.Empty;
  10038. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  10039. if (countryData.Any())
  10040. {
  10041. countryLabel = string.Join("、", countryData);
  10042. }
  10043. dic.Add("ReturnCodeAir", returnCodeLabel);
  10044. dic.Add("VisitStartDate", "-");
  10045. dic.Add("VisitEndDate", "-");
  10046. dic.Add("Day", "0");
  10047. dic.Add("VisitCountry", countryLabel);
  10048. dic.Add("ClientUnit", "-");
  10049. designer.SetDataSource("ClientUnit", "-");
  10050. designer.SetDataSource("VisitCountry", countryLabel);
  10051. designer.SetDataSource("Group", "-");
  10052. designer.SetDataSource("ClientUnitTitle", "-");
  10053. designer.SetDataSource("Name", "-");
  10054. designer.SetDataSource("VisitStartDate", "-");
  10055. designer.SetDataSource("Day", "0");
  10056. designer.SetDataSource("ReturnCode", returnCodeLabel);
  10057. designer.SetDataSource("ReturnCodeAir", "-");
  10058. int startIndex = 10;
  10059. const int startIndexcopy = 10;
  10060. if (dac2.Count == dac3.Count)//国家 币种 金额
  10061. {
  10062. for (int i = 0; i < dac2.Count; i++)
  10063. {
  10064. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10065. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10066. }
  10067. }
  10068. DataTable dtdac1 = new DataTable();
  10069. List<string> place = new List<string>();
  10070. dtdac1.Columns.AddRange(new DataColumn[] {
  10071. new DataColumn(){ ColumnName = "city"},
  10072. new DataColumn(){ ColumnName = "curr"},
  10073. new DataColumn(){ ColumnName = "criterion"},
  10074. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  10075. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  10076. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  10077. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  10078. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  10079. });
  10080. DataTable dtdac2 = new DataTable();
  10081. dtdac2.Columns.AddRange(new DataColumn[] {
  10082. new DataColumn(){ ColumnName = "city"},
  10083. new DataColumn(){ ColumnName = "curr"},
  10084. new DataColumn(){ ColumnName = "criterion"},
  10085. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  10086. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  10087. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  10088. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  10089. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  10090. });
  10091. dtdac1.TableName = "tb1";
  10092. dtdac2.TableName = "tb2";
  10093. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  10094. foreach (var item in dac1)
  10095. {
  10096. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  10097. if (place.Contains(item.Place))
  10098. {
  10099. continue;
  10100. }
  10101. DataRow row = dtdac1.NewRow();
  10102. row["city"] = item.Place;
  10103. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10104. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10105. row["curr"] = currency;
  10106. row["rate"] = rate.ToString("#0.0000");
  10107. row["criterion"] = item.Cost.ToString("#0.00");
  10108. row["number"] = 1;
  10109. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10110. //row["costRMB"] = rbmPrice;
  10111. dtdac1.Rows.Add(row);
  10112. place.Add(item.Place);
  10113. }
  10114. place = new List<string>();
  10115. foreach (var item in dac2)
  10116. {
  10117. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  10118. if (place.Contains(item.Place))
  10119. {
  10120. continue;
  10121. }
  10122. DataRow row = dtdac2.NewRow();
  10123. row["city"] = item.Place;
  10124. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10125. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10126. row["curr"] = currency;
  10127. row["rate"] = rate.ToString("#0.0000");
  10128. row["criterion"] = item.Cost.ToString("#0.00");
  10129. row["number"] = 1;
  10130. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10131. //row["cost"] = item.SubTotal;
  10132. //row["costRMB"] = rbmPrice;
  10133. dtdac2.Rows.Add(row);
  10134. place.Add(item.Place);
  10135. //dac2totalPrice += rbmPrice;
  10136. }
  10137. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  10138. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  10139. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10140. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  10141. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  10142. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  10143. string cell4Str1 = string.Empty;
  10144. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  10145. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  10146. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  10147. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  10148. string cellStr = $" 5.其他费用(";
  10149. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  10150. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  10151. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  10152. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  10153. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  10154. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  10155. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  10156. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  10157. foreach (var otherInfo in dac5)
  10158. {
  10159. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  10160. }
  10161. #endregion
  10162. if (cellStr.Length > 8)
  10163. {
  10164. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  10165. }
  10166. cellStr += ")";
  10167. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  10168. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  10169. decimal pxFee = dac4.Sum(it => it.Cost);
  10170. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  10171. string celllastStr1 = "";
  10172. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  10173. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  10174. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  10175. celllastStr1 += $",国际旅费 元";
  10176. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  10177. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  10178. designer.SetDataSource("cell4Str", cell4Str);
  10179. designer.SetDataSource("cellStr", cellStr);
  10180. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  10181. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10182. designer.SetDataSource("celllastStr", celllastStr);
  10183. Workbook wb = designer.Workbook;
  10184. var sheet = wb.Worksheets[0];
  10185. //绑定datatable数据集
  10186. designer.SetDataSource(dtdac1);
  10187. designer.SetDataSource(dtdac2);
  10188. designer.Process();
  10189. var rowStart = dtdac1.Rows.Count;
  10190. while (rowStart > 0)
  10191. {
  10192. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  10193. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10194. startIndex++;
  10195. rowStart--;
  10196. }
  10197. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  10198. startIndex += 1; //总计行
  10199. rowStart = dtdac2.Rows.Count;
  10200. while (rowStart > 0)
  10201. {
  10202. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  10203. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10204. startIndex++;
  10205. rowStart--;
  10206. }
  10207. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  10208. wb.CalculateFormula(true);
  10209. //模板文件名
  10210. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10211. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10212. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10213. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10214. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10215. }
  10216. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  10217. {
  10218. //获取模板
  10219. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  10220. //载入模板
  10221. Document doc = new Document(tempPath);
  10222. DocumentBuilder builder = new DocumentBuilder(doc);
  10223. Dictionary<string, string> dic = new Dictionary<string, string>();
  10224. dic.Add("GroupName", "-");
  10225. dic.Add("ClientUnit", "-");
  10226. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  10227. //string missionLeaderJob = "";//负责人job
  10228. //int groupNumber = 0; //团人数
  10229. dic.Add("MissionLeader", "-"); //团负责人
  10230. dic.Add("MissionLeaderJob", "-"); //团负责人job
  10231. dic.Add("GroupNumber", "0"); //团人数
  10232. dic.Add("Day", "0");
  10233. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  10234. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10235. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10236. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10237. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  10238. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  10239. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  10240. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  10241. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  10242. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  10243. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  10244. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  10245. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  10246. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  10247. //其他费用
  10248. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  10249. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  10250. //其他费用合计
  10251. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  10252. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  10253. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  10254. //公务舱合计
  10255. //国际旅费
  10256. //string outsideJJ = "";
  10257. //string allPriceJJ = "";
  10258. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  10259. {
  10260. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10261. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  10262. }
  10263. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  10264. {
  10265. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  10266. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  10267. }
  10268. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  10269. {
  10270. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  10271. dic.Add("AirFeeTotal", airFeeTotalStr);
  10272. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  10273. dic.Add("FeeTotal", feeTotalStr);
  10274. }
  10275. foreach (var key in dic.Keys)
  10276. {
  10277. builder.MoveToBookmark(key);
  10278. builder.Write(dic[key]);
  10279. }
  10280. //模板文件名
  10281. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  10282. strFileName = CommonFun.ValidFileName(strFileName);
  10283. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10284. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10285. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10286. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10287. }
  10288. }
  10289. else if (dto.ExportType == 2) //表格
  10290. {
  10291. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10292. }
  10293. else if (dto.ExportType == 3)
  10294. {
  10295. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  10296. }
  10297. return Ok(JsonView(400, "只可导出明细表!", ""));
  10298. }
  10299. catch (Exception ex)
  10300. {
  10301. return Ok(JsonView(400, ex.Message, ""));
  10302. }
  10303. }
  10304. /// <summary>
  10305. /// 获取三公费用标准city
  10306. /// </summary>
  10307. /// <param name="placeData"></param>
  10308. /// <param name="nationalTravelFeeId"></param>
  10309. /// <returns></returns>
  10310. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  10311. {
  10312. string _city = string.Empty;
  10313. if (!placeData.Any()) return _city;
  10314. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  10315. if (data == null) return _city;
  10316. string country = data.Country;
  10317. string city = data.City;
  10318. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  10319. else _city = city;
  10320. return _city;
  10321. }
  10322. /// <summary>
  10323. /// 团组模块 - 出入境费用-草稿 - 一键清空
  10324. /// </summary>
  10325. /// <returns></returns>
  10326. [HttpPost]
  10327. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10329. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  10330. {
  10331. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  10332. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  10333. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  10334. if (_view.Code == 0)
  10335. {
  10336. return Ok(JsonView(true, "操作成功"));
  10337. }
  10338. return Ok(JsonView(false, "操作失败"));
  10339. }
  10340. /// <summary>
  10341. /// 团组模块 - 出入境费用-草稿 - 子项删除
  10342. /// </summary>
  10343. /// <returns></returns>
  10344. [HttpPost]
  10345. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10346. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10347. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  10348. {
  10349. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  10350. if (data.Code != 0)
  10351. {
  10352. return Ok(JsonView(false, data.Msg));
  10353. }
  10354. return Ok(JsonView(true, "操作成功!", data.Data));
  10355. }
  10356. /// <summary>
  10357. /// 三公其他费用草稿 删除
  10358. /// </summary>
  10359. /// <param name="dto"></param>
  10360. /// <returns></returns>
  10361. [HttpPost]
  10362. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  10363. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  10364. {
  10365. var jw = JsonView(false, "删除失败!");
  10366. var data = new Grp_DayOtherPriceDraft()
  10367. {
  10368. Id = dto.Id,
  10369. IsDel = 1,
  10370. DeleteUserId = dto.DeleteUserId,
  10371. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10372. };
  10373. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10374. if (del > 0)
  10375. {
  10376. jw.Code = 200;
  10377. jw.Msg = "删除成功!";
  10378. }
  10379. return Ok(jw);
  10380. }
  10381. /// <summary>
  10382. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  10383. /// </summary>
  10384. /// <returns></returns>
  10385. [HttpPost]
  10386. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  10387. {
  10388. var jw = JsonView(false);
  10389. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  10390. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  10391. jw.Code = StatusCodes.Status200OK;
  10392. jw.Msg = "操作成功!";
  10393. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  10394. return Ok(jw);
  10395. }
  10396. /// <summary>
  10397. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  10398. /// </summary>
  10399. /// <param name="dto"></param>
  10400. /// <returns></returns>
  10401. [HttpPost]
  10402. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  10403. {
  10404. int userId = dto.UserId,
  10405. portId = dto.PortType,
  10406. groupId = dto.GroupId,
  10407. draftId = dto.DraftId;
  10408. _portTypeData.Add(1);
  10409. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10410. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  10411. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  10412. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  10413. _sqlSugar.BeginTran();
  10414. try
  10415. {
  10416. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  10417. if (draftDatas == null)
  10418. {
  10419. _sqlSugar.RollbackTran();
  10420. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  10421. }
  10422. //验证可覆盖已有数据 两边创建人需为同一人;
  10423. int draftCreateUserId = draftDatas.CreateUserId,
  10424. formalCreateUserId = 0;
  10425. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10426. if (formalData != null)
  10427. {
  10428. formalCreateUserId = formalData.CreateUserId;
  10429. if (draftCreateUserId != formalCreateUserId)
  10430. {
  10431. _sqlSugar.RollbackTran();
  10432. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  10433. }
  10434. }
  10435. //默认添加查看、编辑权限(创建人、自己)
  10436. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  10437. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10438. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  10439. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  10440. newExterData.DiId = groupId;
  10441. newExterData.CreateUserId = userId;
  10442. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  10443. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  10444. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  10445. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  10446. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  10447. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  10448. //数据如果存在执行删除
  10449. if (enterExitCostInfo != null)
  10450. {
  10451. _sqlSugar.Updateable<Grp_EnterExitCost>()
  10452. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  10453. .Where(x => x.Id == enterExitCostInfo.Id)
  10454. .ExecuteCommand();
  10455. _sqlSugar.Updateable<Grp_DayAndCost>()
  10456. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10457. .Where(x => x.DiId == groupId)
  10458. .ExecuteCommand();
  10459. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  10460. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10461. .Where(x => x.Diid == groupId)
  10462. .ExecuteCommand();
  10463. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  10464. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  10465. .Where(x => x.GroupId == groupId)
  10466. .ExecuteCommand();
  10467. }
  10468. //执行insert
  10469. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  10470. if (insertId < 1)
  10471. {
  10472. _sqlSugar.RollbackTran();
  10473. return Ok(JsonView(false, "草稿数据导入失败!"));
  10474. }
  10475. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  10476. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  10477. #region 默认添加权限
  10478. #endregion
  10479. _sqlSugar.CommitTran();
  10480. //执行操作之后
  10481. //生成默认文件pdf并且通知人员
  10482. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  10483. {
  10484. DiId = groupId,
  10485. ExportType = 1,
  10486. SubTypeId = 1005
  10487. }, "pdf");
  10488. //发送通知
  10489. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  10490. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  10491. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  10492. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  10493. //汇率信息记录
  10494. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  10495. return Ok(JsonView(true));
  10496. }
  10497. catch (Exception ex)
  10498. {
  10499. _sqlSugar.RollbackTran();
  10500. return Ok(JsonView(false, ex.Message));
  10501. }
  10502. }
  10503. #endregion
  10504. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  10505. /// <summary>
  10506. /// 获取币种基础数据(含逻辑处理)
  10507. /// </summary>
  10508. /// <returns></returns>
  10509. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  10510. {
  10511. return await GeneralMethod.EnterExitCostInitRate();
  10512. }
  10513. /// <summary>
  10514. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  10515. /// </summary>
  10516. /// <returns></returns>
  10517. [HttpPost]
  10518. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10519. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  10520. {
  10521. //验证城市归属并给默认值
  10522. int provinceId = dto.ProvinceId;
  10523. if (provinceId < 1) provinceId = 122;
  10524. var dataSource = await _sqlSugar
  10525. .Queryable<Sys_SetData>()
  10526. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  10527. .ToListAsync();
  10528. var fileTypes = new List<EecSetDataInfoView>();
  10529. //三公费用-Word明细类型
  10530. var wordTypeData = dataSource
  10531. .Where(it => it.STid == 72)
  10532. .Select(x => new EecSetDataInfoView
  10533. {
  10534. ParentId = 1,
  10535. Id = x.Id,
  10536. Name = x.Name
  10537. })
  10538. .ToArray();
  10539. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  10540. var excelTypeData = dataSource
  10541. .Where(it => it.STid == 73)
  10542. .Select(x => new EecSetDataInfoView
  10543. {
  10544. ParentId = 2,
  10545. Id = x.Id,
  10546. Name = x.Name
  10547. })
  10548. .ToArray();
  10549. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  10550. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  10551. fileTypes.Add(groupNameList);
  10552. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  10553. //默认币种显示
  10554. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  10555. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  10556. return Ok(JsonView(true, "查询成功!", new
  10557. {
  10558. FileTypeData = fileTypes,
  10559. CurrencyInit = _currencyInfos,
  10560. viewPermissionData = viewPermissionData
  10561. }));
  10562. }
  10563. /// <summary>
  10564. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  10565. /// </summary>
  10566. /// <returns></returns>
  10567. [HttpPost]
  10568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10569. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  10570. {
  10571. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10572. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10573. RefAsync<int> total = 0;
  10574. int diId = 0;
  10575. var status = int.TryParse(dto.GroupName, out diId);
  10576. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  10577. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  10578. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  10579. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  10580. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  10581. .OrderByDescending(x => x.VisitStartDate)
  10582. .Select(x => new EnterExitCostMobileGroupView()
  10583. {
  10584. Id = x.Id,
  10585. GroupName = x.TeamName,
  10586. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  10587. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  10588. ProvinceId = x.CityId
  10589. })
  10590. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10591. //处理省份Id
  10592. if (data.Any())
  10593. {
  10594. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  10595. if (provCityDatas.Any())
  10596. {
  10597. foreach (var item in data)
  10598. {
  10599. var provinceId = item.ProvinceId;
  10600. var isDefualtVal = true;
  10601. if (provinceId > 0)
  10602. {
  10603. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  10604. if (parentId != null)
  10605. {
  10606. isDefualtVal = false;
  10607. item.ProvinceId = (int)parentId;
  10608. }
  10609. }
  10610. if (isDefualtVal)
  10611. {
  10612. item.ProvinceId = 122; //默认四川
  10613. }
  10614. }
  10615. }
  10616. }
  10617. //处理是否显示
  10618. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  10619. {
  10620. foreach (var item in data)
  10621. {
  10622. item.IsView = true;
  10623. }
  10624. }
  10625. return Ok(JsonView(true, "查询成功!", data, total));
  10626. }
  10627. /// <summary>
  10628. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  10629. /// </summary>
  10630. /// <returns></returns>
  10631. [HttpPost]
  10632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10633. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  10634. {
  10635. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10636. RefAsync<int> total = 0;
  10637. var data = await _sqlSugar.Queryable<Sys_SetData>()
  10638. .Where(x => x.IsDel == 0 && x.STid == 66)
  10639. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  10640. .Select(x => new
  10641. {
  10642. id = x.Id,
  10643. name = x.Name,
  10644. remark = x.Remark,
  10645. })
  10646. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10647. return Ok(JsonView(true, "查询成功!", data, total));
  10648. }
  10649. /// <summary>
  10650. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  10651. /// </summary>
  10652. /// <returns></returns>
  10653. [HttpPost]
  10654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10655. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  10656. {
  10657. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10658. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10659. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  10660. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  10661. var groupOtherRateData = groupRateData.TeamRates;
  10662. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10663. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  10664. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  10665. groupOtherRateData = groupOtherRateData
  10666. .Select(x => new TeamRateDescAddCurrencyIdView
  10667. {
  10668. CurrencyId = x.CurrencyId,
  10669. CurrencyName = x.CurrencyName,
  10670. CurrencyCode = x.CurrencyCode,
  10671. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  10672. }).ToList();
  10673. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  10674. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  10675. }
  10676. /// <summary>
  10677. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  10678. /// </summary>
  10679. /// <returns></returns>
  10680. [HttpPost]
  10681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10682. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  10683. {
  10684. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10685. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10686. var tipsData = new List<int>() { 1, 2, 3 };
  10687. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  10688. if (dto.TipsType == 1)
  10689. {
  10690. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  10691. }
  10692. else if (dto.TipsType == 2)
  10693. {
  10694. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  10695. return Ok(JsonView(true, "查询成功!", visaData.Data));
  10696. }
  10697. else if (dto.TipsType == 3)
  10698. {
  10699. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  10700. return Ok(JsonView(true, "查询成功!", airData));
  10701. }
  10702. return Ok(JsonView(false));
  10703. }
  10704. /// <summary>
  10705. /// 团组模块 - 出入境国家费用标准-移动端 List
  10706. /// </summary>
  10707. /// <returns></returns>
  10708. [HttpPost]
  10709. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10710. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  10711. {
  10712. Stopwatch sw = new Stopwatch();
  10713. sw.Start();
  10714. int provinceId = dto.ProvinceId;
  10715. if (provinceId < 1) provinceId = 122; // 默认四川
  10716. RefAsync<int> total = 0;
  10717. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  10718. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  10719. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  10720. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  10721. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  10722. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  10723. .Select((ntf, sd, u, sd1) => new
  10724. {
  10725. Id = ntf.Id,
  10726. Area = $"{ntf.Country}-{ntf.City}",
  10727. Currency = ntf.Currency,
  10728. CurrencyCode = sd.Name,
  10729. CurrencyName = sd.Remark,
  10730. RoomCost = ntf.RoomCost,
  10731. FoodCost = ntf.FoodCost,
  10732. PublicCost = ntf.PublicCost,
  10733. TrainCost = ntf.TrainCost,
  10734. LastUpdateUserId = ntf.LastUpdateUserId,
  10735. LastUpdateUserName = u.CnName,
  10736. LastUpdateTime = ntf.LastUpdateTime
  10737. })
  10738. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  10739. sw.Stop();
  10740. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  10741. }
  10742. /// <summary>
  10743. /// 团组模块 - 出入境费用-移动端 - Info
  10744. /// </summary>
  10745. /// <returns></returns>
  10746. [HttpPost]
  10747. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10748. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  10749. {
  10750. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10751. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10752. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  10753. return Ok(data);
  10754. }
  10755. /// <summary>
  10756. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  10757. /// </summary>
  10758. /// <returns></returns>
  10759. [HttpPost]
  10760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10761. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto 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 eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10767. var mobileInfo = new EnterExitCostMobileParentInfoView();
  10768. mobileInfo.DiId = dto.DiId;
  10769. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  10770. if (eecInfo == null) return Ok(mobileInfo);
  10771. //验证查看权限
  10772. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  10773. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  10774. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  10775. mobileInfo.IsAssignPerm = isSet;
  10776. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  10777. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10778. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10779. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  10780. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10781. {
  10782. SubId = dac.Id,
  10783. DiId = dac.DiId,
  10784. Type = dac.Type,
  10785. Days = dac.Days,
  10786. NationalTravelFeeId = dac.NationalTravelFeeId,
  10787. Arae = $"{ntf.Country}-{ntf.City}",
  10788. Cost = dac.Cost,
  10789. Currency = dac.Currency,
  10790. CurrencyName = sd.Name,
  10791. SubTotal = dac.SubTotal,
  10792. })
  10793. .ToList();
  10794. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  10795. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  10796. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  10797. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  10798. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  10799. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  10800. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  10801. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  10802. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  10803. //其他款项
  10804. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  10805. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  10806. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  10807. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  10808. .OrderBy((dop, sd1, sd2) => dop.Index)
  10809. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  10810. {
  10811. SubId = dop.Id,
  10812. DiId = dop.Diid,
  10813. Index = dop.Index,
  10814. SetDataId = dop.SetDataId,
  10815. SetDataName = sd1.Name,
  10816. Cost = dop.Cost,
  10817. Currency = dop.Currency,
  10818. CurrencyName = sd2.Remark,
  10819. SubTotal = dop.SubTotal,
  10820. Remark = dop.Remark,
  10821. })
  10822. .ToArray();
  10823. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  10824. return Ok(mobileInfo);
  10825. }
  10826. /// <summary>
  10827. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  10828. /// </summary>
  10829. /// <returns></returns>
  10830. [HttpPost]
  10831. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10832. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  10833. {
  10834. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10835. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10836. //验证查看权限
  10837. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  10838. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  10839. var userIds = await _sqlSugar
  10840. .Queryable<Grp_EnterExitCostPermission>()
  10841. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  10842. .Select(x => x.UserId)
  10843. .ToArrayAsync();
  10844. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  10845. var perUsersView = new List<dynamic>();
  10846. foreach (var item in perUsers)
  10847. {
  10848. bool isView1 = false;
  10849. if (userIds.Any(x => x == item.Id)) isView1 = true;
  10850. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  10851. }
  10852. return Ok(JsonView(perUsersView));
  10853. }
  10854. /// <summary>
  10855. /// 团组模块 - 出入境费用-移动端 - SubInfo
  10856. /// </summary>
  10857. /// <returns></returns>
  10858. [HttpPost]
  10859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10860. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  10861. {
  10862. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  10863. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  10864. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  10865. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  10866. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  10867. //验证查看权限
  10868. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  10869. //if (!isView) return Ok(JsonView(false, msg));
  10870. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  10871. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  10872. var subType = dto.SubType;
  10873. if (subType == 1) //1:境内费用
  10874. {
  10875. var oneData = new ChoiceOneMobileSubInfoView()
  10876. {
  10877. Id = eecInfo.Id,
  10878. ChoiceOne = eecInfo.ChoiceOne,
  10879. ChoiceOneTotalCost = eecInfo.InsidePay,
  10880. Visa = eecInfo.Visa,
  10881. VisaRemark = eecInfo.VisaRemark,
  10882. YiMiao = eecInfo.YiMiao,
  10883. HeSuan = eecInfo.HeSuan,
  10884. Service = eecInfo.Service,
  10885. Ticket = eecInfo.Ticket,
  10886. Safe = eecInfo.Safe,
  10887. FirstItemRemark = eecInfo.FirstItemRemark
  10888. };
  10889. return Ok(JsonView(oneData));
  10890. }
  10891. else if (subType == 2) //2:国际旅费
  10892. {
  10893. var twoData = new ChoiceTwoMobileSubInfoView()
  10894. {
  10895. Id = eecInfo.Id,
  10896. ChoiceTwoJJ = eecInfo.SumJJC,
  10897. OutsideJJPay = eecInfo.OutsideJJPay,
  10898. ChoiceTwoGW = eecInfo.SumGWC,
  10899. OutsideGWPay = eecInfo.OutsideGWPay,
  10900. ChoiceTwoTD = eecInfo.SumTDC,
  10901. OutsideTDPay = eecInfo.OutsideTDPay,
  10902. AirJJ = eecInfo.AirJJ,
  10903. AirGW = eecInfo.AirGW,
  10904. AirTD = eecInfo.AirTD,
  10905. CityTranffic = eecInfo.CityTranffic,
  10906. TwoItemRemark = eecInfo.TwoItemRemark
  10907. };
  10908. return Ok(JsonView(twoData));
  10909. }
  10910. else if (subType == 3) //3:住宿费
  10911. {
  10912. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10913. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10914. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10915. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  10916. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10917. {
  10918. SubId = dac.Id,
  10919. DiId = dac.DiId,
  10920. Type = dac.Type,
  10921. Days = dac.Days,
  10922. NationalTravelFeeId = dac.NationalTravelFeeId,
  10923. Arae = $"{ntf.Country}-{ntf.City}",
  10924. Cost = dac.Cost,
  10925. Currency = dac.Currency,
  10926. CurrencyName = sd.Name,
  10927. SubTotal = dac.SubTotal,
  10928. })
  10929. .ToArray();
  10930. var data = new ChoiceMobileSubInfo3To6View()
  10931. {
  10932. ParentId = eecInfo.Id,
  10933. Choice = eecInfo.ChoiceThree,
  10934. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10935. Details = dayAndCostDatas
  10936. };
  10937. return Ok(JsonView(data));
  10938. }
  10939. else if (subType == 4) //4:伙食费
  10940. {
  10941. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10942. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10943. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10944. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  10945. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10946. {
  10947. SubId = dac.Id,
  10948. DiId = dac.DiId,
  10949. Type = dac.Type,
  10950. Days = dac.Days,
  10951. NationalTravelFeeId = dac.NationalTravelFeeId,
  10952. Arae = $"{ntf.Country}-{ntf.City}",
  10953. Cost = dac.Cost,
  10954. Currency = dac.Currency,
  10955. CurrencyName = sd.Name,
  10956. SubTotal = dac.SubTotal,
  10957. })
  10958. .ToArray();
  10959. var data = new ChoiceMobileSubInfo3To6View()
  10960. {
  10961. ParentId = eecInfo.Id,
  10962. Choice = eecInfo.ChoiceFour,
  10963. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10964. Details = dayAndCostDatas
  10965. };
  10966. return Ok(JsonView(data));
  10967. }
  10968. else if (subType == 5) //5:公杂费
  10969. {
  10970. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  10971. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  10972. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  10973. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  10974. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  10975. {
  10976. SubId = dac.Id,
  10977. DiId = dac.DiId,
  10978. Type = dac.Type,
  10979. Days = dac.Days,
  10980. NationalTravelFeeId = dac.NationalTravelFeeId,
  10981. Arae = $"{ntf.Country}-{ntf.City}",
  10982. Cost = dac.Cost,
  10983. Currency = dac.Currency,
  10984. CurrencyName = sd.Name,
  10985. SubTotal = dac.SubTotal,
  10986. })
  10987. .ToArray();
  10988. var data = new ChoiceMobileSubInfo3To6View()
  10989. {
  10990. ParentId = eecInfo.Id,
  10991. Choice = eecInfo.ChoiceFive,
  10992. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  10993. Details = dayAndCostDatas
  10994. };
  10995. return Ok(JsonView(data));
  10996. }
  10997. else if (subType == 6) //6:培训费
  10998. {
  10999. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  11000. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  11001. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  11002. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  11003. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  11004. {
  11005. SubId = dac.Id,
  11006. DiId = dac.DiId,
  11007. Type = dac.Type,
  11008. Days = dac.Days,
  11009. NationalTravelFeeId = dac.NationalTravelFeeId,
  11010. Arae = $"{ntf.Country}-{ntf.City}",
  11011. Cost = dac.Cost,
  11012. Currency = dac.Currency,
  11013. CurrencyName = sd.Name,
  11014. SubTotal = dac.SubTotal,
  11015. })
  11016. .ToArray();
  11017. var data = new ChoiceMobileSubInfo3To6View()
  11018. {
  11019. ParentId = eecInfo.Id,
  11020. Choice = eecInfo.ChoiceSix,
  11021. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  11022. Details = dayAndCostDatas
  11023. };
  11024. return Ok(JsonView(data));
  11025. }
  11026. else if (subType == 7) //7:其他
  11027. {
  11028. //其他款项
  11029. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  11030. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  11031. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  11032. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  11033. .OrderBy((dop, sd1, sd2) => dop.Index)
  11034. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  11035. {
  11036. SubId = dop.Id,
  11037. DiId = dop.Diid,
  11038. Index = dop.Index,
  11039. SetDataId = dop.SetDataId,
  11040. SetDataName = sd1.Name,
  11041. Cost = dop.Cost,
  11042. Currency = dop.Currency,
  11043. CurrencyName = sd2.Name,
  11044. SubTotal = dop.SubTotal,
  11045. Remark = dop.Remark,
  11046. })
  11047. .ToArray();
  11048. var data = new ChoiceSevenMobileSubInfoView()
  11049. {
  11050. ParentId = eecInfo.Id,
  11051. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  11052. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  11053. Details = otherData
  11054. };
  11055. return Ok(JsonView(data));
  11056. }
  11057. return Ok(JsonView(false));
  11058. }
  11059. #region op
  11060. ///// <summary>
  11061. ///// 移动端更新费用消息通知
  11062. ///// </summary>
  11063. ///// <param name="diid"></param>
  11064. ///// <param name="id"></param>
  11065. ///// <param name="currUserId"></param>
  11066. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  11067. //{
  11068. // try
  11069. // {
  11070. // ////生成默认文件pdf并且通知人员
  11071. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  11072. // //{
  11073. // // DiId = diid,
  11074. // // ExportType = 1,
  11075. // // SubTypeId = 1005
  11076. // //}, "pdf");
  11077. // ////发送通知
  11078. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  11079. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  11080. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  11081. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  11082. // ////汇率信息记录
  11083. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  11084. // }
  11085. // catch (Exception ex)
  11086. // {
  11087. // //记录日志
  11088. // throw;
  11089. // }
  11090. //}
  11091. /// <summary>
  11092. /// 验证出入境费用数据是否存在
  11093. /// 不存在添加
  11094. /// </summary>
  11095. /// <param name="diId"></param>
  11096. /// <param name="currUserId"></param>
  11097. /// <returns></returns>
  11098. /// <exception cref="CustomException"></exception>
  11099. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  11100. {
  11101. var parentId = 0;
  11102. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  11103. if (info != null)
  11104. {
  11105. parentId = info.Id;
  11106. }
  11107. else
  11108. {
  11109. var currencys = await EnterExitCostMobileGetCurrencyInit();
  11110. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  11111. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  11112. parentId = addId;
  11113. }
  11114. return parentId;
  11115. }
  11116. /// <summary>
  11117. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  11118. /// </summary>
  11119. /// <returns></returns>
  11120. [HttpPost]
  11121. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11122. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  11123. {
  11124. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11125. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11126. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11127. //验证编辑权限
  11128. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11129. //if (!isEdit) return Ok(JsonView(false, msg));
  11130. var permissions = new List<Grp_EnterExitCostPermission>();
  11131. foreach (var userId in dto.UserIds)
  11132. {
  11133. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  11134. }
  11135. if (permissions.Any())
  11136. {
  11137. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  11138. {
  11139. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  11140. }
  11141. _sqlSugar.BeginTran();
  11142. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  11143. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11144. if (result < 1)
  11145. {
  11146. _sqlSugar.RollbackTran();
  11147. return Ok(JsonView(false));
  11148. }
  11149. _sqlSugar.CommitTran();
  11150. return Ok(JsonView(true));
  11151. }
  11152. return Ok(JsonView(false));
  11153. }
  11154. /// <summary>
  11155. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  11156. /// </summary>
  11157. /// <returns></returns>
  11158. [HttpPost]
  11159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11160. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  11161. {
  11162. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11163. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11164. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11165. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  11166. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  11167. int id = dto.Id;
  11168. if (id <= 0) //add
  11169. {
  11170. //int provinceId = dto.ProvinceId;
  11171. int groupId = dto.DiId;
  11172. //if (provinceId < 1) provinceId = 122;
  11173. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  11174. info.LastUpdateUserId = dto.CurrUserId;
  11175. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11176. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  11177. if (add < 1) return Ok(JsonView(false));
  11178. id = add;
  11179. }
  11180. else //update
  11181. {
  11182. ////验证编辑权限
  11183. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11184. //if (!isEdit) return Ok(JsonView(false, msg));
  11185. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  11186. {
  11187. CurrencyRemark = currencyStr,
  11188. LastUpdateUserId = dto.CurrUserId,
  11189. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11190. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  11191. if (upd < 1) return Ok(JsonView(false));
  11192. }
  11193. #region 汇率变更时更改币种相关费用
  11194. var opDayCosts = new List<Grp_DayAndCost>();
  11195. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  11196. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  11197. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  11198. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  11199. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  11200. .Select((dac, sd) => new
  11201. {
  11202. dac.Id,
  11203. dac.DiId,
  11204. CurrencyCode = sd.Name,
  11205. dac.Cost
  11206. })
  11207. .ToList();
  11208. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  11209. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  11210. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  11211. .Select((dop, sd) => new
  11212. {
  11213. dop.Id,
  11214. dop.Diid,
  11215. CurrencyCode = sd.Name,
  11216. dop.Cost
  11217. })
  11218. .ToList();
  11219. if (dayCosts.Count > 0)
  11220. {
  11221. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11222. foreach (var dc in new_dayCosts)
  11223. {
  11224. var thisCurrency = dc.Key.ToUpper();
  11225. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11226. if (thisRate == 0.00M) continue;
  11227. foreach (var dcSub in dc)
  11228. {
  11229. opDayCosts.Add(new Grp_DayAndCost()
  11230. {
  11231. Id = dcSub.Id,
  11232. DiId = dcSub.DiId,
  11233. Cost = dcSub.Cost,
  11234. SubTotal = dcSub.Cost * thisRate,
  11235. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11236. });
  11237. }
  11238. }
  11239. if (opDayCosts.Count > 0)
  11240. {
  11241. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11242. }
  11243. }
  11244. if (dayOtherCosts.Count > 0)
  11245. {
  11246. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  11247. foreach (var dc in new_dayOtherCosts)
  11248. {
  11249. var thisCurrency = dc.Key.ToUpper();
  11250. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  11251. if (thisRate == 0.00M) continue;
  11252. foreach (var dcSub in dc)
  11253. {
  11254. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  11255. {
  11256. Id = dcSub.Id,
  11257. Diid = dcSub.Diid,
  11258. Cost = dcSub.Cost,
  11259. SubTotal = dcSub.Cost * thisRate,
  11260. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  11261. });
  11262. }
  11263. }
  11264. if (opDayOtherCosts.Count > 0)
  11265. {
  11266. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  11267. }
  11268. }
  11269. #endregion
  11270. //消息通知
  11271. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11272. //汇率信息记录
  11273. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  11274. return Ok(JsonView(new { parentId = id }));
  11275. }
  11276. /// <summary>
  11277. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  11278. /// </summary>
  11279. /// <returns></returns>
  11280. [HttpPost]
  11281. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11282. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  11283. {
  11284. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11285. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11286. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11287. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11288. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  11289. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  11290. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11291. int id = dto.Id;
  11292. if (id <= 0) //add
  11293. {
  11294. checkboxInfo.CreateUserId = dto.CurrUserId;
  11295. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11296. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11297. if (add < 1) return Ok(JsonView(false));
  11298. }
  11299. else //update
  11300. {
  11301. ////验证编辑权限
  11302. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11303. //if (!isEdit) return Ok(JsonView(false, msg));
  11304. var upd = await _sqlSugar.Updateable(checkboxInfo)
  11305. .UpdateColumns(x => new
  11306. {
  11307. x.ChoiceOne,
  11308. x.ChoiceTwo,
  11309. x.SumJJC,
  11310. x.SumGWC,
  11311. x.SumTDC,
  11312. x.ChoiceThree,
  11313. x.ChoiceFour,
  11314. x.ChoiceFive,
  11315. x.ChoiceSix,
  11316. x.OtherExpenses_Checked
  11317. })
  11318. .Where(x => x.Id == id)
  11319. .ExecuteCommandAsync();
  11320. if (upd < 1) return Ok(JsonView(false));
  11321. }
  11322. return Ok(JsonView(new { parentId = id }));
  11323. }
  11324. /// <summary>
  11325. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  11326. /// </summary>
  11327. /// <returns></returns>
  11328. [HttpPost]
  11329. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11330. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  11331. {
  11332. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  11333. // if (provinceId < 1) provinceId = 122;
  11334. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  11335. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11336. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11337. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11338. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  11339. var checkboxInfo = new Grp_EnterExitCost()
  11340. {
  11341. Id = id,
  11342. //ProvinceId = provinceId,
  11343. DiId = diId,
  11344. CreateUserId = currUserId,
  11345. LastUpdateUserId = dto.CurrUserId,
  11346. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  11347. };
  11348. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  11349. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  11350. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  11351. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  11352. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  11353. if (id <= 0) //add
  11354. {
  11355. checkboxInfo.CreateUserId = dto.CurrUserId;
  11356. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11357. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  11358. if (add < 1) return Ok(JsonView(false));
  11359. }
  11360. else //update
  11361. {
  11362. ////验证编辑权限
  11363. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11364. //if (!isEdit) return Ok(JsonView(false, msg));
  11365. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  11366. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  11367. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  11368. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  11369. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  11370. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  11371. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  11372. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  11373. .Where(x => x.Id == id)
  11374. .ExecuteCommandAsync();
  11375. if (upd < 1) return Ok(JsonView(false));
  11376. }
  11377. return Ok(JsonView(new { parentId = id }));
  11378. }
  11379. /// <summary>
  11380. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  11381. /// </summary>
  11382. /// <returns></returns>
  11383. [HttpPost]
  11384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11385. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  11386. {
  11387. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11388. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11389. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11390. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11391. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11392. info.FirstItemRemark = dto.FirstItemRemark;
  11393. info.LastUpdateUserId = dto.CurrUserId;
  11394. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11395. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  11396. int id = dto.Id;
  11397. if (id <= 0) //add
  11398. {
  11399. info.CreateUserId = dto.CurrUserId;
  11400. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11401. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11402. if (add < 1) return Ok(JsonView(false));
  11403. id = add;
  11404. }
  11405. else //update
  11406. {
  11407. ////验证编辑权限
  11408. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11409. //if (!isEdit) return Ok(JsonView(false, msg));
  11410. var upd = await _sqlSugar.Updateable(info)
  11411. .UpdateColumns(x => new
  11412. {
  11413. x.ChoiceOne,
  11414. x.InsidePay,
  11415. x.VisaRemark,
  11416. x.Visa,
  11417. x.Service,
  11418. x.Safe,
  11419. x.Ticket,
  11420. x.HeSuan,
  11421. x.YiMiao,
  11422. x.FirstItemRemark,
  11423. x.LastUpdateUserId,
  11424. x.LastUpdateTime
  11425. })
  11426. .Where(x => x.Id == id)
  11427. .ExecuteCommandAsync();
  11428. if (upd < 1) return Ok(JsonView(false));
  11429. }
  11430. //消息通知
  11431. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11432. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  11433. }
  11434. /// <summary>
  11435. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  11436. /// </summary>
  11437. /// <returns></returns>
  11438. [HttpPost]
  11439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11440. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  11441. {
  11442. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11443. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11444. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11445. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11446. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  11447. info.DiId = dto.DiId;
  11448. //info.ProvinceId = dto.ProvinceId;
  11449. info.OutsideJJPay = dto.OutsideJJPay;
  11450. info.OutsideGWPay = dto.OutsideGWPay;
  11451. info.OutsideTDPay = dto.OutsideTDPay;
  11452. info.AirJJ = dto.AirJJ;
  11453. info.AirGW = dto.AirGW;
  11454. info.AirTD = dto.AirTD;
  11455. info.CityTranffic = dto.CityTranffic;
  11456. info.TwoItemRemark = dto.TwoItemRemark;
  11457. info.SumJJC = dto.ChoiceTwoJJ;
  11458. info.SumGWC = dto.ChoiceTwoGW;
  11459. info.SumTDC = dto.ChoiceTwoTD;
  11460. info.LastUpdateUserId = dto.CurrUserId;
  11461. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  11462. int id = dto.Id;
  11463. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  11464. if (id <= 0) //add i
  11465. {
  11466. info.CreateUserId = dto.CurrUserId;
  11467. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  11468. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  11469. if (addId <= 0) return Ok(JsonView(false));
  11470. id = addId;
  11471. }
  11472. else //update
  11473. {
  11474. ////验证编辑权限
  11475. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11476. //if (!isEdit) return Ok(JsonView(false, msg));
  11477. var upd = await _sqlSugar.Updateable(info)
  11478. .UpdateColumns(x => new
  11479. {
  11480. x.SumJJC,
  11481. x.OutsideJJPay,
  11482. x.SumGWC,
  11483. x.OutsideGWPay,
  11484. x.SumTDC,
  11485. x.OutsideTDPay,
  11486. x.AirJJ,
  11487. x.AirGW,
  11488. x.AirTD,
  11489. x.CityTranffic,
  11490. x.TwoItemRemark,
  11491. x.LastUpdateTime,
  11492. x.LastUpdateUserId
  11493. })
  11494. .Where(x => x.Id == id)
  11495. .ExecuteCommandAsync();
  11496. if (upd < 1) return Ok(JsonView(false));
  11497. }
  11498. jjcItemTotal = info.AirJJ + info.CityTranffic;
  11499. gwcItemTotal = info.AirGW + info.CityTranffic;
  11500. tdcItemTotal = info.AirTD + info.CityTranffic;
  11501. //消息通知
  11502. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11503. return Ok(JsonView(new
  11504. {
  11505. parentId = id,
  11506. choiceTwoJJ = dto.ChoiceTwoJJ,
  11507. jjcItemTotal = jjcItemTotal,
  11508. choiceTwoGW = dto.ChoiceTwoGW,
  11509. gwcItemTotal = gwcItemTotal,
  11510. choiceTwoTD = dto.ChoiceTwoTD,
  11511. tdcItemTotal = tdcItemTotal
  11512. }));
  11513. }
  11514. /// <summary>
  11515. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  11516. /// </summary>
  11517. /// <returns></returns>
  11518. [HttpPost]
  11519. [ApiExplorerSettings(IgnoreApi = true)]
  11520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11521. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  11522. {
  11523. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11524. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11525. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11526. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  11527. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  11528. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11529. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  11530. var infos = infos1.Select(x => new Grp_DayAndCost
  11531. {
  11532. Id = x.Id,
  11533. DiId = dto.DiId,
  11534. Type = dto.FeeType,
  11535. Days = x.Days,
  11536. NationalTravelFeeId = x.NationalTravelFeeId,
  11537. Cost = x.Cost,
  11538. Currency = x.Currency,
  11539. SubTotal = x.SubTotal,
  11540. CreateUserId = dto.CurrUserId
  11541. })
  11542. .ToList();
  11543. var adds = infos.Where(x => x.Id <= 0).ToList();
  11544. var upds = infos.Where(x => x.Id > 0).ToList();
  11545. if (adds.Count > 0)
  11546. {
  11547. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11548. if (add < 1) return Ok(JsonView(false));
  11549. }
  11550. if (upds.Count > 0)
  11551. {
  11552. var upd = await _sqlSugar.Updateable(adds)
  11553. .UpdateColumns(x => new
  11554. {
  11555. x.Days,
  11556. x.NationalTravelFeeId,
  11557. x.Cost,
  11558. x.Currency,
  11559. x.SubTotal
  11560. })
  11561. .WhereColumns(x => new { x.Id })
  11562. .ExecuteCommandAsync();
  11563. if (upd < 1) return Ok(JsonView(false));
  11564. }
  11565. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  11566. //消息通知
  11567. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11568. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11569. return Ok(JsonView(new { itemTotal = itemTotal }));
  11570. }
  11571. /// <summary>
  11572. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  11573. /// </summary>
  11574. /// <returns></returns>
  11575. [HttpPost]
  11576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11577. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  11578. {
  11579. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  11580. int subId = dto.SubId, feeType = dto.FeeType;
  11581. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11582. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11583. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11584. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  11585. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  11586. subInfo.Id = subId;
  11587. subInfo.DiId = dto.DiId;
  11588. if (feeType == 3) subInfo.Type = 1;
  11589. else if (feeType == 4) subInfo.Type = 2;
  11590. else if (feeType == 5) subInfo.Type = 3;
  11591. else if (feeType == 6) subInfo.Type = 4;
  11592. subInfo.CreateUserId = dto.CurrUserId;
  11593. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  11594. if (parentId < 1) return Ok(JsonView(false));
  11595. //子表op
  11596. if (subId < 1)
  11597. {
  11598. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11599. if (subAdd < 1) return Ok(JsonView(false));
  11600. }
  11601. else
  11602. {
  11603. ////验证编辑权限
  11604. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  11605. //if (!isEdit) return Ok(JsonView(false, msg));
  11606. var subUpd = await _sqlSugar.Updateable(subInfo)
  11607. .UpdateColumns(x => new
  11608. {
  11609. x.Days,
  11610. x.NationalTravelFeeId,
  11611. x.Cost,
  11612. x.Currency,
  11613. x.SubTotal
  11614. })
  11615. .WhereColumns(x => new { x.Id })
  11616. .ExecuteCommandAsync();
  11617. if (subUpd < 1) return Ok(JsonView(false));
  11618. }
  11619. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  11620. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  11621. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11622. }
  11623. /// <summary>
  11624. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  11625. /// </summary>
  11626. /// <returns></returns>
  11627. [HttpPost]
  11628. [ApiExplorerSettings(IgnoreApi = true)]
  11629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11630. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  11631. {
  11632. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11633. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11634. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11635. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  11636. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  11637. {
  11638. Id = x.Id,
  11639. Diid = dto.DiId,
  11640. SetDataId = x.SetDataId,
  11641. Index = x.Index,
  11642. Cost = x.Cost,
  11643. Currency = x.Currency,
  11644. SubTotal = x.SubTotal,
  11645. CreateUserId = dto.CurrUserId,
  11646. Remark = x.Remark
  11647. }).ToList();
  11648. var adds = infos.Where(x => x.Id <= 0).ToList();
  11649. var upds = infos.Where(x => x.Id > 0).ToList();
  11650. if (adds.Count > 0)
  11651. {
  11652. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  11653. if (add < 1) return Ok(JsonView(false));
  11654. }
  11655. if (upds.Count > 0)
  11656. {
  11657. var upd = await _sqlSugar.Updateable(adds)
  11658. .UpdateColumns(x => new
  11659. {
  11660. x.Index,
  11661. x.SetDataId,
  11662. x.Cost,
  11663. x.Currency,
  11664. x.SubTotal,
  11665. x.Remark
  11666. })
  11667. .WhereColumns(x => new { x.Id })
  11668. .ExecuteCommandAsync();
  11669. if (upd < 1) return Ok(JsonView(false));
  11670. }
  11671. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  11672. //消息通知
  11673. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  11674. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  11675. return Ok(JsonView(new { itemTotal = itemTotal }));
  11676. }
  11677. /// <summary>
  11678. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  11679. /// </summary>
  11680. /// <returns></returns>
  11681. [HttpPost]
  11682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11683. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  11684. {
  11685. int subId = dto.SubId;
  11686. int diId = dto.Diid;
  11687. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11688. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  11689. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11690. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  11691. subInfo.Id = subId;
  11692. subInfo.Diid = dto.Diid;
  11693. subInfo.CreateUserId = dto.CurrUserId;
  11694. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  11695. if (parentId < 1) return Ok(JsonView(false));
  11696. #region 子表op
  11697. if (subId < 1)//add
  11698. {
  11699. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  11700. if (subAdd < 1) return Ok(JsonView(false));
  11701. }
  11702. else //upd
  11703. {
  11704. ////验证编辑权限
  11705. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  11706. //if (!isEdit) return Ok(JsonView(false, msg));
  11707. var subUpd = await _sqlSugar.Updateable(subInfo)
  11708. .UpdateColumns(x => new
  11709. {
  11710. x.Index,
  11711. x.SetDataId,
  11712. x.Cost,
  11713. x.Currency,
  11714. x.SubTotal,
  11715. x.Remark
  11716. })
  11717. .WhereColumns(x => new { x.Id })
  11718. .ExecuteCommandAsync();
  11719. if (subUpd < 1) return Ok(JsonView(false));
  11720. }
  11721. #endregion
  11722. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  11723. //消息通知
  11724. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  11725. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  11726. }
  11727. /// <summary>
  11728. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  11729. /// </summary>
  11730. /// <returns></returns>
  11731. [HttpPost]
  11732. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11733. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  11734. {
  11735. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  11736. if (data.Code != 0)
  11737. {
  11738. return Ok(JsonView(false, data.Msg));
  11739. }
  11740. return Ok(JsonView(true, "操作成功!", data.Data));
  11741. }
  11742. /// <summary>
  11743. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  11744. /// </summary>
  11745. /// <param name="dto"></param>
  11746. /// <returns></returns>
  11747. [HttpPost]
  11748. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  11749. {
  11750. var data = new Grp_DayOtherPrice()
  11751. {
  11752. Id = dto.Id,
  11753. IsDel = 1,
  11754. DeleteUserId = dto.DeleteUserId,
  11755. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11756. };
  11757. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11758. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  11759. return Ok(JsonView(false, "删除失败!"));
  11760. }
  11761. #endregion
  11762. #endregion
  11763. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  11764. /// <summary>
  11765. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  11766. /// </summary>
  11767. /// <returns></returns>
  11768. [HttpGet]
  11769. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11770. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  11771. {
  11772. var provData = await _groupRepository.ProvinceBasicSource();
  11773. return Ok(JsonView(true, "查询成功!", provData));
  11774. }
  11775. /// <summary>
  11776. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  11777. /// </summary>
  11778. /// <returns></returns>
  11779. [HttpPost]
  11780. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11781. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  11782. {
  11783. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11784. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11785. RefAsync<int> total = 0;
  11786. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11787. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  11788. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  11789. .Select(x => new
  11790. {
  11791. Id = x.Id,
  11792. DraftName = x.DraftName,
  11793. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  11794. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  11795. .Any()
  11796. })
  11797. .OrderByDescending(x => x.Id)
  11798. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11799. return Ok(JsonView(true, "查询成功!", data, total));
  11800. }
  11801. /// <summary>
  11802. /// 出入境费用-草稿 移动端
  11803. /// 获取币种基础数据(含逻辑处理)
  11804. /// </summary>
  11805. /// <returns></returns>
  11806. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  11807. {
  11808. return await GeneralMethod.EnterExitCostInitRate();
  11809. }
  11810. /// <summary>
  11811. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  11812. /// </summary>
  11813. /// <returns></returns>
  11814. [HttpPost]
  11815. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11816. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  11817. {
  11818. //验证城市归属并给默认值
  11819. int provinceId = dto.ProvinceId;
  11820. if (provinceId < 1) provinceId = 122;
  11821. var dataSource = await _sqlSugar
  11822. .Queryable<Sys_SetData>()
  11823. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  11824. .ToListAsync();
  11825. //三公费用-Word明细类型
  11826. var wordTypeData = dataSource.Where(it => it.STid == 72)
  11827. .Select(x => new SetDataInfoView
  11828. {
  11829. Id = x.Id,
  11830. Name = x.Name,
  11831. Remark = x.Remark
  11832. })
  11833. .ToList();
  11834. //三公费用-Excel明细类型
  11835. var excelTypeData = dataSource.Where(it => it.STid == 73)
  11836. .Select(x => new SetDataInfoView
  11837. {
  11838. Id = x.Id,
  11839. Name = x.Name,
  11840. Remark = x.Remark
  11841. })
  11842. .ToList();
  11843. //默认币种显示
  11844. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  11845. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  11846. return Ok(JsonView(true, "查询成功!", new
  11847. {
  11848. WordTypeData = wordTypeData,
  11849. ExcelTypeData = excelTypeData,
  11850. CurrencyInit = _currencyInfos,
  11851. viewPermissionData = viewPermissionData
  11852. }));
  11853. }
  11854. /// <summary>
  11855. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  11856. /// </summary>
  11857. /// <returns></returns>
  11858. [HttpPost]
  11859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11860. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  11861. {
  11862. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11863. RefAsync<int> total = 0;
  11864. int diId = 0;
  11865. var status = int.TryParse(dto.GroupName, out diId);
  11866. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  11867. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  11868. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  11869. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  11870. .OrderByDescending(x => x.VisitStartDate)
  11871. .Select(x => new
  11872. {
  11873. Id = x.Id,
  11874. GroupName = x.TeamName
  11875. })
  11876. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11877. return Ok(JsonView(true, "查询成功!", data, total));
  11878. }
  11879. /// <summary>
  11880. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  11881. /// </summary>
  11882. /// <returns></returns>
  11883. [HttpPost]
  11884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11885. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  11886. {
  11887. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11888. RefAsync<int> total = 0;
  11889. var data = await _sqlSugar.Queryable<Sys_SetData>()
  11890. .Where(x => x.IsDel == 0 && x.STid == 66)
  11891. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  11892. .Select(x => new
  11893. {
  11894. id = x.Id,
  11895. name = x.Name,
  11896. remark = x.Remark,
  11897. })
  11898. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11899. return Ok(JsonView(true, "查询成功!", data, total));
  11900. }
  11901. /// <summary>
  11902. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  11903. /// </summary>
  11904. /// <returns></returns>
  11905. [HttpPost]
  11906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11907. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  11908. {
  11909. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11910. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11911. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  11912. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  11913. var groupOtherRateData = groupRateData.TeamRates;
  11914. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  11915. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  11916. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  11917. groupOtherRateData = groupOtherRateData
  11918. .Select(x => new TeamRateDescAddCurrencyIdView
  11919. {
  11920. CurrencyId = x.CurrencyId,
  11921. CurrencyName = x.CurrencyName,
  11922. CurrencyCode = x.CurrencyCode,
  11923. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  11924. }).ToList();
  11925. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  11926. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  11927. }
  11928. /// <summary>
  11929. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  11930. /// </summary>
  11931. /// <returns></returns>
  11932. [HttpPost]
  11933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11934. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  11935. {
  11936. int portType = dto.PortType;
  11937. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  11938. var tipsData = new List<int>() { 1, 2, 3 };
  11939. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  11940. if (dto.TipsType == 1)
  11941. {
  11942. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  11943. }
  11944. else if (dto.TipsType == 2)
  11945. {
  11946. if (portType == 2)
  11947. {
  11948. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  11949. }
  11950. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11951. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11952. .Select(x => x.NationalTravelFeeId)
  11953. .Distinct()
  11954. .ToListAsync();
  11955. if (portType == 2)
  11956. {
  11957. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11958. }
  11959. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11960. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11961. .Select(x => x.Country)
  11962. .Distinct()
  11963. .ToArrayAsync();
  11964. if (portType == 2)
  11965. {
  11966. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11967. }
  11968. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11969. return Ok(JsonView(true, "查询成功!", new
  11970. {
  11971. totalAmt = totalAmt,
  11972. remark = remark
  11973. }));
  11974. }
  11975. else if (dto.TipsType == 3)
  11976. {
  11977. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  11978. }
  11979. return Ok(JsonView(false));
  11980. }
  11981. /// <summary>
  11982. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  11983. /// </summary>
  11984. /// <returns></returns>
  11985. [HttpPost]
  11986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11987. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  11988. {
  11989. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  11990. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11991. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  11992. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  11993. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  11994. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  11995. var info = new Grp_EnterExitCostDraft()
  11996. {
  11997. ProvinceId = dto.ProvinceId,
  11998. DraftName = dto.DraftName,
  11999. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  12000. CreateUserId = dto.CurrUserId
  12001. };
  12002. _sqlSugar.BeginTran();
  12003. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12004. if (draftId < 1)
  12005. {
  12006. _sqlSugar.RollbackTran();
  12007. return Ok(JsonView(false, "草稿创建失败!"));
  12008. }
  12009. //添加默认权限
  12010. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  12011. _sqlSugar.CommitTran();
  12012. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  12013. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  12014. mobileInfo.Id = draftId;
  12015. mobileInfo.DraftName = dto.DraftName;
  12016. mobileInfo.Currencys = rateInfos;
  12017. mobileInfo.IsAssignPerm = assignPerm;
  12018. return Ok(JsonView(mobileInfo));
  12019. }
  12020. /// <summary>
  12021. /// 出入境费用-草稿-移动端 查看编辑提示消息
  12022. /// </summary>
  12023. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  12024. /// <summary>
  12025. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  12026. /// </summary>
  12027. /// <returns></returns>
  12028. [HttpPost]
  12029. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12030. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  12031. {
  12032. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12033. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12034. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  12035. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  12036. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  12037. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  12038. //验证查看编辑权限
  12039. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12040. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12041. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  12042. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  12043. mobileInfo.IsAssignPerm = assignPerm;
  12044. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12045. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12046. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12047. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  12048. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12049. {
  12050. ParentId = dac.ParentId,
  12051. SubId = dac.Id,
  12052. Type = dac.Type,
  12053. Days = dac.Days,
  12054. NationalTravelFeeId = dac.NationalTravelFeeId,
  12055. Arae = $"{ntf.Country}-{ntf.City}",
  12056. Cost = dac.Cost,
  12057. Currency = dac.Currency,
  12058. CurrencyName = sd.Name,
  12059. SubTotal = dac.SubTotal,
  12060. })
  12061. .ToList();
  12062. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  12063. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  12064. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  12065. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  12066. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  12067. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  12068. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  12069. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  12070. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  12071. //其他款项
  12072. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12073. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12074. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12075. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12076. .OrderBy((dop, sd1, sd2) => dop.Index)
  12077. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  12078. {
  12079. ParentId = dop.ParentId,
  12080. SubId = dop.Id,
  12081. Index = dop.Index,
  12082. SetDataId = dop.SetDataId,
  12083. SetDataName = sd1.Name,
  12084. Cost = dop.Cost,
  12085. Currency = dop.Currency,
  12086. CurrencyName = sd2.Remark,
  12087. SubTotal = dop.SubTotal,
  12088. Remark = dop.Remark,
  12089. })
  12090. .ToArray();
  12091. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  12092. return Ok(mobileInfo);
  12093. }
  12094. /// <summary>
  12095. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  12096. /// </summary>
  12097. /// <returns></returns>
  12098. [HttpPost]
  12099. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12100. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  12101. {
  12102. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12103. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12104. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12105. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  12106. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  12107. //验证查看编辑权限
  12108. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12109. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12110. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  12111. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  12112. var subType = dto.SubType;
  12113. if (subType == 1) //1:境内费用
  12114. {
  12115. var oneData = new ChoiceOneMobileSubInfoView()
  12116. {
  12117. Id = eecInfo.Id,
  12118. ChoiceOne = eecInfo.ChoiceOne,
  12119. ChoiceOneTotalCost = eecInfo.InsidePay,
  12120. Visa = eecInfo.Visa,
  12121. VisaRemark = eecInfo.VisaRemark,
  12122. YiMiao = eecInfo.YiMiao,
  12123. HeSuan = eecInfo.HeSuan,
  12124. Service = eecInfo.Service,
  12125. Ticket = eecInfo.Ticket,
  12126. Safe = eecInfo.Safe,
  12127. FirstItemRemark = eecInfo.FirstItemRemark
  12128. };
  12129. return Ok(JsonView(oneData));
  12130. }
  12131. else if (subType == 2) //2:国际旅费
  12132. {
  12133. var twoData = new ChoiceTwoMobileSubInfoView()
  12134. {
  12135. Id = eecInfo.Id,
  12136. ChoiceTwoJJ = eecInfo.SumJJC,
  12137. OutsideJJPay = eecInfo.OutsideJJPay,
  12138. ChoiceTwoGW = eecInfo.SumGWC,
  12139. OutsideGWPay = eecInfo.OutsideGWPay,
  12140. ChoiceTwoTD = eecInfo.SumTDC,
  12141. OutsideTDPay = eecInfo.OutsideTDPay,
  12142. AirJJ = eecInfo.AirJJ,
  12143. AirGW = eecInfo.AirGW,
  12144. AirTD = eecInfo.AirTD,
  12145. CityTranffic = eecInfo.CityTranffic,
  12146. TwoItemRemark = eecInfo.TwoItemRemark
  12147. };
  12148. return Ok(JsonView(twoData));
  12149. }
  12150. else if (subType == 3) //3:住宿费
  12151. {
  12152. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12153. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12154. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12155. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  12156. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12157. {
  12158. ParentId = dac.ParentId,
  12159. SubId = dac.Id,
  12160. Type = dac.Type,
  12161. Days = dac.Days,
  12162. NationalTravelFeeId = dac.NationalTravelFeeId,
  12163. Arae = $"{ntf.Country}-{ntf.City}",
  12164. Cost = dac.Cost,
  12165. Currency = dac.Currency,
  12166. CurrencyName = sd.Name,
  12167. SubTotal = dac.SubTotal,
  12168. })
  12169. .ToArray();
  12170. var data = new ChoiceDraftMobileSubInfo3To6View()
  12171. {
  12172. ParentId = eecInfo.Id,
  12173. Choice = eecInfo.ChoiceThree,
  12174. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12175. Details = dayAndCostDatas
  12176. };
  12177. return Ok(JsonView(data));
  12178. }
  12179. else if (subType == 4) //4:伙食费
  12180. {
  12181. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12182. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12183. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12184. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  12185. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12186. {
  12187. ParentId = dac.ParentId,
  12188. SubId = dac.Id,
  12189. Type = dac.Type,
  12190. Days = dac.Days,
  12191. NationalTravelFeeId = dac.NationalTravelFeeId,
  12192. Arae = $"{ntf.Country}-{ntf.City}",
  12193. Cost = dac.Cost,
  12194. Currency = dac.Currency,
  12195. CurrencyName = sd.Name,
  12196. SubTotal = dac.SubTotal,
  12197. })
  12198. .ToArray();
  12199. var data = new ChoiceDraftMobileSubInfo3To6View()
  12200. {
  12201. ParentId = eecInfo.Id,
  12202. Choice = eecInfo.ChoiceFour,
  12203. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12204. Details = dayAndCostDatas
  12205. };
  12206. return Ok(JsonView(data));
  12207. }
  12208. else if (subType == 5) //5:公杂费
  12209. {
  12210. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12211. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12212. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12213. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  12214. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12215. {
  12216. ParentId = dac.ParentId,
  12217. SubId = dac.Id,
  12218. Type = dac.Type,
  12219. Days = dac.Days,
  12220. NationalTravelFeeId = dac.NationalTravelFeeId,
  12221. Arae = $"{ntf.Country}-{ntf.City}",
  12222. Cost = dac.Cost,
  12223. Currency = dac.Currency,
  12224. CurrencyName = sd.Name,
  12225. SubTotal = dac.SubTotal,
  12226. })
  12227. .ToArray();
  12228. var data = new ChoiceDraftMobileSubInfo3To6View()
  12229. {
  12230. ParentId = eecInfo.Id,
  12231. Choice = eecInfo.ChoiceFive,
  12232. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12233. Details = dayAndCostDatas
  12234. };
  12235. return Ok(JsonView(data));
  12236. }
  12237. else if (subType == 6) //6:培训费
  12238. {
  12239. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12240. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12241. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12242. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  12243. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  12244. {
  12245. ParentId = dac.ParentId,
  12246. SubId = dac.Id,
  12247. Type = dac.Type,
  12248. Days = dac.Days,
  12249. NationalTravelFeeId = dac.NationalTravelFeeId,
  12250. Arae = $"{ntf.Country}-{ntf.City}",
  12251. Cost = dac.Cost,
  12252. Currency = dac.Currency,
  12253. CurrencyName = sd.Name,
  12254. SubTotal = dac.SubTotal,
  12255. })
  12256. .ToArray();
  12257. var data = new ChoiceDraftMobileSubInfo3To6View()
  12258. {
  12259. ParentId = eecInfo.Id,
  12260. Choice = eecInfo.ChoiceSix,
  12261. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12262. Details = dayAndCostDatas
  12263. };
  12264. return Ok(JsonView(data));
  12265. }
  12266. else if (subType == 7) //7:其他
  12267. {
  12268. //其他款项
  12269. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12270. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12271. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12272. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12273. .OrderBy((dop, sd1, sd2) => dop.Index)
  12274. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  12275. {
  12276. ParentId = dop.ParentId,
  12277. SubId = dop.Id,
  12278. Index = dop.Index,
  12279. SetDataId = dop.SetDataId,
  12280. SetDataName = sd1.Name,
  12281. Cost = dop.Cost,
  12282. Currency = dop.Currency,
  12283. CurrencyName = sd2.Name,
  12284. SubTotal = dop.SubTotal,
  12285. Remark = dop.Remark,
  12286. })
  12287. .ToArray();
  12288. var data = new ChoiceSevenDraftMobileSubInfoView()
  12289. {
  12290. ParentId = eecInfo.Id,
  12291. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  12292. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  12293. Details = otherData
  12294. };
  12295. return Ok(JsonView(data));
  12296. }
  12297. return Ok(JsonView(false));
  12298. }
  12299. #region op
  12300. ///// <summary>
  12301. ///// 移动端更新费用消息通知
  12302. ///// </summary>
  12303. ///// <param name="draftId"></param>
  12304. ///// <param name="id"></param>
  12305. ///// <param name="currUserId"></param>
  12306. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  12307. //{
  12308. // try
  12309. // {
  12310. // ////生成默认文件pdf并且通知人员
  12311. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12312. // //{
  12313. // // DiId = draftId,
  12314. // // ExportType = 1,
  12315. // // SubTypeId = 1005
  12316. // //}, "pdf");
  12317. // ////发送通知
  12318. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  12319. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  12320. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  12321. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  12322. // ////汇率信息记录
  12323. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  12324. // }
  12325. // catch (Exception ex)
  12326. // {
  12327. // //记录日志
  12328. // throw;
  12329. // }
  12330. //}
  12331. /// <summary>
  12332. /// 验证出入境费用数据是否存在
  12333. /// 不存在添加
  12334. /// </summary>
  12335. /// <param name="draftId"></param>
  12336. /// <param name="currUserId"></param>
  12337. /// <returns></returns>
  12338. /// <exception cref="CustomException"></exception>
  12339. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  12340. {
  12341. var parentId = 0;
  12342. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  12343. if (info != null) parentId = info.Id;
  12344. else
  12345. {
  12346. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  12347. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  12348. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  12349. parentId = addId;
  12350. }
  12351. return parentId;
  12352. }
  12353. /// <summary>
  12354. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  12355. /// </summary>
  12356. /// <returns></returns>
  12357. [HttpPost]
  12358. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12359. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  12360. {
  12361. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12362. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12363. //验证查看权限
  12364. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12365. if (!isView) return Ok(JsonView(false, _viewPermStr));
  12366. var userIds = await _sqlSugar
  12367. .Queryable<Grp_EnterExitCostDraftPermission>()
  12368. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  12369. .Select(x => x.UserId)
  12370. .ToArrayAsync();
  12371. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  12372. var perUsersView = new List<dynamic>();
  12373. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  12374. var viewPermissionData = new List<PermissionViewUserview>();
  12375. if (feeBasePerm.Any())
  12376. {
  12377. foreach (var item in feeBasePerm)
  12378. {
  12379. if (item.Users.Any())
  12380. {
  12381. viewPermissionData.AddRange(item.Users);
  12382. }
  12383. }
  12384. }
  12385. foreach (var item in perUsers)
  12386. {
  12387. bool isView1 = false;
  12388. if (userIds.Any(x => x == item.Id)) isView1 = true;
  12389. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  12390. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  12391. }
  12392. return Ok(JsonView(perUsersView));
  12393. }
  12394. /// <summary>
  12395. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  12396. /// </summary>
  12397. /// <returns></returns>
  12398. [HttpPost]
  12399. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12400. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  12401. {
  12402. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12403. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12404. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  12405. //验证查看编辑权限
  12406. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12407. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12408. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  12409. foreach (var userId in dto.UserIds)
  12410. {
  12411. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  12412. }
  12413. if (permissions.Any())
  12414. {
  12415. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  12416. {
  12417. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  12418. }
  12419. _sqlSugar.BeginTran();
  12420. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  12421. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  12422. if (result < 1)
  12423. {
  12424. _sqlSugar.RollbackTran();
  12425. return Ok(JsonView(false));
  12426. }
  12427. _sqlSugar.CommitTran();
  12428. return Ok(JsonView(true));
  12429. }
  12430. return Ok(JsonView(false));
  12431. }
  12432. /// <summary>
  12433. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  12434. /// </summary>
  12435. /// <returns></returns>
  12436. [HttpPost]
  12437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12438. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  12439. {
  12440. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12441. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12442. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12443. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  12444. int id = dto.DraftId;
  12445. if (id <= 0) //add
  12446. {
  12447. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12448. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12449. if (add < 1) return Ok(JsonView(false));
  12450. id = add;
  12451. }
  12452. else //update
  12453. {
  12454. //验证查看编辑权限
  12455. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12456. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12457. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12458. if (upd < 1) return Ok(JsonView(false));
  12459. }
  12460. return Ok(JsonView(new { parentId = id }));
  12461. }
  12462. /// <summary>
  12463. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  12464. /// </summary>
  12465. /// <returns></returns>
  12466. [HttpPost]
  12467. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12468. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  12469. {
  12470. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12471. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12472. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12473. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  12474. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  12475. int id = dto.DraftId;
  12476. if (id <= 0) //add
  12477. {
  12478. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12479. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  12480. if (add < 1) return Ok(JsonView(false));
  12481. id = add;
  12482. }
  12483. else //update
  12484. {
  12485. //验证查看编辑权限
  12486. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  12487. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  12488. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  12489. if (upd < 1) return Ok(JsonView(false));
  12490. }
  12491. #region 汇率变更时更改币种相关费用
  12492. var opDayCosts = new List<Grp_DayAndCostDraft>();
  12493. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  12494. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  12495. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  12496. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  12497. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  12498. .Select((dac, sd) => new
  12499. {
  12500. dac.Id,
  12501. dac.ParentId,
  12502. CurrencyCode = sd.Name,
  12503. dac.Cost
  12504. })
  12505. .ToList();
  12506. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  12507. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  12508. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  12509. .Select((dop, sd) => new
  12510. {
  12511. dop.Id,
  12512. dop.ParentId,
  12513. CurrencyCode = sd.Name,
  12514. dop.Cost
  12515. })
  12516. .ToList();
  12517. if (dayCosts.Count > 0)
  12518. {
  12519. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12520. foreach (var dc in new_dayCosts)
  12521. {
  12522. var thisCurrency = dc.Key.ToUpper();
  12523. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12524. if (thisRate == 0.00M) continue;
  12525. foreach (var dcSub in dc)
  12526. {
  12527. opDayCosts.Add(new Grp_DayAndCostDraft()
  12528. {
  12529. Id = dcSub.Id,
  12530. ParentId = dcSub.ParentId,
  12531. Cost = dcSub.Cost,
  12532. SubTotal = dcSub.Cost * thisRate,
  12533. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  12534. });
  12535. }
  12536. }
  12537. if (opDayCosts.Count > 0)
  12538. {
  12539. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12540. }
  12541. }
  12542. if (dayOtherCosts.Count > 0)
  12543. {
  12544. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  12545. foreach (var dc in new_dayOtherCosts)
  12546. {
  12547. var thisCurrency = dc.Key.ToUpper();
  12548. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  12549. if (thisRate == 0.00M) continue;
  12550. foreach (var dcSub in dc)
  12551. {
  12552. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  12553. {
  12554. Id = dcSub.Id,
  12555. ParentId = dcSub.ParentId,
  12556. Cost = dcSub.Cost,
  12557. SubTotal = dcSub.Cost * thisRate,
  12558. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  12559. });
  12560. }
  12561. }
  12562. if (opDayOtherCosts.Count > 0)
  12563. {
  12564. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  12565. }
  12566. }
  12567. #endregion
  12568. ////消息通知
  12569. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12570. ////汇率信息记录
  12571. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  12572. return Ok(JsonView(new { parentId = id }));
  12573. }
  12574. /// <summary>
  12575. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  12576. /// </summary>
  12577. /// <returns></returns>
  12578. [HttpPost]
  12579. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12580. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  12581. {
  12582. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12583. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  12584. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12585. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12586. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12587. int id = dto.DraftId;
  12588. if (id <= 0) //add
  12589. {
  12590. checkboxInfo.ProvinceId = dto.ProvinceId;
  12591. checkboxInfo.CreateUserId = dto.CurrUserId;
  12592. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  12593. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12594. if (add < 1) return Ok(JsonView(false));
  12595. }
  12596. else //update
  12597. {
  12598. var upd = await _sqlSugar.Updateable(checkboxInfo)
  12599. .UpdateColumns(x => new
  12600. {
  12601. x.ChoiceOne,
  12602. x.ChoiceTwo,
  12603. x.SumJJC,
  12604. x.SumGWC,
  12605. x.SumTDC,
  12606. x.ChoiceThree,
  12607. x.ChoiceFour,
  12608. x.ChoiceFive,
  12609. x.ChoiceSix,
  12610. x.OtherExpenses_Checked
  12611. })
  12612. .Where(x => x.Id == id)
  12613. .ExecuteCommandAsync();
  12614. if (upd < 1) return Ok(JsonView(false));
  12615. }
  12616. return Ok(JsonView(new { parentId = id }));
  12617. }
  12618. /// <summary>
  12619. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  12620. /// </summary>
  12621. /// <returns></returns>
  12622. [HttpPost]
  12623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12624. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  12625. {
  12626. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  12627. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  12628. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12629. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12630. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12631. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  12632. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12633. var checkboxInfo = new Grp_EnterExitCostDraft()
  12634. {
  12635. Id = draftId,
  12636. ProvinceId = dto.ProvinceId,
  12637. CreateUserId = currUserId
  12638. };
  12639. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  12640. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  12641. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  12642. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  12643. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  12644. if (draftId <= 0) //add
  12645. {
  12646. checkboxInfo.CreateUserId = dto.CurrUserId;
  12647. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12648. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  12649. if (add < 1) return Ok(JsonView(false));
  12650. }
  12651. else //update
  12652. {
  12653. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  12654. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  12655. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  12656. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  12657. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  12658. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  12659. .Where(x => x.Id == draftId)
  12660. .ExecuteCommandAsync();
  12661. if (upd < 1) return Ok(JsonView(false));
  12662. }
  12663. return Ok(JsonView(new { parentId = draftId }));
  12664. }
  12665. /// <summary>
  12666. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  12667. /// </summary>
  12668. /// <returns></returns>
  12669. [HttpPost]
  12670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12671. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  12672. {
  12673. int id = dto.DraftId, currUserId = dto.CurrUserId;
  12674. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12675. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12676. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12677. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12678. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12679. info.ProvinceId = dto.ProvinceId;
  12680. info.FirstItemRemark = dto.FirstItemRemark;
  12681. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  12682. if (id <= 0) //add
  12683. {
  12684. info.CreateUserId = dto.CurrUserId;
  12685. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12686. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12687. if (add < 1) return Ok(JsonView(false));
  12688. id = add;
  12689. }
  12690. else //update
  12691. {
  12692. var upd = await _sqlSugar.Updateable(info)
  12693. .UpdateColumns(x => new
  12694. {
  12695. x.ChoiceOne,
  12696. x.InsidePay,
  12697. x.VisaRemark,
  12698. x.Visa,
  12699. x.Service,
  12700. x.Safe,
  12701. x.Ticket,
  12702. x.HeSuan,
  12703. x.YiMiao,
  12704. x.FirstItemRemark
  12705. })
  12706. .Where(x => x.Id == id)
  12707. .ExecuteCommandAsync();
  12708. if (upd < 1) return Ok(JsonView(false));
  12709. }
  12710. ////消息通知
  12711. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12712. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  12713. }
  12714. /// <summary>
  12715. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  12716. /// </summary>
  12717. /// <returns></returns>
  12718. [HttpPost]
  12719. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12720. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  12721. {
  12722. int id = dto.DraftId;
  12723. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12724. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  12725. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12726. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  12727. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  12728. info.ProvinceId = dto.ProvinceId;
  12729. info.OutsideJJPay = dto.OutsideJJPay;
  12730. info.OutsideGWPay = dto.OutsideGWPay;
  12731. info.OutsideTDPay = dto.OutsideTDPay;
  12732. info.AirJJ = dto.AirJJ;
  12733. info.AirGW = dto.AirGW;
  12734. info.AirTD = dto.AirTD;
  12735. info.CityTranffic = dto.CityTranffic;
  12736. info.TwoItemRemark = dto.TwoItemRemark;
  12737. info.SumJJC = dto.ChoiceTwoJJ;
  12738. info.SumGWC = dto.ChoiceTwoGW;
  12739. info.SumTDC = dto.ChoiceTwoTD;
  12740. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  12741. if (id <= 0) //add
  12742. {
  12743. info.CreateUserId = dto.CurrUserId;
  12744. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  12745. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  12746. if (addId <= 0) return Ok(JsonView(false));
  12747. id = addId;
  12748. }
  12749. else //update
  12750. {
  12751. var upd = await _sqlSugar.Updateable(info)
  12752. .UpdateColumns(x => new
  12753. {
  12754. x.SumJJC,
  12755. x.OutsideJJPay,
  12756. x.SumGWC,
  12757. x.OutsideGWPay,
  12758. x.SumTDC,
  12759. x.OutsideTDPay,
  12760. x.AirJJ,
  12761. x.AirGW,
  12762. x.AirTD,
  12763. x.CityTranffic,
  12764. x.TwoItemRemark
  12765. })
  12766. .Where(x => x.Id == id)
  12767. .ExecuteCommandAsync();
  12768. if (upd < 1) return Ok(JsonView(false));
  12769. }
  12770. jjcItemTotal = info.AirJJ + info.CityTranffic;
  12771. gwcItemTotal = info.AirGW + info.CityTranffic;
  12772. tdcItemTotal = info.AirTD + info.CityTranffic;
  12773. ////消息通知
  12774. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12775. return Ok(JsonView(new
  12776. {
  12777. parentId = id,
  12778. choiceTwoJJ = dto.ChoiceTwoJJ,
  12779. jjcItemTotal = jjcItemTotal,
  12780. choiceTwoGW = dto.ChoiceTwoGW,
  12781. gwcItemTotal = gwcItemTotal,
  12782. choiceTwoTD = dto.ChoiceTwoTD,
  12783. tdcItemTotal = tdcItemTotal
  12784. }));
  12785. }
  12786. /// <summary>
  12787. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  12788. /// </summary>
  12789. /// <returns></returns>
  12790. [HttpPost]
  12791. [ApiExplorerSettings(IgnoreApi = true)]
  12792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12793. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  12794. {
  12795. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12796. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12797. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12798. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  12799. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  12800. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12801. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  12802. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  12803. {
  12804. Id = x.Id,
  12805. ParentId = dto.DraftId,
  12806. Type = dto.FeeType,
  12807. Days = x.Days,
  12808. NationalTravelFeeId = x.NationalTravelFeeId,
  12809. Cost = x.Cost,
  12810. Currency = x.Currency,
  12811. SubTotal = x.SubTotal,
  12812. CreateUserId = dto.CurrUserId
  12813. })
  12814. .ToList();
  12815. var adds = infos.Where(x => x.Id <= 0).ToList();
  12816. var upds = infos.Where(x => x.Id > 0).ToList();
  12817. if (adds.Count > 0)
  12818. {
  12819. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12820. if (add < 1) return Ok(JsonView(false));
  12821. }
  12822. if (upds.Count > 0)
  12823. {
  12824. var upd = await _sqlSugar.Updateable(adds)
  12825. .UpdateColumns(x => new
  12826. {
  12827. x.Days,
  12828. x.NationalTravelFeeId,
  12829. x.Cost,
  12830. x.Currency,
  12831. x.SubTotal
  12832. })
  12833. .WhereColumns(x => new { x.Id })
  12834. .ExecuteCommandAsync();
  12835. if (upd < 1) return Ok(JsonView(false));
  12836. }
  12837. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  12838. ////消息通知
  12839. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  12840. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12841. return Ok(JsonView(new { itemTotal = itemTotal }));
  12842. }
  12843. /// <summary>
  12844. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  12845. /// </summary>
  12846. /// <returns></returns>
  12847. [HttpPost]
  12848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12849. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  12850. {
  12851. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  12852. int subId = dto.SubId, feeType = dto.FeeType;
  12853. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12854. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12855. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12856. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  12857. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  12858. subInfo.Id = subId;
  12859. subInfo.ParentId = dto.DraftId;
  12860. if (feeType == 3) subInfo.Type = 1;
  12861. else if (feeType == 4) subInfo.Type = 2;
  12862. else if (feeType == 5) subInfo.Type = 3;
  12863. else if (feeType == 6) subInfo.Type = 4;
  12864. subInfo.CreateUserId = dto.CurrUserId;
  12865. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  12866. if (parentId < 1) return Ok(JsonView(false));
  12867. //子表op
  12868. if (subId < 1)
  12869. {
  12870. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12871. if (subAdd < 1) return Ok(JsonView(false));
  12872. }
  12873. else
  12874. {
  12875. var subUpd = await _sqlSugar.Updateable(subInfo)
  12876. .UpdateColumns(x => new
  12877. {
  12878. x.Days,
  12879. x.NationalTravelFeeId,
  12880. x.Cost,
  12881. x.Currency,
  12882. x.SubTotal
  12883. })
  12884. .WhereColumns(x => new { x.Id })
  12885. .ExecuteCommandAsync();
  12886. if (subUpd < 1) return Ok(JsonView(false));
  12887. }
  12888. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  12889. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12890. }
  12891. /// <summary>
  12892. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  12893. /// </summary>
  12894. /// <returns></returns>
  12895. [HttpPost]
  12896. [ApiExplorerSettings(IgnoreApi = true)]
  12897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12898. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  12899. {
  12900. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12901. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12902. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12903. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  12904. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  12905. {
  12906. Id = x.Id,
  12907. ParentId = dto.DraftId,
  12908. SetDataId = x.SetDataId,
  12909. Index = x.Index,
  12910. Cost = x.Cost,
  12911. Currency = x.Currency,
  12912. SubTotal = x.SubTotal,
  12913. CreateUserId = dto.CurrUserId,
  12914. Remark = x.Remark
  12915. }).ToList();
  12916. var adds = infos.Where(x => x.Id <= 0).ToList();
  12917. var upds = infos.Where(x => x.Id > 0).ToList();
  12918. if (adds.Count > 0)
  12919. {
  12920. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  12921. if (add < 1) return Ok(JsonView(false));
  12922. }
  12923. if (upds.Count > 0)
  12924. {
  12925. var upd = await _sqlSugar.Updateable(adds)
  12926. .UpdateColumns(x => new
  12927. {
  12928. x.Index,
  12929. x.SetDataId,
  12930. x.Cost,
  12931. x.Currency,
  12932. x.SubTotal,
  12933. x.Remark
  12934. })
  12935. .WhereColumns(x => new { x.Id })
  12936. .ExecuteCommandAsync();
  12937. if (upd < 1) return Ok(JsonView(false));
  12938. }
  12939. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  12940. //消息通知
  12941. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  12942. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  12943. return Ok(JsonView(new { itemTotal = itemTotal }));
  12944. }
  12945. /// <summary>
  12946. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  12947. /// </summary>
  12948. /// <returns></returns>
  12949. [HttpPost]
  12950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12951. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  12952. {
  12953. int subId = dto.SubId, id = dto.DraftId;
  12954. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12955. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  12956. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12957. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  12958. subInfo.Id = subId;
  12959. subInfo.ParentId = id;
  12960. subInfo.CreateUserId = dto.CurrUserId;
  12961. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  12962. if (parentId < 1) return Ok(JsonView(false));
  12963. #region 子表op
  12964. if (subId < 1)//add
  12965. {
  12966. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  12967. if (subAdd < 1) return Ok(JsonView(false));
  12968. }
  12969. else //upd
  12970. {
  12971. var subUpd = await _sqlSugar.Updateable(subInfo)
  12972. .UpdateColumns(x => new
  12973. {
  12974. x.Index,
  12975. x.SetDataId,
  12976. x.Cost,
  12977. x.Currency,
  12978. x.SubTotal,
  12979. x.Remark
  12980. })
  12981. .WhereColumns(x => new { x.Id })
  12982. .ExecuteCommandAsync();
  12983. if (subUpd < 1) return Ok(JsonView(false));
  12984. }
  12985. #endregion
  12986. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  12987. ////消息通知
  12988. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  12989. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  12990. }
  12991. /// <summary>
  12992. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  12993. /// </summary>
  12994. /// <returns></returns>
  12995. [HttpPost]
  12996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12997. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12998. {
  12999. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  13000. if (data.Code != 0)
  13001. {
  13002. return Ok(JsonView(false, data.Msg));
  13003. }
  13004. return Ok(JsonView(true, "操作成功!", data.Data));
  13005. }
  13006. /// <summary>
  13007. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  13008. /// </summary>
  13009. /// <param name="dto"></param>
  13010. /// <returns></returns>
  13011. [HttpPost]
  13012. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  13013. {
  13014. var data = new Grp_DayOtherPriceDraft()
  13015. {
  13016. Id = dto.Id,
  13017. IsDel = 1,
  13018. DeleteUserId = dto.DeleteUserId,
  13019. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  13020. };
  13021. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  13022. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  13023. return Ok(JsonView(false, "删除失败!"));
  13024. }
  13025. #endregion
  13026. #endregion
  13027. #region 团组经理模块 出入境费用报价表
  13028. /// <summary>
  13029. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  13030. /// </summary>
  13031. /// <returns></returns>
  13032. [HttpPost]
  13033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13034. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  13035. {
  13036. var initRates = await GeneralMethod.EnterExitCostInitRate();
  13037. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  13038. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  13039. initRates.Insert(0, cnyInfo);
  13040. liveRates.Insert(0, cnyInfo);
  13041. return Ok(JsonView(true, "查询成功!", new
  13042. {
  13043. InitRates = initRates,
  13044. LiveRates = liveRates
  13045. }));
  13046. }
  13047. /// <summary>
  13048. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  13049. /// </summary>
  13050. /// <returns></returns>
  13051. [HttpPost]
  13052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13053. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  13054. {
  13055. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  13056. }
  13057. /// <summary>
  13058. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  13059. /// </summary>
  13060. /// <returns></returns>
  13061. [HttpPost]
  13062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13063. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  13064. {
  13065. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  13066. }
  13067. /// <summary>
  13068. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  13069. /// </summary>
  13070. /// <returns></returns>
  13071. [HttpPost]
  13072. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13073. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  13074. {
  13075. int groupId = dto.DiId,
  13076. currUserId = dto.CurrUserId;
  13077. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  13078. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  13079. //验证报价数据是否存在
  13080. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  13081. if (isNull != null)
  13082. {
  13083. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  13084. if (!info1.Rates.Any())
  13085. {
  13086. var rates = await GeneralMethod.EnterExitCostInitRate();
  13087. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13088. info1.Rates = rates.ToArray();
  13089. }
  13090. return Ok(JsonView(info1));
  13091. }
  13092. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  13093. result.GroupId = groupId;
  13094. //处理报价名称
  13095. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  13096. if (groupInfo != null)
  13097. {
  13098. var visitCountry = groupInfo.VisitCountry;
  13099. if (!string.IsNullOrEmpty(visitCountry))
  13100. {
  13101. string quoteName = string.Empty;
  13102. if (visitCountry.Contains("|"))
  13103. {
  13104. var countrys = visitCountry.Split("|");
  13105. quoteName = string.Join("、", countrys);
  13106. }
  13107. else quoteName = visitCountry;
  13108. quoteName += $"团组报价表";
  13109. result.Name = quoteName;
  13110. }
  13111. }
  13112. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  13113. if (info.Code != StatusCodes.Status200OK)
  13114. {
  13115. if (!result.Rates.Any())
  13116. {
  13117. var rates = await GeneralMethod.EnterExitCostInitRate();
  13118. result.Rates = rates.ToArray();
  13119. }
  13120. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  13121. }
  13122. var infoView = info.Data as EnterExitCostInfoView;
  13123. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  13124. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  13125. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  13126. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  13127. var eecRates = infoView.Currencys;
  13128. //默认添加人名币
  13129. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  13130. {
  13131. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13132. }
  13133. //处理团组人数
  13134. int pplNum = 1;
  13135. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  13136. var views = new List<QuoteSubItemInfo>();
  13137. #region 数据填充
  13138. var intTravelCosts = new List<QuoteSubItemInfo>();
  13139. #region 机票费用 1354
  13140. int intTravelIndex = 1;
  13141. if (infoView.SumJJC == 1)
  13142. {
  13143. intTravelCosts.Add(new QuoteSubItemInfo
  13144. {
  13145. ItemId = 1354,
  13146. Index = intTravelIndex,
  13147. FeeName = "经济舱",
  13148. UnitPrice = infoView.AirJJ,
  13149. Currency = "CNY",
  13150. Quantity = 1,
  13151. PplNum = 1,
  13152. TotalAmt = infoView.AirJJ,
  13153. Remark = "",
  13154. });
  13155. intTravelIndex++;
  13156. }
  13157. if (infoView.SumGWC == 1)
  13158. {
  13159. intTravelCosts.Add(new QuoteSubItemInfo
  13160. {
  13161. ItemId = 1354,
  13162. Index = intTravelIndex,
  13163. FeeName = "公务舱",
  13164. UnitPrice = infoView.AirGW,
  13165. Currency = "CNY",
  13166. Quantity = 1,
  13167. PplNum = 1,
  13168. TotalAmt = infoView.AirGW,
  13169. Remark = "",
  13170. });
  13171. intTravelIndex++;
  13172. }
  13173. if (infoView.SumTDC == 1)
  13174. {
  13175. intTravelCosts.Add(new QuoteSubItemInfo
  13176. {
  13177. ItemId = 1354,
  13178. Index = intTravelIndex,
  13179. FeeName = "头等舱",
  13180. UnitPrice = infoView.AirTD,
  13181. Currency = "CNY",
  13182. Quantity = 1,
  13183. PplNum = 1,
  13184. TotalAmt = infoView.AirTD,
  13185. Remark = "",
  13186. });
  13187. intTravelIndex++;
  13188. }
  13189. intTravelCosts.Add(new QuoteSubItemInfo
  13190. {
  13191. ItemId = 1354,
  13192. Index = intTravelIndex,
  13193. FeeName = "城市间交通费用",
  13194. UnitPrice = infoView.CityTranffic,
  13195. Currency = "CNY",
  13196. Quantity = 1,
  13197. PplNum = pplNum,
  13198. TotalAmt = infoView.CityTranffic * pplNum,
  13199. Remark = "",
  13200. });
  13201. views.AddRange(intTravelCosts);
  13202. #endregion
  13203. var accomCosts = new List<QuoteSubItemInfo>();
  13204. #region 住宿费 1355
  13205. if (infoView.QuarterageData.Any())
  13206. {
  13207. int accomIndex = 1;
  13208. int accomItemTypeId = 1355;
  13209. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  13210. foreach (var item in groupData)
  13211. {
  13212. string feeName = string.Empty;
  13213. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13214. if (countryInfo != null)
  13215. {
  13216. feeName = countryInfo.Country;
  13217. var city = countryInfo.City;
  13218. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13219. {
  13220. feeName += $"-{city}";
  13221. }
  13222. }
  13223. var hotelInfo = item.FirstOrDefault();
  13224. if (hotelInfo == null) continue;
  13225. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  13226. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13227. int quantity = item.ToList().Count;
  13228. accomCosts.Add(new QuoteSubItemInfo
  13229. {
  13230. ItemId = accomItemTypeId,
  13231. Index = accomIndex,
  13232. FeeName = feeName,
  13233. UnitPrice = hotelInfo.Cost,
  13234. Currency = thisCurrency,
  13235. Quantity = quantity,
  13236. PplNum = pplNum,
  13237. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  13238. Remark = "",
  13239. });
  13240. accomIndex++;
  13241. }
  13242. views.AddRange(accomCosts);
  13243. }
  13244. #endregion
  13245. var mealCosts = new List<QuoteSubItemInfo>();
  13246. #region 餐饮费 1356
  13247. if (infoView.BoardWagesData.Any())
  13248. {
  13249. var mealIndex = 1;
  13250. int mealItemTypeId = 1356;
  13251. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  13252. foreach (var item in groupData)
  13253. {
  13254. string feeName = string.Empty;
  13255. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13256. if (countryInfo != null)
  13257. {
  13258. feeName = countryInfo.Country;
  13259. var city = countryInfo.City;
  13260. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13261. {
  13262. feeName += $"-{city}";
  13263. }
  13264. }
  13265. var mealInfo = item.FirstOrDefault();
  13266. if (mealInfo == null) continue;
  13267. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  13268. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13269. int quantity = item.ToList().Count;
  13270. mealCosts.Add(new QuoteSubItemInfo
  13271. {
  13272. ItemId = mealItemTypeId,
  13273. Index = mealIndex,
  13274. FeeName = feeName,
  13275. UnitPrice = mealInfo.Cost,
  13276. Currency = thisCurrency,
  13277. Quantity = quantity,
  13278. PplNum = pplNum,
  13279. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  13280. Remark = "",
  13281. });
  13282. mealIndex++;
  13283. }
  13284. views.AddRange(mealCosts);
  13285. }
  13286. #endregion
  13287. var miscCosts = new List<QuoteSubItemInfo>();
  13288. #region 公杂费 1364
  13289. if (infoView.MiscellaneousFeeData.Any())
  13290. {
  13291. var miscIndex = 1;
  13292. int miscItemTypeId = 1364;
  13293. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  13294. foreach (var item in groupData)
  13295. {
  13296. string feeName = string.Empty;
  13297. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  13298. if (countryInfo != null)
  13299. {
  13300. feeName = countryInfo.Country;
  13301. var city = countryInfo.City;
  13302. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  13303. {
  13304. feeName += $"-{city}";
  13305. }
  13306. }
  13307. var miscInfo = item.FirstOrDefault();
  13308. if (miscInfo == null) continue;
  13309. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  13310. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  13311. int quantity = item.ToList().Count;
  13312. miscCosts.Add(new QuoteSubItemInfo
  13313. {
  13314. ItemId = miscItemTypeId,
  13315. Index = miscIndex,
  13316. FeeName = feeName,
  13317. UnitPrice = miscInfo.Cost,
  13318. Currency = thisCurrency,
  13319. Quantity = quantity,
  13320. PplNum = pplNum,
  13321. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  13322. Remark = "",
  13323. });
  13324. miscIndex++;
  13325. }
  13326. views.AddRange(miscCosts);
  13327. }
  13328. #endregion
  13329. #region 签证+保险 1362
  13330. int visaInsIndex = 1;
  13331. int visaInsItemTypeId = 1362;
  13332. if (infoView.Visa > 0)
  13333. {
  13334. views.Add(new QuoteSubItemInfo()
  13335. {
  13336. ItemId = visaInsItemTypeId,
  13337. Index = visaInsIndex,
  13338. FeeName = $"签证",
  13339. UnitPrice = infoView.Visa,
  13340. Currency = $"CNY",
  13341. Quantity = 1,
  13342. PplNum = pplNum,
  13343. TotalAmt = infoView.Visa * pplNum,
  13344. Remark = "",
  13345. });
  13346. visaInsIndex++;
  13347. }
  13348. if (infoView.Safe > 0)
  13349. {
  13350. views.Add(new QuoteSubItemInfo()
  13351. {
  13352. ItemId = visaInsItemTypeId,
  13353. Index = visaInsIndex,
  13354. FeeName = $"保险",
  13355. UnitPrice = infoView.Safe,
  13356. Currency = $"CNY",
  13357. Quantity = 1,
  13358. PplNum = pplNum,
  13359. TotalAmt = infoView.Safe * pplNum,
  13360. Remark = "",
  13361. });
  13362. }
  13363. #endregion
  13364. #region 服务费 1363
  13365. int serviceFeeIndex = 1;
  13366. int serviceFeeItemTypeId = 1363;
  13367. if (infoView.Service > 0)
  13368. {
  13369. views.Add(new QuoteSubItemInfo()
  13370. {
  13371. ItemId = serviceFeeItemTypeId,
  13372. Index = serviceFeeIndex,
  13373. FeeName = $"服务费",
  13374. UnitPrice = infoView.Service,
  13375. Currency = $"CNY",
  13376. Quantity = 1,
  13377. PplNum = pplNum,
  13378. TotalAmt = infoView.Service * pplNum,
  13379. Remark = "",
  13380. });
  13381. }
  13382. #endregion
  13383. #endregion
  13384. if (result.FeeItems.Any())
  13385. {
  13386. result.FeeItems.Select(x =>
  13387. {
  13388. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  13389. if (feeInfos.Any()) x.Infos = feeInfos;
  13390. return x;
  13391. }
  13392. ).OrderBy(x => x.Index)
  13393. .ToList();
  13394. if (!result.Rates.Any())
  13395. {
  13396. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  13397. else
  13398. {
  13399. var rates = await GeneralMethod.EnterExitCostInitRate();
  13400. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13401. result.Rates = rates.ToArray();
  13402. }
  13403. }
  13404. }
  13405. return Ok(JsonView(result));
  13406. }
  13407. /// <summary>
  13408. /// 团组模块 - 出入境费用报价表 - Info
  13409. /// </summary>
  13410. /// <returns></returns>
  13411. [HttpPost]
  13412. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13413. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  13414. {
  13415. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  13416. if (!info.Rates.Any())
  13417. {
  13418. var rates = await GeneralMethod.EnterExitCostInitRate();
  13419. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  13420. info.Rates = rates.ToArray();
  13421. }
  13422. return Ok(JsonView(info));
  13423. }
  13424. /// <summary>
  13425. /// 团组模块 - 出入境费用报价表 - OP
  13426. /// </summary>
  13427. /// <returns></returns>
  13428. [HttpPost]
  13429. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13430. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  13431. {
  13432. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  13433. }
  13434. /// <summary>
  13435. /// 团组模块 - 出入境费用报价表 - 删除 项
  13436. /// </summary>
  13437. /// <returns></returns>
  13438. [HttpPost]
  13439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13440. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  13441. {
  13442. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13443. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13444. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  13445. }
  13446. /// <summary>
  13447. /// 团组模块 - 出入境费用报价表 - 导出
  13448. /// </summary>
  13449. /// <returns></returns>
  13450. [HttpPost]
  13451. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13452. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  13453. {
  13454. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  13455. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13456. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  13457. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  13458. var rates = info.Rates;
  13459. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  13460. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  13461. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  13462. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  13463. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  13464. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  13465. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  13466. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  13467. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  13468. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  13469. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  13470. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  13471. //获取模板
  13472. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  13473. var designer = new WorkbookDesigner();
  13474. designer.Workbook = new Workbook(tempPath);
  13475. designer.SetDataSource("QuoteName", info.Name);
  13476. designer.SetDataSource("CompanyTitle", "公司名称");
  13477. designer.SetDataSource("CompanyLabel", "");
  13478. #region 国际旅费
  13479. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  13480. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  13481. {
  13482. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  13483. var label = new StringBuilder();
  13484. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  13485. if (infos.Any())
  13486. {
  13487. label.Append(infos.Sum(x => x.PplNum));
  13488. label.Append("人全程机票:");
  13489. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  13490. label.AppendLine("元");
  13491. }
  13492. foreach (var item in intTravelCosts.Infos)
  13493. {
  13494. label.Append(item.FeeName);
  13495. label.Append(":");
  13496. label.Append(item.UnitPrice.TruncDecimals(2));
  13497. label.Append("元/人*");
  13498. label.Append(item.PplNum);
  13499. label.AppendLine("人");
  13500. }
  13501. if (label.HasValue())
  13502. {
  13503. label.Append("\r\n以上小计:");
  13504. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  13505. label.Append("元");
  13506. }
  13507. designer.SetDataSource("IntTravelLabel", label.ToString());
  13508. }
  13509. #endregion
  13510. #region 住宿费
  13511. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  13512. if (accomCosts != null && accomCosts.Infos.Any())
  13513. {
  13514. string currencyName = string.Empty,
  13515. countryName = string.Empty;
  13516. decimal rate = 1.0000M;
  13517. var label = new StringBuilder();
  13518. label.AppendLine("全程五星酒店,每人1间房");
  13519. foreach (var item in accomCosts.Infos)
  13520. {
  13521. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  13522. string name = string.Empty, thisCountryName = string.Empty;
  13523. if (item.FeeName.Contains('-'))
  13524. {
  13525. var feeName = item.FeeName.Split('-');
  13526. thisCountryName = feeName[0];
  13527. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13528. name = feeName[1];
  13529. }
  13530. else name = item.FeeName;
  13531. string thisFeeName = string.Empty;
  13532. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13533. else thisFeeName = $"\r\n{name}:";
  13534. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13535. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13536. rate = rateInfo?.Rate ?? 1.0000M;
  13537. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  13538. label.AppendLine(subLabel);
  13539. }
  13540. if (label.HasValue())
  13541. {
  13542. //以上小计:52440元(美金汇率:7.5 )
  13543. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  13544. label.AppendLine(subLabel);
  13545. }
  13546. designer.SetDataSource("AccomLabel", label.ToString());
  13547. }
  13548. #endregion
  13549. #region 餐饮费
  13550. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  13551. if (mealCosts != null && mealCosts.Infos.Any())
  13552. {
  13553. string currencyName = string.Empty;
  13554. decimal rate = 1.0000M;
  13555. var label = new StringBuilder();
  13556. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  13557. foreach (var item in mealCosts.Infos)
  13558. {
  13559. string name = string.Empty;
  13560. if (item.FeeName.Contains('-'))
  13561. {
  13562. var feeName = item.FeeName.Split('-');
  13563. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  13564. }
  13565. else name = $"\r\n{item.FeeName}:";
  13566. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13567. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13568. rate = rateInfo?.Rate ?? 1.0000M;
  13569. label.Append(name);
  13570. label.Append(item.UnitPrice.TruncDecimals(2));
  13571. label.Append(currencyName);
  13572. label.Append("/天*");
  13573. label.Append(item.Quantity.ToString("#0"));
  13574. label.Append('*');
  13575. label.Append(item.PplNum);
  13576. label.Append("人\r\n");
  13577. }
  13578. if (label.HasValue())
  13579. {
  13580. label.Append("\r\n以上小计:");
  13581. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  13582. label.Append("元\r\n(");
  13583. label.Append("汇率:");
  13584. label.Append(rate.TruncDecimals(4));
  13585. label.Append(')');
  13586. }
  13587. designer.SetDataSource("MealLabel", label.ToString());
  13588. }
  13589. #endregion
  13590. #region 车辆安排
  13591. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  13592. if (vehArranges != null && vehArranges.Infos.Any())
  13593. {
  13594. string currencyName = string.Empty;
  13595. //decimal rate = 1.0000M;
  13596. var label = new StringBuilder();
  13597. foreach (var item in vehArranges.Infos)
  13598. {
  13599. label.AppendLine();
  13600. label.AppendLine();
  13601. label.Append(item.FeeName);
  13602. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  13603. }
  13604. designer.SetDataSource("VehArrangeLabel", label.ToString());
  13605. }
  13606. #endregion
  13607. #region 邀请函发放对象
  13608. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  13609. designer.SetDataSource("InviteToContent", "");
  13610. #endregion
  13611. #region 邀请函费
  13612. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  13613. var is_label = new StringBuilder();
  13614. if (inviteCosts != null && inviteCosts.Infos.Any())
  13615. {
  13616. string currencyName = string.Empty;
  13617. decimal rate = 1.0000M;
  13618. foreach (var item in inviteCosts.Infos)
  13619. {
  13620. //乌兹别克斯坦:2000美金
  13621. currencyName = item.Currency;
  13622. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13623. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  13624. is_label.AppendLine(label);
  13625. }
  13626. if (is_label.HasValue())
  13627. {
  13628. //以上小计:28500元(美金汇率:7.5)
  13629. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  13630. is_label.AppendLine(label);
  13631. }
  13632. }
  13633. designer.SetDataSource("InviteCostContent", is_label.ToString());
  13634. #endregion
  13635. #region 邀请函发放时间
  13636. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  13637. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  13638. #endregion
  13639. #region 公务活动(含翻译)
  13640. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  13641. var oa_label = new StringBuilder();
  13642. if (officialActs != null && officialActs.Infos.Any())
  13643. {
  13644. string currencyName = string.Empty;
  13645. decimal rate = 1.0000M;
  13646. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  13647. foreach (var item in officialActs.Infos)
  13648. {
  13649. //乌兹别克斯坦:1000美金/场
  13650. currencyName = item.Currency;
  13651. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  13652. string label_remark = string.Empty;
  13653. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  13654. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  13655. }
  13656. label_content += "*总费用中未含超出公务活动价格";
  13657. //8场公务活动(以上小计:60000元)
  13658. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  13659. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  13660. oa_label.AppendLine(label_title);
  13661. oa_label.AppendLine(label_content);
  13662. }
  13663. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  13664. #endregion
  13665. #region 签证+保险
  13666. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  13667. var vi_label = new StringBuilder();
  13668. if (visaIns != null && visaIns.Infos.Any())
  13669. {
  13670. foreach (var item in visaIns.Infos)
  13671. {
  13672. //签证:500元/人
  13673. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  13674. vi_label.AppendLine(label);
  13675. }
  13676. if (vi_label.HasValue())
  13677. {
  13678. //以上小计:6000元
  13679. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  13680. vi_label.AppendLine(label);
  13681. }
  13682. }
  13683. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  13684. #endregion
  13685. #region 服务费
  13686. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  13687. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13688. #endregion
  13689. #region 公杂费
  13690. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  13691. var pm_label = new StringBuilder();
  13692. if (pubMiscs != null && pubMiscs.Infos.Any())
  13693. {
  13694. string currencyName = string.Empty,
  13695. countryName = string.Empty;
  13696. decimal rate = 1.0000M;
  13697. foreach (var item in pubMiscs.Infos)
  13698. {
  13699. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  13700. string name = string.Empty, thisCountryName = string.Empty;
  13701. if (item.FeeName.Contains('-'))
  13702. {
  13703. var feeName = item.FeeName.Split('-');
  13704. thisCountryName = feeName[0];
  13705. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  13706. name = feeName[1];
  13707. }
  13708. else name = item.FeeName;
  13709. string thisFeeName = string.Empty;
  13710. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  13711. else thisFeeName = $"\r\n{name}:";
  13712. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  13713. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  13714. rate = rateInfo?.Rate ?? 1.0000M;
  13715. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  13716. pm_label.AppendLine(label);
  13717. }
  13718. if (pm_label.HasValue())
  13719. {
  13720. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  13721. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  13722. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  13723. pm_label.AppendLine(string.Format("部分发放成员"));
  13724. }
  13725. }
  13726. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  13727. #endregion
  13728. #region 税费
  13729. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  13730. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  13731. #endregion
  13732. #region 合计(单位:元)
  13733. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  13734. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  13735. #endregion
  13736. #region 汇率 Remark
  13737. var rate_label = new StringBuilder();
  13738. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  13739. foreach (var item in rateGroups)
  13740. {
  13741. //美元汇率按\r\n1:7.5
  13742. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  13743. rate_label.AppendLine(label);
  13744. }
  13745. designer.SetDataSource("RateLabel", rate_label.ToString());
  13746. #endregion
  13747. designer.Process();
  13748. //文件名
  13749. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  13750. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  13751. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  13752. return Ok(JsonView(true, "成功", url));
  13753. }
  13754. #endregion
  13755. #region 签证费用录入
  13756. /// <summary>
  13757. /// 根据diid查询签证费用列表
  13758. /// </summary>
  13759. /// <param name="dto"></param>
  13760. /// <returns></returns>
  13761. [HttpPost]
  13762. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13763. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  13764. {
  13765. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  13766. if (groupData.Code != 0)
  13767. {
  13768. return Ok(JsonView(false, groupData.Msg));
  13769. }
  13770. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13771. }
  13772. /// <summary>
  13773. /// 根据签证费用Id查询单条数据及c表数据
  13774. /// </summary>
  13775. /// <param name="dto"></param>
  13776. /// <returns></returns>
  13777. [HttpPost]
  13778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13779. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  13780. {
  13781. Result groupData = await _visaPriceRep.PostVisaById(dto);
  13782. if (groupData.Code != 0)
  13783. {
  13784. return Ok(JsonView(false, groupData.Msg));
  13785. }
  13786. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13787. }
  13788. /// <summary>
  13789. /// 签证费用删除
  13790. /// </summary>
  13791. /// <param name="dto"></param>
  13792. /// <returns></returns>
  13793. [HttpPost]
  13794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13795. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  13796. {
  13797. _sqlSugar.BeginTran();
  13798. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  13799. if (!res)
  13800. {
  13801. _sqlSugar.RollbackTran();
  13802. return Ok(JsonView(false, "删除失败"));
  13803. }
  13804. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  13805. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  13806. .SetColumns(a => new Grp_CreditCardPayment()
  13807. {
  13808. IsDel = 1,
  13809. DeleteUserId = dto.DeleteUserId,
  13810. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13811. })
  13812. .ExecuteCommand();
  13813. if (resSub < 1)
  13814. {
  13815. _sqlSugar.RollbackTran();
  13816. return Ok(JsonView(false, "删除失败"));
  13817. }
  13818. _sqlSugar.CommitTran();
  13819. return Ok(JsonView(true, "删除成功!"));
  13820. }
  13821. /// <summary>
  13822. /// 签证费用录入下拉框初始化
  13823. /// </summary>
  13824. /// <returns></returns>
  13825. [HttpPost]
  13826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13827. public async Task<IActionResult> VisaPriceAddSelect()
  13828. {
  13829. //支付方式
  13830. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  13831. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  13832. //币种
  13833. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  13834. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  13835. //乘客类型
  13836. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  13837. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  13838. //卡类型
  13839. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  13840. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  13841. //代办费类型
  13842. var agencyFeeTypeData = new List<dynamic>() {
  13843. new { id = 0 , Text = "未选择" },
  13844. new { id = 1 , Text = "小公务" },
  13845. new { id = 2 , Text = "大公务" },
  13846. };
  13847. //签证费用标准国家Data
  13848. var visaSql = string.Format(@"select
  13849. id,
  13850. case
  13851. when FeeType = 0 then Country+'(因公)'
  13852. when FeeType = 1 then Country+'(因私)'
  13853. else Country+'(未设置)'
  13854. end as 'country'
  13855. from Res_VisaFeeStandard where isdel = 0");
  13856. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  13857. var data = new
  13858. {
  13859. Payment = _Payment,
  13860. CurrencyList = _CurrencyList,
  13861. PassengerType = _PassengerType,
  13862. BankCard = _BankCard,
  13863. AgencyFeeType = agencyFeeTypeData,
  13864. CountryFeeData = visaCountryFeeData
  13865. };
  13866. return Ok(JsonView(true, "查询成功!", data));
  13867. }
  13868. /// <summary>
  13869. /// 签证费用录入操作(Status:1.新增,2.修改)
  13870. /// </summary>
  13871. /// <param name="dto"></param>
  13872. /// <returns></returns>
  13873. [HttpPost]
  13874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13875. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  13876. {
  13877. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  13878. if (groupData.Code != 0)
  13879. {
  13880. return Ok(JsonView(false, groupData.Msg));
  13881. }
  13882. #region 应用推送
  13883. try
  13884. {
  13885. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  13886. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  13887. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  13888. //2024-10-21 新增LZ UID
  13889. var userIds = new List<int>() { 21 };
  13890. string title = $"系统通知";
  13891. string content = "";
  13892. var diId = dto.DiId;
  13893. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  13894. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  13895. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13896. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  13897. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  13898. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  13899. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  13900. }
  13901. catch (Exception ex)
  13902. {
  13903. }
  13904. #endregion
  13905. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  13906. }
  13907. #endregion
  13908. #region 签证提成录入
  13909. /// <summary>
  13910. /// 签证提成录入
  13911. /// 基础数据
  13912. /// </summary>
  13913. /// <returns></returns>
  13914. [HttpGet]
  13915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13916. public async Task<IActionResult> VisaCommissionInit()
  13917. {
  13918. return Ok(await _visaCommissionRep.Init());
  13919. }
  13920. /// <summary>
  13921. /// 签证提成录入
  13922. /// Item
  13923. /// </summary>
  13924. /// <param name="_dto"></param>
  13925. /// <returns></returns>
  13926. [HttpPost]
  13927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13928. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  13929. {
  13930. var validator = new VisaCommissionItemDtoValidator();
  13931. var validatorRes = await validator.ValidateAsync(_dto);
  13932. if (!validatorRes.IsValid)
  13933. {
  13934. var sb = new StringBuilder();
  13935. foreach (var item in validatorRes.Errors)
  13936. {
  13937. sb.AppendLine(item.ErrorMessage);
  13938. }
  13939. return Ok(JsonView(false, sb.ToString()));
  13940. }
  13941. return Ok(await _visaCommissionRep.Item(_dto));
  13942. }
  13943. /// <summary>
  13944. /// 签证提成录入
  13945. /// Save
  13946. /// </summary>
  13947. /// <param name="_dto"></param>
  13948. /// <returns></returns>
  13949. [HttpPost]
  13950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13951. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  13952. {
  13953. //参数验证
  13954. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  13955. foreach (var item in _dto.Items)
  13956. {
  13957. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  13958. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  13959. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  13960. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  13961. }
  13962. return Ok(await _visaCommissionRep.Save(_dto));
  13963. }
  13964. /// <summary>
  13965. /// 签证提成录入
  13966. /// Create
  13967. /// </summary>
  13968. /// <param name="_dto"></param>
  13969. /// <returns></returns>
  13970. [HttpPost]
  13971. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13972. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  13973. {
  13974. var validator = new VisaCommissionCreateDtoValidator();
  13975. var validatorRes = await validator.ValidateAsync(_dto);
  13976. if (!validatorRes.IsValid)
  13977. {
  13978. var sb = new StringBuilder();
  13979. foreach (var item in validatorRes.Errors)
  13980. {
  13981. sb.AppendLine(item.ErrorMessage);
  13982. }
  13983. return Ok(JsonView(false, sb.ToString()));
  13984. }
  13985. return Ok(await _visaCommissionRep.Create(_dto));
  13986. }
  13987. /// <summary>
  13988. /// 签证提成录入
  13989. /// Put(编辑)
  13990. /// </summary>
  13991. /// <param name="id"></param>
  13992. /// <param name="_dto"></param>
  13993. /// <returns></returns>
  13994. [HttpPut]
  13995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13996. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  13997. {
  13998. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  13999. var validator = new VisaCommissionCreateDtoValidator();
  14000. var validatorRes = await validator.ValidateAsync(_dto);
  14001. if (!validatorRes.IsValid)
  14002. {
  14003. var sb = new StringBuilder();
  14004. foreach (var item in validatorRes.Errors)
  14005. {
  14006. sb.AppendLine(item.ErrorMessage);
  14007. }
  14008. return Ok(JsonView(false, sb.ToString()));
  14009. }
  14010. return Ok(await _visaCommissionRep.Edit(id, _dto));
  14011. }
  14012. /// <summary>
  14013. /// 签证提成录入
  14014. /// Del
  14015. /// </summary>
  14016. /// <param name="id"></param>
  14017. /// <param name="currUserId"></param>
  14018. /// <returns></returns>
  14019. [HttpPost]
  14020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14021. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  14022. {
  14023. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  14024. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  14025. return Ok(await _visaCommissionRep.Del(id, currUserId));
  14026. }
  14027. #endregion
  14028. #region op费用录入
  14029. /// <summary>
  14030. /// 根据diid查询op费用列表
  14031. /// </summary>
  14032. /// <param name="dto"></param>
  14033. /// <returns></returns>
  14034. [HttpPost]
  14035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14036. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  14037. {
  14038. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  14039. if (groupData.Code != 0)
  14040. {
  14041. return Ok(JsonView(false, groupData.Msg));
  14042. }
  14043. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14044. }
  14045. /// <summary>
  14046. /// 根据op费用Id查询单条数据及c表数据
  14047. /// </summary>
  14048. /// <param name="dto"></param>
  14049. /// <returns></returns>
  14050. [HttpPost]
  14051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14052. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  14053. {
  14054. try
  14055. {
  14056. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  14057. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  14058. var data = new
  14059. {
  14060. CarTouristGuideGround = _groupData,
  14061. CreditCardPayment = _creditCardPayment
  14062. };
  14063. return Ok(JsonView(true, "查询成功!", data));
  14064. }
  14065. catch (Exception ex)
  14066. {
  14067. return Ok(JsonView(false, "程序错误!"));
  14068. }
  14069. }
  14070. /// <summary>
  14071. /// op费用删除
  14072. /// </summary>
  14073. /// <param name="dto"></param>
  14074. /// <returns></returns>
  14075. [HttpPost]
  14076. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14077. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  14078. {
  14079. try
  14080. {
  14081. _sqlSugar.BeginTran();
  14082. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  14083. if (!res)
  14084. {
  14085. return Ok(JsonView(false, "删除失败"));
  14086. }
  14087. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  14088. {
  14089. IsDel = 1,
  14090. DeleteUserId = dto.DeleteUserId,
  14091. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14092. }).ExecuteCommandAsync();
  14093. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  14094. {
  14095. IsDel = 1,
  14096. DeleteUserId = dto.DeleteUserId,
  14097. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14098. }).ExecuteCommandAsync();
  14099. #region 删除超支相关数据
  14100. //删除导入的超支数据
  14101. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  14102. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  14103. {
  14104. IsDel = 1,
  14105. DeleteUserId = dto.DeleteUserId,
  14106. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14107. }).ExecuteCommand();
  14108. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  14109. {
  14110. IsDel = 1,
  14111. DeleteUserId = dto.DeleteUserId,
  14112. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14113. }).ExecuteCommand();
  14114. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  14115. {
  14116. IsDel = 1,
  14117. DeleteUserId = dto.DeleteUserId,
  14118. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14119. }).ExecuteCommand();
  14120. #endregion
  14121. _sqlSugar.CommitTran();
  14122. return Ok(JsonView(true, "删除成功!"));
  14123. }
  14124. catch (Exception ex)
  14125. {
  14126. _sqlSugar.RollbackTran();
  14127. return Ok(JsonView(false, "程序错误!" + ex.Message));
  14128. }
  14129. }
  14130. /// <summary>
  14131. /// op费用录入操作(Status:1.新增,2.修改)
  14132. /// </summary>
  14133. /// <param name="dto"></param>
  14134. /// <returns></returns>
  14135. [HttpPost]
  14136. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14137. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  14138. {
  14139. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  14140. if (groupData.Code != 0)
  14141. {
  14142. return Ok(JsonView(false, groupData.Msg));
  14143. }
  14144. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14145. }
  14146. /// <summary>
  14147. /// 填写费用详细页面初始化绑定
  14148. /// </summary>
  14149. /// <param name="dto"></param>
  14150. /// <returns></returns>
  14151. [HttpPost]
  14152. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14153. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  14154. {
  14155. try
  14156. {
  14157. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  14158. if (groupData.Code != 0)
  14159. {
  14160. return Ok(JsonView(false, groupData.Msg));
  14161. }
  14162. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14163. }
  14164. catch (Exception ex)
  14165. {
  14166. return Ok(JsonView(false, ex.Message));
  14167. }
  14168. }
  14169. /// <summary>
  14170. /// 根据op费用Id查询详细数据
  14171. /// </summary>
  14172. /// <param name="dto"></param>
  14173. /// <returns></returns>
  14174. [HttpPost]
  14175. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14176. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  14177. {
  14178. try
  14179. {
  14180. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  14181. if (groupData.Code != 0)
  14182. {
  14183. return Ok(JsonView(false, groupData.Msg));
  14184. }
  14185. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14186. }
  14187. catch (Exception ex)
  14188. {
  14189. return Ok(JsonView(false, ex.Message));
  14190. }
  14191. }
  14192. /// <summary>
  14193. /// OP费用录入填写详情
  14194. /// </summary>
  14195. /// <param name="dto"></param>
  14196. /// <returns></returns>
  14197. [HttpPost]
  14198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14199. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  14200. {
  14201. try
  14202. {
  14203. #region 参数校验
  14204. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  14205. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  14206. if (di == null) return Ok(JsonView(false, "团组错误!"));
  14207. #endregion
  14208. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  14209. if (groupData.Code != 0)
  14210. {
  14211. return Ok(JsonView(false, groupData.Msg));
  14212. }
  14213. //自动审核
  14214. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  14215. #region 尾款自动审核
  14216. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14217. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  14218. if (opinfos.PriceType == 1062)
  14219. {
  14220. var isAuto = false;
  14221. //找对应的首付款
  14222. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  14223. .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))
  14224. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  14225. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  14226. x.PriceType == 1061 && x.DiId == dto.DiId);
  14227. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  14228. {
  14229. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  14230. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  14231. //合计中排除城市税
  14232. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  14233. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  14234. .Sum(x => x.Price * x.Count);
  14235. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  14236. if (balance >= opinfos.ServiceQuotedPrice)
  14237. {
  14238. isAuto = true;
  14239. }
  14240. }
  14241. if (isAuto)
  14242. {
  14243. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  14244. .SetColumns(a => new Grp_CreditCardPayment
  14245. {
  14246. IsAuditGM = 3, //自动审核通过
  14247. AuditGMOperate = 4,
  14248. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  14249. })
  14250. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  14251. .ExecuteCommand();
  14252. }
  14253. }
  14254. #endregion
  14255. #region 应用推送
  14256. try
  14257. {
  14258. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  14259. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  14260. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  14261. //2024-10-21 新增LZ UID
  14262. var userIds = new List<int>() { 21 };
  14263. string title = $"系统通知";
  14264. var diId = dto.DiId;
  14265. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  14266. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  14267. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  14268. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  14269. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  14270. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  14271. }
  14272. catch (Exception ex)
  14273. {
  14274. }
  14275. #endregion
  14276. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  14277. }
  14278. catch (Exception ex)
  14279. {
  14280. return Ok(JsonView(false, ex.Message));
  14281. }
  14282. }
  14283. /// <summary>
  14284. /// 获取三公详细所有城市
  14285. /// </summary>
  14286. /// <returns></returns>
  14287. [HttpGet]
  14288. public IActionResult OpCarCityResult()
  14289. {
  14290. var jw = JsonView(false);
  14291. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  14292. {
  14293. x.Id,
  14294. x.Country,
  14295. x.City,
  14296. }).ToList();
  14297. if (data.Count > 0)
  14298. {
  14299. jw = JsonView(true, "获取成功!", data);
  14300. }
  14301. else
  14302. {
  14303. jw.Msg = "城市数据为空!";
  14304. jw.Data = Array.Empty<string>();
  14305. }
  14306. return Ok(jw);
  14307. }
  14308. /// <summary>
  14309. /// 导出地接费用明细
  14310. /// </summary>
  14311. /// <param name="dto"></param>
  14312. /// <returns></returns>
  14313. [HttpPost]
  14314. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  14315. {
  14316. var jw = JsonView(false);
  14317. if (dto.Diid < 1)
  14318. {
  14319. jw.Msg = "请输入正确的diid!";
  14320. return Ok(jw);
  14321. }
  14322. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  14323. if (group == null)
  14324. {
  14325. jw.Msg = "未找到团组信息!";
  14326. return Ok(jw);
  14327. }
  14328. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  14329. if (localGuideArr.Count == 0)
  14330. {
  14331. jw.Msg = "该团组暂无地接信息!";
  14332. return Ok(jw);
  14333. }
  14334. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  14335. var overspendSoure = new Dictionary<int, int>
  14336. {
  14337. { 91, 982 }, //车
  14338. { 92 , 1059} ,//导游
  14339. { 994 , 1073}, //翻译
  14340. { 988 , 1074 }, //早餐
  14341. { 93 , 1075 }, //午餐
  14342. { 989 , 1076 }, //晚餐
  14343. };
  14344. var Zips = new Dictionary<string, Stream>();
  14345. foreach (var groupArr in localGroup)
  14346. {
  14347. var keyValue = groupArr.Key;
  14348. if (int.TryParse(keyValue, out int cityid))
  14349. {
  14350. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  14351. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  14352. }
  14353. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  14354. foreach (var item in groupArr)
  14355. {
  14356. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  14357. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  14358. new Grp_CarTouristGuideGroundReservationsContentExtend
  14359. {
  14360. Count = a.Count,
  14361. CreateTime = a.CreateTime,
  14362. CreateUserId = a.CreateUserId,
  14363. CTGGRId = a.CTGGRId,
  14364. Currency = a.Currency,
  14365. DatePrice = a.DatePrice,
  14366. DeleteTime = a.DeleteTime,
  14367. DeleteUserId = a.DeleteUserId,
  14368. DiId = a.DiId,
  14369. Id = a.Id,
  14370. IsDel = a.IsDel,
  14371. Price = a.Price,
  14372. PriceContent = a.PriceContent,
  14373. Remark = a.Remark,
  14374. SId = a.SId,
  14375. SidName = b.Name,
  14376. Units = a.Units,
  14377. }
  14378. ).ToList();
  14379. if (content.Count > 0)
  14380. {
  14381. contentArr.Add(content);
  14382. }
  14383. }
  14384. //open excel
  14385. //set excel
  14386. //save excel
  14387. try
  14388. {
  14389. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  14390. IWorkbook workbook;
  14391. if (Path.GetExtension(filePath).ToLower() == ".xls")
  14392. {
  14393. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14394. }
  14395. else
  14396. {
  14397. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  14398. }
  14399. ISheet sheet = workbook.GetSheetAt(0);
  14400. var rowStartIndex = 2;
  14401. var clounmCount = 10;
  14402. var initStyleRow = sheet.GetRow(2);
  14403. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  14404. //var overspendArrDetail =
  14405. var existsId = new List<CarCompare>();
  14406. var lastElem = arr.Last();
  14407. var thisSid = -1;
  14408. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  14409. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  14410. {
  14411. Name = "未知币种!",
  14412. Remark = "未知币种!",
  14413. };
  14414. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  14415. Action cloneRowFn = () =>
  14416. {
  14417. rowStartIndex++;
  14418. var cloneRow = sheet.CreateRow(rowStartIndex);
  14419. // 复制样式
  14420. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  14421. {
  14422. ICell sourceCell = initStyleRow.GetCell(i);
  14423. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  14424. // 确保单元格存在样式
  14425. if (sourceCell.CellStyle != null)
  14426. {
  14427. targetCell.CellStyle = sourceCell.CellStyle;
  14428. }
  14429. }
  14430. };
  14431. var mergeRow = () =>
  14432. {
  14433. for (int i = 2; i < sheet.LastRowNum; i++)
  14434. {
  14435. var row = sheet.GetRow(i);
  14436. var cellFirst = row.GetCell(0);
  14437. var thisIndex = i + 1;
  14438. while (thisIndex < sheet.LastRowNum)
  14439. {
  14440. var nextRow = sheet.GetRow(thisIndex);
  14441. var nextCellFirst = nextRow.GetCell(0);
  14442. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  14443. {
  14444. thisIndex++;
  14445. }
  14446. else
  14447. {
  14448. break;
  14449. }
  14450. }
  14451. thisIndex--;
  14452. if (thisIndex != i)
  14453. {
  14454. //合并row
  14455. var cellRangeAddress = new CellRangeAddress(
  14456. i, // 起始行索引(0-based)
  14457. thisIndex, // 结束行索引(0-based)
  14458. 0, // 起始列索引(0-based)
  14459. 0 // 结束列索引(0-based)
  14460. );
  14461. sheet.AddMergedRegion(cellRangeAddress);
  14462. i = thisIndex;
  14463. }
  14464. }
  14465. };
  14466. var chaoshiNumber = 0;
  14467. var totalNumber = 0.00M;
  14468. string lastStr = "";
  14469. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  14470. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  14471. {
  14472. b.IsAuditGM,
  14473. x.Id,
  14474. x.Area,
  14475. b.PayPercentage,
  14476. b.PayMoney,
  14477. }).ToList();
  14478. string yesPayment = "", noPayment = "";
  14479. foreach (var item in queryCarArrByCityAndDiid)
  14480. {
  14481. if (item.IsAuditGM == 1)
  14482. {
  14483. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14484. }
  14485. else
  14486. {
  14487. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  14488. }
  14489. }
  14490. lastStr = yesPayment + noPayment;
  14491. foreach (var item in arr)
  14492. {
  14493. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  14494. {
  14495. if (thisSid != item.SId)
  14496. {
  14497. if (thisSid == -1)
  14498. {
  14499. thisSid = item.SId;
  14500. }
  14501. else
  14502. {
  14503. //合并小计行
  14504. //创建合并区域的实例
  14505. var cellRangeAddress = new CellRangeAddress(
  14506. rowStartIndex, // 起始行索引(0-based)
  14507. rowStartIndex, // 结束行索引(0-based)
  14508. 0, // 起始列索引(0-based)
  14509. 3 // 结束列索引(0-based)
  14510. );
  14511. sheet.AddMergedRegion(cellRangeAddress);
  14512. var CellStyle = workbook.CreateCellStyle();
  14513. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14514. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14515. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14516. for (int i = 0; i <= clounmCount; i++)
  14517. {
  14518. if (i > 6)
  14519. {
  14520. var CellStyle1 = workbook.CreateCellStyle();
  14521. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14522. IFont Font = workbook.CreateFont(); // 创建字体
  14523. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14524. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14525. CellStyle1.SetFont(Font);
  14526. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14527. }
  14528. else
  14529. {
  14530. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14531. }
  14532. }
  14533. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14534. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14535. //超时合计
  14536. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14537. //超时数
  14538. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14539. //超时合计费用
  14540. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14541. thisSid = item.SId;
  14542. cloneRowFn();
  14543. chaoshiNumber = 0;
  14544. totalNumber = 0;
  14545. }
  14546. }
  14547. IRow row = sheet.GetRow(rowStartIndex);
  14548. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14549. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  14550. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  14551. if (isOpenOverspendSoure)
  14552. {
  14553. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14554. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  14555. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  14556. }
  14557. for (int i = 0; i <= clounmCount; i++)
  14558. {
  14559. var cell = row.GetCell(i);
  14560. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  14561. if (cell == null)
  14562. {
  14563. cell = row.CreateCell(i);
  14564. }
  14565. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  14566. fontRed.CloneStyleFrom(cell.CellStyle);
  14567. IFont Font = workbook.CreateFont(); // 创建字体
  14568. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  14569. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14570. fontRed.SetFont(Font);
  14571. byte[] rgb = new byte[3] { 255, 242, 204 };
  14572. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  14573. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  14574. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  14575. if (workbook is XSSFWorkbook)
  14576. {
  14577. BackgroundColor255_242_204.FillForegroundColor = 0;
  14578. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  14579. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14580. }
  14581. else
  14582. {
  14583. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  14584. }
  14585. if (i == 1 || i > 6)
  14586. {
  14587. if (i > 6)
  14588. {
  14589. fontRed.FillForegroundColor = 0;
  14590. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  14591. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  14592. }
  14593. cell.CellStyle = fontRed;
  14594. }
  14595. if (i > 2 && i < 7)
  14596. {
  14597. cell.CellStyle = BackgroundColor255_242_204;
  14598. }
  14599. cell.SetCellValue(setCellValue); //写入单元格
  14600. }
  14601. if (overspendSoure.ContainsKey(thisSid))
  14602. {
  14603. var overspendId = overspendSoure[thisSid];
  14604. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  14605. }
  14606. cloneRowFn();
  14607. existsId.Add(new CarCompare
  14608. {
  14609. DataPrice = item.DatePrice.ObjToDate(),
  14610. Sid = item.SId
  14611. });
  14612. }
  14613. if (item.Equals(lastElem))
  14614. {
  14615. //合并小计行
  14616. //创建合并区域的实例
  14617. var cellRangeAddress = new CellRangeAddress(
  14618. rowStartIndex, // 起始行索引(0-based)
  14619. rowStartIndex, // 结束行索引(0-based)
  14620. 0, // 起始列索引(0-based)
  14621. 3 // 结束列索引(0-based)
  14622. );
  14623. sheet.AddMergedRegion(cellRangeAddress);
  14624. var CellStyle = workbook.CreateCellStyle();
  14625. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14626. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  14627. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  14628. for (int i = 0; i <= clounmCount; i++)
  14629. {
  14630. if (i > 6)
  14631. {
  14632. var CellStyle1 = workbook.CreateCellStyle();
  14633. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  14634. IFont Font = workbook.CreateFont(); // 创建字体
  14635. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  14636. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  14637. CellStyle1.SetFont(Font);
  14638. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  14639. }
  14640. else
  14641. {
  14642. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  14643. }
  14644. }
  14645. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  14646. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  14647. //超时合计
  14648. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  14649. //超时数
  14650. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  14651. //超时合计费用
  14652. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  14653. cloneRowFn();
  14654. // 创建合并区域的实例
  14655. cellRangeAddress = new CellRangeAddress(
  14656. rowStartIndex, // 起始行索引(0-based)
  14657. rowStartIndex, // 结束行索引(0-based)
  14658. 0, // 起始列索引(0-based)
  14659. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  14660. );
  14661. // 添加合并区域
  14662. sheet.AddMergedRegion(cellRangeAddress);
  14663. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  14664. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  14665. }
  14666. }
  14667. mergeRow();
  14668. // 保存修改后的Excel文件到新文件
  14669. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  14670. // new FileStream(newFilePath, FileMode.CreateNew)
  14671. using (var stream = new MemoryStream())
  14672. {
  14673. workbook.Write(stream, true);
  14674. stream.Flush();
  14675. stream.Seek(0, SeekOrigin.Begin);
  14676. var memoryStream = new MemoryStream();
  14677. stream.CopyTo(memoryStream);
  14678. memoryStream.Seek(0, SeekOrigin.Begin);
  14679. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  14680. }
  14681. workbook.Close();
  14682. workbook.Dispose();
  14683. }
  14684. catch (Exception ex)
  14685. {
  14686. jw.Msg = "出现异常!" + ex.Message;
  14687. return Ok(jw);
  14688. }
  14689. }
  14690. if (Zips.Count > 0)
  14691. {
  14692. var io = new IOOperatorHelper();
  14693. var byts = io.ConvertZipStream(Zips);
  14694. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  14695. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  14696. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  14697. }
  14698. else
  14699. {
  14700. jw.Msg = "暂无生成文件!";
  14701. }
  14702. return Ok(jw);
  14703. }
  14704. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  14705. {
  14706. string outStr = string.Empty;
  14707. switch (i)
  14708. {
  14709. case 0:
  14710. outStr = arr[0].SidName;
  14711. break;
  14712. case 1:
  14713. outStr = arr[0].DataPriceStr;
  14714. break;
  14715. case 2:
  14716. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  14717. break;
  14718. case 4:
  14719. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  14720. break;
  14721. case 7:
  14722. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14723. {
  14724. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  14725. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  14726. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  14727. }
  14728. break;
  14729. case 8:
  14730. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14731. {
  14732. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  14733. }
  14734. break;
  14735. case 9:
  14736. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14737. {
  14738. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  14739. }
  14740. break;
  14741. case 10:
  14742. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  14743. {
  14744. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  14745. }
  14746. break;
  14747. }
  14748. return outStr;
  14749. }
  14750. #region OP行程单
  14751. /// <summary>
  14752. /// OP行程单初始化
  14753. /// </summary>
  14754. /// <param name="dto"></param>
  14755. /// <returns></returns>
  14756. [HttpPost]
  14757. public IActionResult InitOpTravel(InitOpTravelDto dto)
  14758. {
  14759. var jw = JsonView(false);
  14760. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  14761. var group = groupList.First();
  14762. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  14763. if (group == null)
  14764. {
  14765. jw.Msg = "暂无团组!";
  14766. return Ok(jw);
  14767. }
  14768. group = groupList.Find(x => x.Id == diid);
  14769. if (group == null)
  14770. {
  14771. jw.Msg = "请输入正确的团组ID!";
  14772. return Ok(jw);
  14773. }
  14774. string city = string.Empty;
  14775. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  14776. if (blackCode.Count > 0)
  14777. {
  14778. var black = blackCode.First();
  14779. black.BlackCode = black.BlackCode ?? "";
  14780. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  14781. if (blackSp.Length > 0)
  14782. {
  14783. try
  14784. {
  14785. var cityArrCode = new List<string>(20);
  14786. foreach (var item in blackSp)
  14787. {
  14788. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  14789. var IndexSelect = itemSp[2];
  14790. var cityArrCodeLength = cityArrCode.Count - 1;
  14791. var startCity = IndexSelect.Substring(0, 3);
  14792. if (cityArrCodeLength > 0)
  14793. {
  14794. var arrEndCity = cityArrCode[cityArrCodeLength];
  14795. if (arrEndCity != startCity)
  14796. {
  14797. cityArrCode.Add(startCity.ToUpper());
  14798. }
  14799. }
  14800. else
  14801. {
  14802. cityArrCode.Add(startCity.ToUpper());
  14803. }
  14804. var endCity = IndexSelect.Substring(3, 3);
  14805. cityArrCode.Add(endCity.ToUpper());
  14806. }
  14807. var cityThree = string.Empty;
  14808. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  14809. cityThree = cityThree.TrimEnd(',');
  14810. if (string.IsNullOrWhiteSpace(cityThree))
  14811. {
  14812. throw new
  14813. Exception("error");
  14814. }
  14815. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  14816. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  14817. foreach (var item in cityArrCode)
  14818. {
  14819. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  14820. if (find != null)
  14821. {
  14822. city += find.City + "/";
  14823. }
  14824. else
  14825. {
  14826. city += item + "三字码未收入/";
  14827. }
  14828. }
  14829. city = city.TrimEnd('/');
  14830. }
  14831. catch (Exception e)
  14832. {
  14833. city = "黑屏代码格式不正确!";
  14834. }
  14835. }
  14836. }
  14837. else
  14838. {
  14839. city = "未录入黑屏代码";
  14840. }
  14841. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  14842. {
  14843. Date = x.Date,
  14844. Days = x.Days,
  14845. Diffgroup = x.Diffgroup,
  14846. Diid = x.Diid,
  14847. Traffic_First = x.Traffic_First,
  14848. Traffic_Second = x.Traffic_Second,
  14849. Trip = x.Trip,
  14850. WeekDay = x.WeekDay,
  14851. Id = x.Id
  14852. }).ToList();
  14853. jw.Data = new
  14854. {
  14855. groupList = groupList.Select(x => new
  14856. {
  14857. x.Id,
  14858. x.TeamName,
  14859. x.TourCode
  14860. }).ToList(),
  14861. groupInfo = new
  14862. {
  14863. group.VisitDays,
  14864. group.TourCode,
  14865. group.VisitPNumber,
  14866. group.TeamName,
  14867. city
  14868. },
  14869. OpTravelList
  14870. };
  14871. jw.Code = 200;
  14872. jw.Msg = "操作成功!";
  14873. return Ok(jw);
  14874. }
  14875. /// <summary>
  14876. /// 删除团组行程单
  14877. /// </summary>
  14878. /// <returns></returns>
  14879. [HttpPost]
  14880. public IActionResult DelTravel(DelOpTravelDto dto)
  14881. {
  14882. var jw = JsonView(false);
  14883. if (dto.UserId <= 0 || dto.Diid <= 0)
  14884. {
  14885. jw.Msg = "请输入正确的参数!";
  14886. return Ok(jw);
  14887. }
  14888. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  14889. .SetColumns(x => new Grp_TravelList
  14890. {
  14891. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  14892. DeleteUserId = dto.UserId,
  14893. IsDel = 1,
  14894. }).ExecuteCommand();
  14895. jw = JsonView(true);
  14896. return Ok(jw);
  14897. }
  14898. /// <summary>
  14899. /// 行程单保存
  14900. /// </summary>
  14901. /// <returns></returns>
  14902. [HttpPost]
  14903. public IActionResult TravelSave(TravelSaveDto dto)
  14904. {
  14905. var jw = JsonView(false);
  14906. if (dto.Arr.Count > 0)
  14907. {
  14908. try
  14909. {
  14910. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  14911. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  14912. .ToList();
  14913. _sqlSugar.BeginTran();
  14914. foreach (var item in dto.Arr)
  14915. {
  14916. if (item.Id == 0)
  14917. {
  14918. throw new Exception("请传入正确的Id");
  14919. }
  14920. //比较上一次的差异
  14921. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  14922. if (findTravel != null)
  14923. {
  14924. item.Trip = item.Trip.Replace("[++]", string.Empty);
  14925. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  14926. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  14927. }
  14928. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  14929. .SetColumns(x => new Grp_TravelList
  14930. {
  14931. Trip = item.Trip
  14932. }).ExecuteCommand();
  14933. }
  14934. _sqlSugar.CommitTran();
  14935. jw = JsonView(true);
  14936. }
  14937. catch (Exception ex)
  14938. {
  14939. _sqlSugar.RollbackTran();
  14940. jw.Msg = "程序异常!" + ex.Message;
  14941. }
  14942. }
  14943. else
  14944. {
  14945. jw.Msg = "请传入正确的参数!";
  14946. }
  14947. return Ok(jw);
  14948. }
  14949. private static string CheckStr(string original, string changed)
  14950. {
  14951. // 创建diff_match_patch对象
  14952. var dmp = new diff_match_patch();
  14953. // 计算差异
  14954. List<Diff> diffs = dmp.diff_main(original, changed);
  14955. // 清理和合并差异
  14956. dmp.diff_cleanupSemantic(diffs);
  14957. // 使用StringBuilder构建最终的字符串
  14958. var finalString = new StringBuilder();
  14959. // 输出差异结果,并构建变动后的字符串
  14960. foreach (Diff diff in diffs)
  14961. {
  14962. switch (diff.operation)
  14963. {
  14964. case Operation.EQUAL:
  14965. // 相等的部分,直接添加到最终字符串
  14966. finalString.Append(diff.text);
  14967. break;
  14968. case Operation.INSERT:
  14969. // 插入的部分,添加标记并添加到最终字符串
  14970. finalString.Append("[++]" + diff.text + "[++]");
  14971. break;
  14972. case Operation.DELETE:
  14973. // 删除的部分,不添加到最终字符串
  14974. //finalString.Append("[++]" + diff.text + "[++]");
  14975. break;
  14976. }
  14977. }
  14978. // 输出变动后的字符串
  14979. return finalString.ToString();
  14980. }
  14981. private class tagContent
  14982. {
  14983. public DateTime Date { get; set; }
  14984. public string StartTag { get; set; }
  14985. public string EndTag { get; set; }
  14986. public string Content { get; set; }
  14987. public static int tagLength { get { return 3; } }
  14988. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  14989. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  14990. public bool IsFinally { get; set; }
  14991. }
  14992. private static List<string> ExtractContentBetweenTags(string input, string tag)
  14993. {
  14994. var results = new List<string>();
  14995. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  14996. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  14997. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  14998. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  14999. string[] strValueArr = new string[1];
  15000. foreach (System.Text.RegularExpressions.Match match in matches)
  15001. {
  15002. var strValue = match.Groups[1].Value;
  15003. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  15004. }
  15005. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  15006. return results;
  15007. }
  15008. /// <summary>
  15009. /// 导出行程单
  15010. /// </summary>
  15011. /// <param name="dto"></param>
  15012. /// <returns></returns>
  15013. [HttpPost]
  15014. public IActionResult ExportTravel(ExportTravelDto dto)
  15015. {
  15016. var jw = JsonView(false);
  15017. jw.Data = "";
  15018. int diid = 0;
  15019. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  15020. if (Find == null)
  15021. {
  15022. jw.Msg = "请选择正确的团组!";
  15023. return Ok(jw);
  15024. }
  15025. else
  15026. {
  15027. diid = Find.Id;
  15028. }
  15029. //数据源
  15030. var _travelList = new List<Grp_TravelList>();
  15031. DataTable dtBlack = null;
  15032. try
  15033. {
  15034. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  15035. }
  15036. catch (Exception)
  15037. {
  15038. jw.Msg = "机票黑屏代码有误!";
  15039. return Ok(jw);
  15040. }
  15041. string CityStr = string.Empty;
  15042. if (dtBlack.Rows.Count == 0)
  15043. {
  15044. jw.Msg = "机票黑屏代码有误!";
  15045. return Ok(jw);
  15046. }
  15047. else
  15048. {
  15049. foreach (DataRow row in dtBlack.Rows)
  15050. {
  15051. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  15052. {
  15053. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  15054. return Ok(jw);
  15055. }
  15056. }
  15057. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  15058. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  15059. }
  15060. // 指定的文字
  15061. var targetTextDic = new Dictionary<string, List<string>>();
  15062. //创建数据源Table
  15063. var dtSource = new DataTable();
  15064. dtSource.Columns.Add("Days", typeof(string));
  15065. dtSource.Columns.Add("Date", typeof(string));
  15066. dtSource.Columns.Add("Week", typeof(string));
  15067. dtSource.Columns.Add("Traffic", typeof(string));
  15068. dtSource.Columns.Add("Trip", typeof(string));
  15069. //获取数据,放到datatable
  15070. foreach (var item in _travelList)
  15071. {
  15072. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  15073. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  15074. .Replace(tagContent.TagFormat.Item2, string.Empty)
  15075. .Replace("[++]", string.Empty);
  15076. DataRow dr = dtSource.NewRow();
  15077. dr["Days"] = item.Days;
  15078. dr["Date"] = item.Date;
  15079. dr["Week"] = item.WeekDay;
  15080. dr["Traffic"] = item.Traffic_First
  15081. + "\r\n"
  15082. + item.Traffic_Second;
  15083. dr["Trip"] = item.Trip;
  15084. dtSource.Rows.Add(dr);
  15085. }
  15086. var dic = new Dictionary<string, string>
  15087. {
  15088. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  15089. { "City", CityStr },
  15090. { "Days", Find.VisitDays.ToString() },
  15091. { "DeleCode", Find.TourCode },
  15092. { "Pnum", Find.VisitPNumber.ToString() }
  15093. };
  15094. //模板路径
  15095. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  15096. //载入模板
  15097. Document doc = null;
  15098. DocumentBuilder builder = null;
  15099. try
  15100. {
  15101. //载入模板
  15102. doc = new Document(tempPath);
  15103. builder = new DocumentBuilder(doc);
  15104. }
  15105. catch (Exception)
  15106. {
  15107. jw.Msg = "模板位置不存在!";
  15108. return Ok(jw);
  15109. }
  15110. foreach (var key in dic.Keys)
  15111. {
  15112. Bookmark bookmark = doc.Range.Bookmarks[key];
  15113. if (bookmark != null)
  15114. {
  15115. builder.MoveToBookmark(key);
  15116. builder.Write(dic[key]);
  15117. }
  15118. }
  15119. //获取word里所有表格
  15120. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  15121. //获取所填表格的序数
  15122. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  15123. try
  15124. {
  15125. //循环赋值
  15126. for (int i = 0; i < dtSource.Rows.Count; i++)
  15127. {
  15128. builder.MoveToCell(0, i + 1, 0, 0);
  15129. builder.Write(dtSource.Rows[i]["Days"].ToString());
  15130. builder.MoveToCell(0, i + 1, 1, 0);
  15131. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  15132. builder.MoveToCell(0, i + 1, 2, 0);
  15133. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  15134. var trip = dtSource.Rows[i]["Trip"].ToString();
  15135. builder.MoveToCell(0, i + 1, 3, 0);
  15136. builder.Write(trip);
  15137. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  15138. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  15139. // 获取特定索引的段落
  15140. Paragraph paragraph = (Paragraph)paragraphs[0];
  15141. Run run = paragraph.Runs[0];
  15142. Aspose.Words.Font font = run.Font;
  15143. font.Name = "黑体";
  15144. //设置双休红色
  15145. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  15146. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  15147. paragraph = (Paragraph)paragraphs[1];
  15148. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  15149. {
  15150. run = paragraph.Runs[0];
  15151. font = run.Font;
  15152. font.Color = Color.Red;
  15153. }
  15154. }
  15155. }
  15156. catch (Exception ex)
  15157. {
  15158. }
  15159. //删除多余行
  15160. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  15161. {
  15162. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  15163. }
  15164. var targetTextList = new List<string>();
  15165. // 遍历文档中的表格
  15166. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  15167. {
  15168. foreach (Aspose.Words.Tables.Row row in table.Rows)
  15169. {
  15170. var cellIndex = 0;
  15171. foreach (Cell cell in row.Cells)
  15172. {
  15173. if (cellIndex == 1 && row.Cells.Count == 4)
  15174. {
  15175. foreach (var target in targetTextDic.Keys)
  15176. {
  15177. if (cell.GetText().Contains(target))
  15178. {
  15179. targetTextList = targetTextDic[target];
  15180. break;
  15181. }
  15182. }
  15183. }
  15184. // 遍历单元格中的所有段落
  15185. foreach (Paragraph paragraph in cell.Paragraphs)
  15186. {
  15187. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  15188. var runs = new List<Run>();
  15189. foreach (Run run in paragraph.Runs)
  15190. {
  15191. runs.Add(run);
  15192. }
  15193. foreach (Run run in runs)
  15194. {
  15195. foreach (var targetText in targetTextList)
  15196. {
  15197. // 检查文字是否包含指定文字
  15198. if (run.Text.Contains(targetText))
  15199. {
  15200. // 将包含的部分设置为红色
  15201. HighlightText(run, targetText, Color.Red);
  15202. }
  15203. }
  15204. }
  15205. }
  15206. cellIndex++;
  15207. }
  15208. }
  15209. }
  15210. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  15211. if (!Directory.Exists(savePath))
  15212. {
  15213. try
  15214. {
  15215. Directory.CreateDirectory(savePath);
  15216. }
  15217. catch
  15218. {
  15219. }
  15220. }
  15221. string path = savePath + Find.TeamName + "出访日程";
  15222. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  15223. try
  15224. {
  15225. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  15226. string postfix = ".docx";
  15227. if (dto.IsPDF == 1)
  15228. {
  15229. saveFormat = Aspose.Words.SaveFormat.Pdf;
  15230. postfix = ".pdf";
  15231. }
  15232. doc.Save(path + postfix, saveFormat);
  15233. jw = JsonView(true, "导出成功", ftpPath + postfix);
  15234. }
  15235. catch (Exception)
  15236. {
  15237. jw = JsonView(false);
  15238. }
  15239. return Ok(jw);
  15240. }
  15241. /// <summary>
  15242. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  15243. /// </summary>
  15244. /// <param name="num"></param>
  15245. /// <returns></returns>
  15246. static string GetNum(string num)
  15247. {
  15248. string str = "";
  15249. switch (num)
  15250. {
  15251. case "1":
  15252. str = "一";
  15253. break;
  15254. case "2":
  15255. str = "二";
  15256. break;
  15257. case "3":
  15258. str = "三";
  15259. break;
  15260. case "4":
  15261. str = "四";
  15262. break;
  15263. case "5":
  15264. str = "五";
  15265. break;
  15266. case "6":
  15267. str = "六";
  15268. break;
  15269. case "7":
  15270. str = "七";
  15271. break;
  15272. case "8":
  15273. str = "八";
  15274. break;
  15275. case "9":
  15276. str = "九";
  15277. break;
  15278. case "10":
  15279. str = "十";
  15280. break;
  15281. case "11":
  15282. str = "十一";
  15283. break;
  15284. case "12":
  15285. str = "十二";
  15286. break;
  15287. case "一":
  15288. str = "1";
  15289. break;
  15290. case "二":
  15291. str = "2";
  15292. break;
  15293. case "三":
  15294. str = "3";
  15295. break;
  15296. case "四":
  15297. str = "4";
  15298. break;
  15299. case "五":
  15300. str = "5";
  15301. break;
  15302. case "六":
  15303. str = "6";
  15304. break;
  15305. case "七":
  15306. str = "7";
  15307. break;
  15308. case "八":
  15309. str = "8";
  15310. break;
  15311. case "九":
  15312. str = "9";
  15313. break;
  15314. case "十":
  15315. str = "10";
  15316. break;
  15317. case "十一":
  15318. str = "11";
  15319. break;
  15320. case "十二":
  15321. str = "12";
  15322. break;
  15323. }
  15324. return str;
  15325. }
  15326. /// <summary>
  15327. /// 高亮包含指定文字的部分
  15328. /// </summary>
  15329. /// <param name="run"></param>
  15330. /// <param name="targetText"></param>
  15331. /// <param name="color"></param>
  15332. static void HighlightText(Run run, string targetText, Color color)
  15333. {
  15334. string text = run.Text;
  15335. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  15336. if (startIndex >= 0)
  15337. {
  15338. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  15339. // 前部分
  15340. if (startIndex > 0)
  15341. {
  15342. Run beforeRun = (Run)run.Clone(true);
  15343. beforeRun.Text = text.Substring(0, startIndex);
  15344. parentParagraph.InsertBefore(beforeRun, run);
  15345. }
  15346. // 匹配部分
  15347. Run matchRun = (Run)run.Clone(true);
  15348. matchRun.Text = text.Substring(startIndex, targetText.Length);
  15349. matchRun.Font.Color = color;
  15350. parentParagraph.InsertBefore(matchRun, run);
  15351. // 后部分
  15352. if (startIndex + targetText.Length < text.Length)
  15353. {
  15354. Run afterRun = (Run)run.Clone(true);
  15355. afterRun.Text = text.Substring(startIndex + targetText.Length);
  15356. parentParagraph.InsertBefore(afterRun, run);
  15357. }
  15358. // 删除原始Run
  15359. run.Remove();
  15360. }
  15361. }
  15362. #endregion
  15363. #endregion
  15364. #region 团组成本
  15365. /// <summary>
  15366. /// 团组成本数据初始化
  15367. /// </summary>
  15368. /// <param name="dto"></param>
  15369. /// <returns></returns>
  15370. [HttpPost]
  15371. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  15372. {
  15373. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  15374. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  15375. WHEN COUNT(*) >= 0 THEN 'True'
  15376. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  15377. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  15378. ").ToList(); //团组列表
  15379. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  15380. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  15381. var visaCountryInfoArr = new ArrayList();
  15382. var groupinfoValue = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == diid && x.IsDel == 0);
  15383. if (groupinfoValue != null)
  15384. {
  15385. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  15386. var dicity = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == groupinfoValue.CityId);
  15387. dicity ??= new Sys_Cities()
  15388. {
  15389. ParentId = 122
  15390. };
  15391. var diparent = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == dicity.ParentId);
  15392. var spArr = new string[1] { countryArr };
  15393. if (countryArr.Contains("|"))
  15394. {
  15395. spArr = countryArr.Split("|");
  15396. }
  15397. else if (countryArr.Contains("、"))
  15398. {
  15399. spArr = countryArr.Split("、");
  15400. }
  15401. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  15402. {
  15403. try
  15404. {
  15405. var visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  15406. .Where(x => x.IsDel == 0 && x.Country == item)
  15407. .ToList();
  15408. if (visa.Any())
  15409. {
  15410. var visainfo = _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  15411. .Where(x => x.IsDel == 0 && visa.Select(x => x.Id).Contains(x.ParentId))
  15412. .ToList();
  15413. var visaMain = visainfo.FirstOrDefault(x => x.ProvinceId == diparent.Id);
  15414. var visayinsiValue = visainfo.FirstOrDefault(x => x.ParentId == visa.FirstOrDefault(x => x.FeeType == 1)?.Id);
  15415. visaCountryInfoArr.Add(new
  15416. {
  15417. country = item,
  15418. yinsi = new
  15419. {
  15420. Id = visayinsiValue.Id,
  15421. value = visayinsiValue.SmallVisaPrice
  15422. },
  15423. visaMain = new
  15424. {
  15425. Id = visaMain.Id,
  15426. IsVisaOnArrival = visaMain.IsVisaOnArrival ? "是" : "否",
  15427. IsElectronicSign = visaMain.IsElectronicSign ? "是" : "否",
  15428. VisaTime = visaMain.VisaTime,
  15429. IsVisaExemptionLarge = visaMain.IsVisaExemptionLarge ? "是" : "否",
  15430. LargeVisaPrice = visaMain.LargeVisaPrice,
  15431. LargeAgencyFee = visaMain.LargeAgencyFee,
  15432. IsVisaExemptionSmall = visaMain.IsVisaExemptionSmall ? "是" : "否",
  15433. SmallVisaPrice = visaMain.SmallVisaPrice,
  15434. SmallAgencyFee = visaMain.SmallAgencyFee,
  15435. NormExtFee = visaMain.NormExtFee,
  15436. UrgExtFee = visaMain.UrgExtFee,
  15437. IsUrgent = visaMain.IsUrgent ? "是" : "否",
  15438. UrgentTime = visaMain.UrgentTime,
  15439. UrgentPrice = visaMain.UrgentPrice,
  15440. UrgentPriceDesc = visaMain.UrgentPriceDesc,
  15441. Remark = visaMain.Remark,
  15442. }
  15443. });
  15444. }
  15445. }
  15446. catch (Exception ex)
  15447. {
  15448. //写入日志
  15449. _logger.LogError(ex, "团组成本解析签证异常!");
  15450. }
  15451. }
  15452. }
  15453. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  15454. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  15455. #region 屏蔽黑屏代码生成
  15456. //var create = _GroupCostRepository.
  15457. // CreateGroupCostByBlackCode(dto.Diid);
  15458. //if (groupCost.Count == 0 && create.Code == 0)
  15459. //{
  15460. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  15461. //}
  15462. #endregion
  15463. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  15464. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  15465. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  15466. groupCostMap = groupCostMap.Select(x =>
  15467. {
  15468. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  15469. {
  15470. x.Date = dataForamt.ToString("yyyy-MM-dd");
  15471. }
  15472. return x;
  15473. }).ToList();
  15474. //GroupCostParameter.Add(new
  15475. // Grp_GroupCostParameter());
  15476. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  15477. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  15478. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  15479. return Ok(JsonView(new
  15480. {
  15481. groupList,
  15482. groupInfo,
  15483. groupChecks,
  15484. groupCost = groupCostMap,
  15485. hotelNumber,
  15486. GroupCostParameter = GroupCostParameterMap,
  15487. visaCountryInfoArr = visaCountryInfoArr,
  15488. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  15489. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  15490. hotelIsTrue,
  15491. groupModuleOperators
  15492. }));
  15493. }
  15494. /// <summary>
  15495. /// 团组成本信息保存
  15496. /// </summary>
  15497. /// <param name="dto"></param>
  15498. /// <returns></returns>
  15499. [HttpPost]
  15500. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  15501. {
  15502. if (dto.Diid <= 0 || dto.Userid <= 0)
  15503. {
  15504. return Ok(JsonView(false));
  15505. }
  15506. JsonView jw = null;
  15507. bool isTrue = false;
  15508. #region 复制团组成本
  15509. //if (dto.Diid == 2581)
  15510. //{
  15511. // dto.Diid = 2599;
  15512. // dto.CheckBoxs.ForEach(x =>
  15513. // {
  15514. // x.Diid = 2599;
  15515. // });
  15516. // dto.GroupCosts.ForEach(x =>
  15517. // {
  15518. // x.Diid = 2599;
  15519. // });
  15520. // dto.CostTypeHotelNumbers.ForEach(x =>
  15521. // {
  15522. // x.Diid = 2599;
  15523. // });
  15524. // dto.GroupCostParameters.ForEach(x =>
  15525. // {
  15526. // x.DiId = 2599;
  15527. // });
  15528. //}
  15529. #endregion
  15530. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15531. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15532. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15533. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15534. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15535. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15536. try
  15537. {
  15538. _sqlSugar.BeginTran();
  15539. isTrue = await _GroupCostRepository.
  15540. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15541. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15542. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15543. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15544. _sqlSugar.CommitTran();
  15545. jw = JsonView(true, "保存成功!", isTrue);
  15546. }
  15547. catch (Exception)
  15548. {
  15549. _sqlSugar.RollbackTran();
  15550. jw = JsonView(false);
  15551. }
  15552. return Ok(jw);
  15553. }
  15554. /// <summary>
  15555. /// 复制团组成本信息
  15556. /// </summary>
  15557. /// <param name="dto"></param>
  15558. /// <returns></returns>
  15559. [HttpPost]
  15560. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  15561. {
  15562. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  15563. {
  15564. return Ok(JsonView(false, "参数有误!"));
  15565. }
  15566. #region 复制团组成本
  15567. dto.Diid = dto.ToGroupId;
  15568. dto.CheckBoxs.ForEach(x =>
  15569. {
  15570. x.Diid = dto.ToGroupId;
  15571. });
  15572. dto.GroupCosts.ForEach(x =>
  15573. {
  15574. x.Diid = dto.ToGroupId;
  15575. });
  15576. dto.CostTypeHotelNumbers.ForEach(x =>
  15577. {
  15578. x.Diid = dto.ToGroupId;
  15579. });
  15580. dto.GroupCostParameters.ForEach(x =>
  15581. {
  15582. x.DiId = dto.ToGroupId;
  15583. });
  15584. #endregion
  15585. JsonView jw = null;
  15586. bool isTrue = false;
  15587. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  15588. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  15589. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  15590. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  15591. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  15592. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  15593. try
  15594. {
  15595. _sqlSugar.BeginTran();
  15596. isTrue = await _GroupCostRepository.
  15597. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  15598. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  15599. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  15600. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  15601. _sqlSugar.CommitTran();
  15602. jw = JsonView(true, "保存成功!", isTrue);
  15603. }
  15604. catch (Exception)
  15605. {
  15606. _sqlSugar.RollbackTran();
  15607. jw = JsonView(false);
  15608. }
  15609. return Ok(jw);
  15610. }
  15611. /// <summary>
  15612. /// 司兼导数据
  15613. /// </summary>
  15614. /// <param name="dto"></param>
  15615. /// <returns></returns>
  15616. [HttpPost]
  15617. public IActionResult GetCarGuides(CarGuidesDto dto)
  15618. {
  15619. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  15620. return Ok(JsonView(true, "获取成功!", Data));
  15621. }
  15622. /// <summary>
  15623. /// 导游数据
  15624. /// </summary>
  15625. /// <param name="dto"></param>
  15626. /// <returns></returns>
  15627. [HttpPost]
  15628. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  15629. {
  15630. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  15631. // 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
  15632. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  15633. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  15634. return Ok(JsonView(true, "获取成功!", Data));
  15635. }
  15636. /// <summary>
  15637. /// 成本车数据
  15638. /// </summary>
  15639. /// <param name="dto"></param>
  15640. /// <returns></returns>
  15641. [HttpPost]
  15642. public IActionResult GetCarInfo(CarGuidesDto dto)
  15643. {
  15644. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  15645. return Ok(JsonView(true, "获取成功!", Data));
  15646. }
  15647. /// <summary>
  15648. /// 景点数据
  15649. /// </summary>
  15650. /// <param name="dto"></param>
  15651. /// <returns></returns>
  15652. [HttpPost]
  15653. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  15654. {
  15655. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  15656. return Ok(JsonView(true, "获取成功!", Data));
  15657. }
  15658. /// <summary>
  15659. /// 成本通知
  15660. /// </summary>
  15661. /// <param name="dto"></param>
  15662. /// <returns></returns>
  15663. [HttpPost]
  15664. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  15665. {
  15666. if (dto.Diid < 0)
  15667. {
  15668. return Ok(JsonView(false));
  15669. }
  15670. JsonView jw;
  15671. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  15672. if (GroupCostParameter != null)
  15673. {
  15674. int IsShare = 0;
  15675. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  15676. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  15677. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  15678. string msg = string.Empty;
  15679. if (isTrue)
  15680. {
  15681. if (IsShare == 0)
  15682. {
  15683. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  15684. }
  15685. else
  15686. {
  15687. #region 企微通知对应岗位用户
  15688. try
  15689. {
  15690. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  15691. }
  15692. catch (Exception)
  15693. {
  15694. }
  15695. #endregion
  15696. msg = "通知成功,其他模块操作人员可见此成本信息!";
  15697. }
  15698. jw = JsonView(isTrue, msg, new { IsShare });
  15699. }
  15700. else
  15701. {
  15702. msg = "修改失败!";
  15703. jw = JsonView(isTrue, msg);
  15704. }
  15705. }
  15706. else
  15707. {
  15708. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  15709. }
  15710. return Ok(jw);
  15711. }
  15712. /// <summary>
  15713. /// 导出报价单
  15714. /// </summary>
  15715. /// <param name="dto"></param>
  15716. /// <returns></returns>
  15717. [HttpPost]
  15718. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  15719. {
  15720. if (dto.Diid == 0)
  15721. {
  15722. return Ok(JsonView(false, "请传递团组id"));
  15723. }
  15724. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15725. if (deleInfo.Code != 0)
  15726. {
  15727. return Ok(JsonView(false, "团组信息查询失败!"));
  15728. }
  15729. var di = deleInfo.Data as DelegationInfoWebView;
  15730. if (di != null)
  15731. {
  15732. di.TeamName = di.TeamName.Replace("|", "、");
  15733. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  15734. //文件名
  15735. string strFileName = di.TeamName + "-收款账单.doc";
  15736. //获取模板
  15737. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  15738. //载入模板
  15739. Document doc = new Document(tmppath);
  15740. decimal TotalPrice = 0.00M;
  15741. string itemStr = string.Empty;
  15742. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  15743. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15744. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  15745. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  15746. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  15747. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  15748. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  15749. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  15750. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  15751. foreach (var cost in groupCostType)
  15752. {
  15753. var List = cost.ToList();
  15754. if (cost.Key == "A")
  15755. {
  15756. foreach (var ListItem in List)
  15757. {
  15758. if (ListItem.number > 0)
  15759. {
  15760. if (ListItem.code.Contains("TBR"))
  15761. {
  15762. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15763. }
  15764. else
  15765. {
  15766. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15767. }
  15768. TotalPrice += (ListItem.number * ListItem.price);
  15769. }
  15770. }
  15771. }
  15772. else
  15773. {
  15774. itemStr = itemStr.Insert(0, "A段\r\n");
  15775. itemStr += "B段\r\n";
  15776. foreach (var ListItem in List)
  15777. {
  15778. if (ListItem.number > 0)
  15779. {
  15780. if (ListItem.code.Contains("TBR"))
  15781. {
  15782. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15783. }
  15784. else
  15785. {
  15786. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  15787. }
  15788. TotalPrice += (ListItem.number * ListItem.price);
  15789. }
  15790. }
  15791. }
  15792. }
  15793. #region 替换Word模板书签内容
  15794. Dictionary<string, string> marks = new Dictionary<string, string>();
  15795. marks.Add("To", di.ClientUnit);//付款方
  15796. marks.Add("ToTel", di.TellPhone);//付款方电话
  15797. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  15798. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  15799. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  15800. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  15801. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  15802. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  15803. marks.Add("PayItemContent", itemStr);//详细信息
  15804. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  15805. #endregion
  15806. ////注
  15807. //if (doc.Range.Bookmarks["Attention"] != null)
  15808. //{
  15809. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  15810. // mark.Text = frList[0].Attention;
  15811. //}
  15812. foreach (var item in marks.Keys)
  15813. {
  15814. if (doc.Range.Bookmarks[item] != null)
  15815. {
  15816. Bookmark mark = doc.Range.Bookmarks[item];
  15817. mark.Text = marks[item];
  15818. }
  15819. }
  15820. byte[] bytes = null;
  15821. using (MemoryStream stream = new MemoryStream())
  15822. {
  15823. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  15824. bytes = stream.ToArray();
  15825. }
  15826. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  15827. return Ok(JsonView(true, "", new
  15828. {
  15829. Data = bytes,
  15830. strFileName,
  15831. }));
  15832. }
  15833. else
  15834. {
  15835. return Ok(JsonView(false, "团组信息不存在!"));
  15836. }
  15837. }
  15838. /// <summary>
  15839. /// 导出团组成本
  15840. /// </summary>
  15841. /// <param name="dto"></param>
  15842. /// <returns></returns>
  15843. [HttpPost]
  15844. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  15845. {
  15846. var jw = JsonView(false);
  15847. if (dto.Diid == 0)
  15848. {
  15849. return Ok(JsonView(false, "请传递团组id"));
  15850. }
  15851. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  15852. if (deleInfo.Code != 0)
  15853. {
  15854. return Ok(JsonView(false, "团组信息查询失败!"));
  15855. }
  15856. var di = deleInfo.Data as DelegationInfoWebView;
  15857. if (di == null)
  15858. {
  15859. return Ok(JsonView(false, "团组信息查询失败!"));
  15860. }
  15861. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  15862. WorkbookDesigner designer = new WorkbookDesigner();
  15863. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  15864. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  15865. List<int> hideColumnList = new List<int>();
  15866. var ColumnSetting = new[]
  15867. {
  15868. new { tag = "VF", Index = 4, P = "CarCost" },
  15869. new { tag = "VN", Index = 5, P = "CarNumber" },
  15870. new { tag = "VRD", Index = 6, P = "CarTiming" },
  15871. new { tag = "T/G S", Index = 7, P = "TGS" },
  15872. new { tag = "TGWH", Index = 8, P = "TGWH" },
  15873. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  15874. new { tag = "T/G M", Index = 10, P = "TGM" },
  15875. new { tag = "T/G A", Index = 11, P = "TGA" },
  15876. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  15877. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  15878. new { tag = "C/F S", Index = 14, P = "CFS" },
  15879. new { tag = "C/F M", Index = 15, P = "CFM" },
  15880. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  15881. new { tag = "B", Index = 17, P = "B" },
  15882. new { tag = "L", Index = 18, P = "L" },
  15883. new { tag = "D", Index = 19, P = "D" },
  15884. new { tag = "TBR", Index = 20, P = "TBR" },
  15885. new { tag = "SGR", Index = 21, P = "SGR" },
  15886. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  15887. new { tag = "Suite", Index = 23, P = "Suite" },
  15888. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  15889. new { tag = "T/V", Index = 25, P = "TV" },
  15890. new { tag = "1/L", Index = 26, P = "iL" },
  15891. new { tag = "I/F", Index = 27, P = "IF" },
  15892. new { tag = "EF", Index = 28, P = "EF" },
  15893. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  15894. new { tag = "TE", Index = 30, P = "TE" },
  15895. new { tag = "T/G T", Index = 31, P = "TGTips" },
  15896. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  15897. new { tag = "P/C", Index = 33, P = "PC" },
  15898. new { tag = "T/L F", Index = 34, P = "TLF" },
  15899. new { tag = "E/C T", Index = 35, P = "ECT" }
  15900. };
  15901. Func<string, bool> isEmpty = (str) =>
  15902. {
  15903. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  15904. {
  15905. return true;
  15906. }
  15907. if (string.IsNullOrWhiteSpace(str))
  15908. {
  15909. return true;
  15910. }
  15911. return false;
  15912. };
  15913. for (int i = 0; i < List_GC.Count; i++)
  15914. {
  15915. GroupCost_Excel gc = new GroupCost_Excel();
  15916. gc.Id = List_GC[i].Id;
  15917. gc.Diid = List_GC[i].Diid.ToString();
  15918. gc.DAY = List_GC[i].DAY;
  15919. string week = "";
  15920. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  15921. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  15922. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  15923. gc.ITIN = List_GC[i].ITIN;
  15924. gc.CarType = List_GC[i].CarType;
  15925. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  15926. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  15927. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  15928. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  15929. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  15930. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  15931. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  15932. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  15933. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  15934. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  15935. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  15936. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  15937. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  15938. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  15939. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  15940. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  15941. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  15942. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  15943. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  15944. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  15945. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  15946. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  15947. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  15948. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  15949. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  15950. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  15951. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  15952. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  15953. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  15954. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  15955. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  15956. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  15957. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  15958. gc.EFR = List_GC[i].EFR;
  15959. List_GC1.Add(gc);
  15960. }
  15961. if (List_GC1.Count > 0)
  15962. {
  15963. var p = List_GC1[0];
  15964. var prs = p.GetType().GetProperties();
  15965. foreach (var item in prs)
  15966. {
  15967. var tp = item.PropertyType;
  15968. if (tp == typeof(int))
  15969. {
  15970. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  15971. if (val == 0)
  15972. {
  15973. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15974. if (columnSetting != null)
  15975. {
  15976. hideColumnList.Add(columnSetting.Index);
  15977. }
  15978. }
  15979. }
  15980. if (tp == typeof(decimal))
  15981. {
  15982. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  15983. if (val == 0)
  15984. {
  15985. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  15986. if (columnSetting != null)
  15987. {
  15988. hideColumnList.Add(columnSetting.Index);
  15989. }
  15990. }
  15991. }
  15992. if (tp == typeof(string))
  15993. {
  15994. var val = List_GC1.Sum(x =>
  15995. {
  15996. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  15997. if (decimal.TryParse(str, out decimal str_De))
  15998. {
  15999. return str_De;
  16000. }
  16001. else
  16002. {
  16003. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  16004. }
  16005. });
  16006. if (val == 0)
  16007. {
  16008. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  16009. if (columnSetting != null)
  16010. {
  16011. hideColumnList.Add(columnSetting.Index);
  16012. }
  16013. }
  16014. }
  16015. }
  16016. }
  16017. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  16018. dt.TableName = "TB";
  16019. //报表标题等不用dt的值
  16020. designer.SetDataSource("TeamName", dto.title.TeamName);
  16021. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  16022. designer.SetDataSource("Tax", dto.title.Tax);
  16023. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  16024. designer.SetDataSource("Currency", dto.title.Currency);
  16025. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  16026. designer.SetDataSource("Rate", dto.title.Rate);
  16027. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  16028. var Aparams = hotels.Find(x => x.Type == "Default");
  16029. if (Aparams == null)
  16030. {
  16031. return Ok(jw);
  16032. }
  16033. //酒店数量
  16034. var txtSGRNumber = Aparams.SGR.ToString();
  16035. var txtTBRNumber = Aparams.TBR.ToString();
  16036. var txtJSESNumber = Aparams.JSES.ToString();
  16037. var txtSUITENumbe = Aparams.SUITE.ToString();
  16038. if (dto.costType == "B")
  16039. {
  16040. Aparams = hotels.Find(x => x.Type == "A");
  16041. var Bparams = hotels.Find(x => x.Type == "B");
  16042. if (Aparams == null || Bparams == null)
  16043. {
  16044. return Ok(jw);
  16045. }
  16046. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  16047. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  16048. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  16049. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  16050. }
  16051. designer.SetDataSource("SGRNumber", txtSGRNumber);
  16052. designer.SetDataSource("TBRNumber", txtTBRNumber);
  16053. designer.SetDataSource("JSESNumber", txtJSESNumber);
  16054. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  16055. var ws = designer.Workbook.Worksheets[1];
  16056. int Row = List_GC.Count;
  16057. int startIndex = 0;
  16058. int HideRows = 0;
  16059. Row = 0;
  16060. List<int> hideRowsList = new List<int>();
  16061. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  16062. #region A段left数据
  16063. var left = dto.leftInfo.Find(x => x.Type == "A");
  16064. if (left == null)
  16065. {
  16066. return Ok(jw);
  16067. }
  16068. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  16069. if (leftBindData != null)
  16070. {
  16071. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  16072. designer.SetDataSource("VisaRS", leftBindData.rs);
  16073. designer.SetDataSource("VisaXS", leftBindData.xs);
  16074. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16075. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16076. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16077. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16078. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16079. }
  16080. else
  16081. {
  16082. hideRowsList.Add(Row + startIndex + HideRows);
  16083. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16084. }
  16085. HideRows += 2;
  16086. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  16087. if (leftBindData != null)
  16088. {
  16089. designer.SetDataSource("BXDRCB", leftBindData.cb);
  16090. designer.SetDataSource("BXRS", leftBindData.rs);
  16091. designer.SetDataSource("BXXS", leftBindData.xs);
  16092. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16093. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16094. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16095. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16096. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16097. }
  16098. else
  16099. {
  16100. hideRowsList.Add(Row + startIndex + HideRows);
  16101. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16102. }
  16103. HideRows += 2;
  16104. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  16105. if (leftBindData != null)
  16106. {
  16107. designer.SetDataSource("HSDRCB", leftBindData.cb);
  16108. designer.SetDataSource("HSRS", leftBindData.rs);
  16109. designer.SetDataSource("HSXS", leftBindData.xs);
  16110. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16111. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16112. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16113. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16114. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16115. }
  16116. else
  16117. {
  16118. hideRowsList.Add(Row + startIndex + HideRows);
  16119. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16120. }
  16121. HideRows += 2;
  16122. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  16123. if (leftBindData != null)
  16124. {
  16125. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  16126. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  16127. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  16128. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16129. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16130. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16131. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16132. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16133. }
  16134. else
  16135. {
  16136. hideRowsList.Add(Row + startIndex + HideRows);
  16137. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16138. }
  16139. HideRows += 2;
  16140. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  16141. if (leftBindData != null)
  16142. {
  16143. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  16144. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  16145. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  16146. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16147. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16148. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16149. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16150. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16151. }
  16152. else
  16153. {
  16154. hideRowsList.Add(Row + startIndex + HideRows);
  16155. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16156. }
  16157. HideRows += 2;
  16158. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  16159. if (leftBindData != null)
  16160. {
  16161. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  16162. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  16163. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  16164. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16165. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16166. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16167. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16168. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16169. }
  16170. else
  16171. {
  16172. hideRowsList.Add(Row + startIndex + HideRows);
  16173. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16174. }
  16175. HideRows += 2;
  16176. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  16177. if (leftBindData != null)
  16178. {
  16179. ////TBR
  16180. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  16181. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  16182. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  16183. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16184. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16185. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16186. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16187. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16188. }
  16189. else
  16190. {
  16191. hideRowsList.Add(Row + startIndex + HideRows);
  16192. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16193. }
  16194. HideRows += 2;
  16195. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16196. if (leftBindData != null)
  16197. {
  16198. ////SGR
  16199. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  16200. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  16201. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  16202. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16203. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16204. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16205. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16206. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16207. }
  16208. else
  16209. {
  16210. hideRowsList.Add(Row + startIndex + HideRows);
  16211. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16212. }
  16213. HideRows += 2;
  16214. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16215. if (leftBindData != null)
  16216. {
  16217. ////JS/ES
  16218. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  16219. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  16220. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  16221. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16222. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16223. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16224. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16225. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16226. }
  16227. else
  16228. {
  16229. hideRowsList.Add(Row + startIndex + HideRows);
  16230. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16231. }
  16232. HideRows += 2;
  16233. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16234. if (leftBindData != null)
  16235. {
  16236. ////SUITE
  16237. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  16238. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  16239. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  16240. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16241. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16242. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16243. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16244. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16245. }
  16246. else
  16247. {
  16248. hideRowsList.Add(Row + startIndex + HideRows);
  16249. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16250. }
  16251. HideRows += 2;
  16252. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16253. if (leftBindData != null)
  16254. {
  16255. designer.SetDataSource("DJDRCB", leftBindData.cb);
  16256. designer.SetDataSource("DJRS", leftBindData.rs);
  16257. designer.SetDataSource("DJXS", leftBindData.xs);
  16258. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16259. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16260. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16261. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16262. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16263. }
  16264. else
  16265. {
  16266. hideRowsList.Add(Row + startIndex + HideRows);
  16267. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16268. }
  16269. HideRows += 2;
  16270. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16271. if (leftBindData != null)
  16272. {
  16273. designer.SetDataSource("HCPCB", leftBindData.cb);
  16274. designer.SetDataSource("HCPRS", leftBindData.rs);
  16275. designer.SetDataSource("HCPXS", leftBindData.xs);
  16276. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16277. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16278. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16279. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16280. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16281. }
  16282. else
  16283. {
  16284. hideRowsList.Add(Row + startIndex + HideRows);
  16285. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16286. }
  16287. HideRows += 2;
  16288. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16289. if (leftBindData != null)
  16290. {
  16291. designer.SetDataSource("CPCB", leftBindData.cb);
  16292. designer.SetDataSource("CPRS", leftBindData.rs);
  16293. designer.SetDataSource("CPXS", leftBindData.xs);
  16294. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16295. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16296. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16297. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16298. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16299. }
  16300. else
  16301. {
  16302. hideRowsList.Add(Row + startIndex + HideRows);
  16303. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16304. }
  16305. HideRows += 2;
  16306. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16307. if (leftBindData != null)
  16308. {
  16309. designer.SetDataSource("GWDRCD", leftBindData.cb);
  16310. designer.SetDataSource("GWRS", leftBindData.rs);
  16311. designer.SetDataSource("GWXS", leftBindData.xs);
  16312. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16313. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16314. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16315. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16316. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16317. }
  16318. else
  16319. {
  16320. hideRowsList.Add(Row + startIndex + HideRows);
  16321. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16322. }
  16323. HideRows += 2;
  16324. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16325. if (leftBindData != null)
  16326. {
  16327. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  16328. designer.SetDataSource("LYJRS", leftBindData.rs);
  16329. designer.SetDataSource("LYJXS", leftBindData.xs);
  16330. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16331. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16332. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16333. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16334. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16335. }
  16336. else
  16337. {
  16338. hideRowsList.Add(Row + startIndex + HideRows);
  16339. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  16340. }
  16341. #endregion
  16342. #region A段Right信息
  16343. var right = dto.rightInfo.Find(x => x.Type == "A");
  16344. if (right == null)
  16345. {
  16346. return Ok(jw);
  16347. }
  16348. HideRows += 4;
  16349. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16350. if (rightBindData != null)
  16351. {
  16352. //经济舱 + 双人间 TBR
  16353. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  16354. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  16355. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16356. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  16357. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16358. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16359. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16360. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16361. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16362. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16363. }
  16364. else
  16365. {
  16366. hideRowsList.Add(Row + startIndex + HideRows);
  16367. }
  16368. HideRows += 2;
  16369. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16370. if (rightBindData != null)
  16371. {
  16372. //经济舱 + 单人间 SGR
  16373. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  16374. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  16375. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16376. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  16377. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16378. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16379. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16380. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16381. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16382. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16383. }
  16384. else
  16385. {
  16386. hideRowsList.Add(Row + startIndex + HideRows);
  16387. }
  16388. HideRows += 2;
  16389. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16390. if (rightBindData != null)
  16391. {
  16392. //公务舱 + 单人间 SGR
  16393. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  16394. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  16395. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16396. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  16397. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16398. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16399. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16400. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16401. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16402. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16403. }
  16404. else
  16405. {
  16406. hideRowsList.Add(Row + startIndex + HideRows);
  16407. }
  16408. HideRows += 2;
  16409. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16410. if (rightBindData != null)
  16411. {
  16412. //公务舱 + 小套房 JSES
  16413. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  16414. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  16415. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16416. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  16417. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16418. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16419. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16420. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16421. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16422. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16423. }
  16424. else
  16425. {
  16426. hideRowsList.Add(Row + startIndex + HideRows);
  16427. }
  16428. HideRows += 2;
  16429. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16430. if (rightBindData != null)
  16431. {
  16432. //公务舱 + 小套房 JSES
  16433. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  16434. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  16435. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16436. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  16437. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16438. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16439. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16440. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16441. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16442. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16443. }
  16444. else
  16445. {
  16446. hideRowsList.Add(Row + startIndex + HideRows);
  16447. }
  16448. HideRows += 2;
  16449. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16450. if (rightBindData != null)
  16451. {
  16452. //经济舱 + 大套房
  16453. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  16454. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  16455. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16456. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  16457. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16458. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16459. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16460. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16461. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16462. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16463. }
  16464. else
  16465. {
  16466. hideRowsList.Add(Row + startIndex + HideRows);
  16467. }
  16468. HideRows += 2;
  16469. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16470. if (rightBindData != null)
  16471. {
  16472. //头等舱 + 小套房 JSES
  16473. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  16474. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  16475. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16476. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  16477. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16478. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16479. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16480. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16481. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16482. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16483. }
  16484. else
  16485. {
  16486. hideRowsList.Add(Row + startIndex + HideRows);
  16487. }
  16488. HideRows += 2;
  16489. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16490. if (rightBindData != null)
  16491. {
  16492. //头等舱 + 大套房
  16493. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  16494. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  16495. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16496. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  16497. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16498. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16499. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16500. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16501. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16502. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16503. }
  16504. else
  16505. {
  16506. hideRowsList.Add(Row + startIndex + HideRows);
  16507. }
  16508. #endregion
  16509. #region B段标题清空
  16510. designer.SetDataSource("CostBDRCB", "");
  16511. designer.SetDataSource("CostBRS", "");
  16512. designer.SetDataSource("CostBXS", "");
  16513. designer.SetDataSource("CostBZCB", "");
  16514. designer.SetDataSource("CostBDRBJ", "");
  16515. designer.SetDataSource("CostBZBJ", "");
  16516. designer.SetDataSource("CostBDRLR", "");
  16517. designer.SetDataSource("CostBZLR", "");
  16518. designer.SetDataSource("CostBDRCBOM", "");
  16519. designer.SetDataSource("CostBRSOM", "");
  16520. designer.SetDataSource("CostBZCBOM", "");
  16521. designer.SetDataSource("CostBDRBJOM", "");
  16522. designer.SetDataSource("CostBZBJOM", "");
  16523. designer.SetDataSource("CostBDRLROM", "");
  16524. designer.SetDataSource("CostBZLROM", "");
  16525. #endregion
  16526. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  16527. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  16528. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  16529. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  16530. designer.SetDataSource("DJName", "地接(CNY)");
  16531. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  16532. designer.SetDataSource("CPName", "地接-船票(CNY)");
  16533. designer.SetDataSource("GWName", "公务(CNY)");
  16534. designer.SetDataSource("YQHName", "邀请函(CNY)");
  16535. designer.SetDataSource("LYJName", "零用金(CNY)");
  16536. designer.SetDataSource("HSName", "核酸检测(CNY)");
  16537. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  16538. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  16539. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  16540. designer.SetDataSource("BXName", "保险(CNY)");
  16541. designer.SetDataSource("VisaName", "签证(CNY)");
  16542. #region B段基本数据
  16543. if (dto.costType == "B")
  16544. {
  16545. left = dto.leftInfo.Find(x => x.Type == "B");
  16546. if (left == null)
  16547. {
  16548. return Ok(jw);
  16549. }
  16550. #region B段left数据
  16551. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  16552. if (leftBindData != null)
  16553. {
  16554. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  16555. designer.SetDataSource("BHSRS", leftBindData.rs);
  16556. designer.SetDataSource("BHSXS", leftBindData.xs);
  16557. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16558. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16559. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16560. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16561. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16562. }
  16563. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  16564. if (leftBindData != null)
  16565. {
  16566. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  16567. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  16568. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  16569. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16570. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16571. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16572. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16573. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16574. }
  16575. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  16576. if (leftBindData != null)
  16577. {
  16578. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  16579. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  16580. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  16581. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16582. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16583. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16584. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16585. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16586. }
  16587. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  16588. if (leftBindData != null)
  16589. {
  16590. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  16591. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  16592. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  16593. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16594. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16595. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16596. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16597. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16598. }
  16599. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  16600. if (leftBindData != null)
  16601. {
  16602. designer.SetDataSource("BHCPCB", leftBindData.cb);
  16603. designer.SetDataSource("BHCPRS", leftBindData.rs);
  16604. designer.SetDataSource("BHCPXS", leftBindData.xs);
  16605. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16606. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16607. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16608. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16609. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16610. }
  16611. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  16612. if (leftBindData != null)
  16613. {
  16614. designer.SetDataSource("BCPCB", leftBindData.cb);
  16615. designer.SetDataSource("BCPRS", leftBindData.rs);
  16616. designer.SetDataSource("BCPXS", leftBindData.xs);
  16617. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16618. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16619. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16620. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16621. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16622. }
  16623. //TBR
  16624. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  16625. if (leftBindData != null)
  16626. {
  16627. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  16628. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  16629. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  16630. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16631. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16632. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16633. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16634. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16635. }
  16636. //SGR
  16637. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  16638. if (leftBindData != null)
  16639. {
  16640. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  16641. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  16642. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  16643. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16644. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16645. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16646. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16647. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16648. }
  16649. //JS/ES
  16650. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  16651. if (leftBindData != null)
  16652. {
  16653. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  16654. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  16655. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  16656. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16657. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16658. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16659. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16660. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16661. }
  16662. //SUITE
  16663. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  16664. if (leftBindData != null)
  16665. {
  16666. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  16667. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  16668. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  16669. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16670. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16671. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16672. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16673. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16674. }
  16675. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  16676. if (leftBindData != null)
  16677. {
  16678. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  16679. designer.SetDataSource("BDJRS", leftBindData.rs);
  16680. designer.SetDataSource("BDJXS", leftBindData.xs);
  16681. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16682. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16683. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16684. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16685. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16686. }
  16687. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  16688. if (leftBindData != null)
  16689. {
  16690. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  16691. designer.SetDataSource("BGWRS", leftBindData.rs);
  16692. designer.SetDataSource("BGWXS", leftBindData.xs);
  16693. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16694. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16695. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16696. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16697. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16698. }
  16699. #region 优化方案
  16700. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  16701. //excelBind.Add("零用金", new {
  16702. //cb="",
  16703. //rs="",
  16704. //xs ="",
  16705. //zcb = "",
  16706. //});
  16707. #endregion
  16708. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  16709. if (leftBindData != null)
  16710. {
  16711. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  16712. designer.SetDataSource("BLYJRS", leftBindData.rs);
  16713. designer.SetDataSource("BLYJXS", leftBindData.xs);
  16714. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  16715. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  16716. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  16717. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  16718. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  16719. }
  16720. #endregion
  16721. #region B段Right信息
  16722. right = dto.rightInfo.Find(x => x.Type == "B");
  16723. if (right == null)
  16724. {
  16725. return Ok(jw);
  16726. }
  16727. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  16728. if (rightBindData != null)
  16729. {
  16730. //经济舱 + 双人间 TBR
  16731. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  16732. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  16733. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16734. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  16735. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16736. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16737. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16738. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16739. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16740. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16741. }
  16742. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  16743. if (rightBindData != null)
  16744. {
  16745. //经济舱 + 单人间 SGR
  16746. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  16747. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  16748. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16749. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  16750. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16751. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16752. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16753. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16754. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16755. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16756. }
  16757. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  16758. if (rightBindData != null)
  16759. {
  16760. //公务舱 + 单人间 SGR
  16761. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  16762. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  16763. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16764. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  16765. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16766. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16767. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16768. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16769. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16770. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16771. }
  16772. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  16773. if (rightBindData != null)
  16774. {
  16775. //公务舱 + 小套房 JSES
  16776. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  16777. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  16778. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16779. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  16780. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16781. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16782. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16783. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16784. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16785. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16786. }
  16787. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  16788. if (rightBindData != null)
  16789. {
  16790. //公务舱 + 小套房 JSES
  16791. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  16792. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  16793. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16794. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  16795. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16796. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16797. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16798. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16799. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16800. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16801. }
  16802. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  16803. if (rightBindData != null)
  16804. {
  16805. //经济舱 + 大套房
  16806. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  16807. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  16808. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16809. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  16810. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16811. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16812. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16813. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16814. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16815. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16816. }
  16817. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  16818. if (rightBindData != null)
  16819. {
  16820. //头等舱 + 小套房 JSES
  16821. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  16822. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  16823. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16824. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  16825. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16826. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16827. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16828. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16829. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16830. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16831. }
  16832. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  16833. if (rightBindData != null)
  16834. {
  16835. //头等舱 + 大套房
  16836. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  16837. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  16838. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  16839. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  16840. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  16841. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  16842. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  16843. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  16844. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  16845. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  16846. }
  16847. #endregion
  16848. #region 标题
  16849. designer.SetDataSource("CostBDRCB", "单人成本");
  16850. designer.SetDataSource("CostBRS", "人数");
  16851. designer.SetDataSource("CostBXS", "系数");
  16852. designer.SetDataSource("CostBZCB", "总成本");
  16853. designer.SetDataSource("CostBDRBJ", "单人报价");
  16854. designer.SetDataSource("CostBZBJ", "总报价");
  16855. designer.SetDataSource("CostBDRLR", "单人利润");
  16856. designer.SetDataSource("CostBZLR", "总利润");
  16857. designer.SetDataSource("CostBDRCBOM", "单人成本");
  16858. designer.SetDataSource("CostBRSOM", "人数");
  16859. designer.SetDataSource("CostBZCBOM", "总成本");
  16860. designer.SetDataSource("CostBDRBJOM", "单人报价");
  16861. designer.SetDataSource("CostBZBJOM", "总报价");
  16862. designer.SetDataSource("CostBDRLROM", "单人利润");
  16863. designer.SetDataSource("CostBZLROM", "总利润");
  16864. #endregion
  16865. }
  16866. #endregion
  16867. designer.SetDataSource("TzZCB2", TzZCB2);
  16868. designer.SetDataSource("TzZBJ2", TzZBJ2);
  16869. designer.SetDataSource("TzZLR2", TzZLR2);
  16870. string[] dataSourceKeys = new string[]
  16871. {
  16872. "VF",
  16873. "TGS",
  16874. "TGOF",
  16875. "TGM",
  16876. "TGA",
  16877. "TGTF",
  16878. "TGEF",
  16879. "CFM",
  16880. "CFOF",
  16881. "B",
  16882. "L",
  16883. "D",
  16884. "TBR",
  16885. "SGR",
  16886. "JSES",
  16887. "Suite",
  16888. "TV",
  16889. "1L",
  16890. "IF",
  16891. "EF",
  16892. "BRF",
  16893. "TE",
  16894. "TGT",
  16895. "DRVT",
  16896. "PC",
  16897. "TLF",
  16898. "ECT"
  16899. };
  16900. foreach (var item in dataSourceKeys)
  16901. {
  16902. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  16903. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  16904. var find = dto.titleModel.FirstOrDefault(expr);
  16905. if (find != null)
  16906. {
  16907. designer.SetDataSource(item, find.text);
  16908. }
  16909. else
  16910. {
  16911. designer.SetDataSource(item, 0);
  16912. }
  16913. }
  16914. designer.SetDataSource(dt);
  16915. //根据数据源处理生成报表内容
  16916. designer.Process();
  16917. designer.Workbook.Worksheets[0].Name = "费用明细";
  16918. designer.Workbook.Worksheets[1].Name = "费用总核算";
  16919. Worksheet sheet = designer.Workbook.Worksheets[0];
  16920. #region 隐藏舱位
  16921. var settingAir = new[]
  16922. {
  16923. new { key = "经济舱", index = 7 },
  16924. new { key = "公务舱", index = 19 },
  16925. new { key = "头等舱", index = 11 }
  16926. };
  16927. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  16928. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  16929. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  16930. .Select((c, s) => s.Name)
  16931. .ToList()
  16932. .GroupBy(x => x)
  16933. .Select(x => x.Key);
  16934. foreach (var item in settingAir)
  16935. {
  16936. if (!airType.Contains(item.key))
  16937. {
  16938. hideRowsList.Add(item.index);
  16939. }
  16940. }
  16941. #endregion
  16942. foreach (var Rowindex in hideRowsList)
  16943. {
  16944. ws.Cells.HideRows(Rowindex, 2);
  16945. }
  16946. ws = designer.Workbook.Worksheets[0];
  16947. foreach (var Column in hideColumnList)
  16948. {
  16949. ws.Cells.HideColumns(Column, 1);
  16950. }
  16951. byte[] bytes = null;
  16952. string strFileName = di.TeamName + "-团组-成本.xls";
  16953. using (MemoryStream stream = new MemoryStream())
  16954. {
  16955. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  16956. bytes = stream.ToArray();
  16957. }
  16958. return Ok(JsonView(true, "", new
  16959. {
  16960. Data = bytes,
  16961. strFileName,
  16962. }));
  16963. }
  16964. /// <summary>
  16965. /// 导出客户报表
  16966. /// </summary>
  16967. /// <returns></returns>
  16968. [HttpPost]
  16969. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  16970. {
  16971. var jw = JsonView(false);
  16972. if (dto.Diid == 0)
  16973. {
  16974. return Ok(JsonView(false, "请传递团组id"));
  16975. }
  16976. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  16977. if (deleInfo.Code != 0)
  16978. {
  16979. return Ok(JsonView(false, "团组信息查询失败!"));
  16980. }
  16981. var di = deleInfo.Data as DelegationInfoWebView;
  16982. if (di == null)
  16983. {
  16984. return Ok(JsonView(false, "团组信息查询失败!"));
  16985. }
  16986. //文件名
  16987. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  16988. //获取模板
  16989. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  16990. //载入模板
  16991. Document doc = new Document(tmppath);
  16992. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  16993. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  16994. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  16995. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  16996. var AParameter = ParameterList.Find(x => x.CostType == "A");
  16997. var BParameter = ParameterList.Find(x => x.CostType == "B");
  16998. if (AParameter == null)
  16999. {
  17000. return Ok(JsonView(false, "系数不存在!"));
  17001. }
  17002. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  17003. , TzAirDesc, TzZCost;
  17004. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  17005. = TzAirDesc = TzZCost = string.Empty;
  17006. TzNumber = AParameter.CostTypenumber.ToString();
  17007. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  17008. CarGuides1 = dto.CarGuides1;
  17009. Meal = dto.Meal;
  17010. SubsidizedMeals = dto.SubsidizedMeals;
  17011. NightRepair = dto.NightRepair;
  17012. AttractionsTickets = dto.AttractionsTickets;
  17013. MiscellaneousFees = dto.MiscellaneousFees;
  17014. ATip = dto.ATip;
  17015. TzHotelDesc = "";
  17016. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  17017. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  17018. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  17019. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  17020. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  17021. TzAirDesc = "";
  17022. TzZCost = dto.TzZCost;
  17023. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  17024. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  17025. var index = 1;
  17026. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  17027. foreach (var item in TzHotelDescArr)
  17028. {
  17029. if (AinfoArr != null)
  17030. {
  17031. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17032. if (Ainfo != null)
  17033. {
  17034. if (int.Parse(Ainfo.rs) <= 0)
  17035. {
  17036. continue;
  17037. }
  17038. var hotelText = string.Empty;
  17039. switch (item)
  17040. {
  17041. case "SGR":
  17042. hotelText = "单人间";
  17043. break;
  17044. case "JSES":
  17045. hotelText = "小套房";
  17046. break;
  17047. case "SUITE":
  17048. hotelText = "套房";
  17049. break;
  17050. case "TBR":
  17051. hotelText = "双人间";
  17052. break;
  17053. }
  17054. if (item != "TBR")
  17055. {
  17056. 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";
  17057. }
  17058. else
  17059. {
  17060. 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";
  17061. }
  17062. index++;
  17063. }
  17064. }
  17065. }
  17066. index = 1;
  17067. foreach (var item in TzAirDescArr)
  17068. {
  17069. if (AinfoArr != null)
  17070. {
  17071. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17072. if (Ainfo != null)
  17073. {
  17074. if (int.Parse(Ainfo.rs) <= 0)
  17075. {
  17076. continue;
  17077. }
  17078. 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";
  17079. index++;
  17080. }
  17081. }
  17082. }
  17083. if (dto.costType == "B")
  17084. {
  17085. if (BParameter == null)
  17086. {
  17087. return Ok(JsonView(false, "B段系数不存在!"));
  17088. }
  17089. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  17090. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  17091. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  17092. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  17093. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  17094. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  17095. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  17096. foreach (var item in TzHotelDescArr)
  17097. {
  17098. if (AinfoArr != null)
  17099. {
  17100. TzHotelDesc += "B段信息 \r\n";
  17101. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17102. if (Ainfo != null)
  17103. {
  17104. if (int.Parse(Ainfo.rs) <= 0)
  17105. {
  17106. continue;
  17107. }
  17108. var hotelText = string.Empty;
  17109. switch (item)
  17110. {
  17111. case "SGR":
  17112. hotelText = "单人间";
  17113. break;
  17114. case "JSES":
  17115. hotelText = "小套房";
  17116. break;
  17117. case "SUITE":
  17118. hotelText = "套房";
  17119. break;
  17120. case "TBR":
  17121. hotelText = "双人间";
  17122. break;
  17123. }
  17124. if (item != "TBR")
  17125. {
  17126. 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";
  17127. }
  17128. else
  17129. {
  17130. 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";
  17131. }
  17132. index++;
  17133. }
  17134. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  17135. }
  17136. }
  17137. index = 1;
  17138. foreach (var item in TzAirDescArr)
  17139. {
  17140. if (AinfoArr != null)
  17141. {
  17142. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  17143. if (Ainfo != null)
  17144. {
  17145. if (int.Parse(Ainfo.rs) <= 0)
  17146. {
  17147. continue;
  17148. }
  17149. 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";
  17150. index++;
  17151. }
  17152. }
  17153. }
  17154. }
  17155. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  17156. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  17157. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  17158. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  17159. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  17160. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  17161. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  17162. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  17163. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  17164. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  17165. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  17166. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  17167. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  17168. DickeyValue.Add("Visa", Visa); // 签证单人报价
  17169. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  17170. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  17171. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  17172. DickeyValue.Add("TzZCost", TzZCost);
  17173. foreach (var key in DickeyValue.Keys)
  17174. {
  17175. if (doc.Range.Bookmarks[key] != null)
  17176. {
  17177. Bookmark mark = doc.Range.Bookmarks[key];
  17178. mark.Text = DickeyValue[key];
  17179. }
  17180. }
  17181. byte[] bytes = null;
  17182. string strFileName = di.TeamName + "-客户报价.doc";
  17183. using (MemoryStream stream = new MemoryStream())
  17184. {
  17185. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  17186. bytes = stream.ToArray();
  17187. }
  17188. return Ok(JsonView(true, "", new
  17189. {
  17190. Data = bytes,
  17191. strFileName,
  17192. }));
  17193. }
  17194. /// <summary>
  17195. /// 团组成本 各模块(酒店,地接,机票)成本提示
  17196. /// </summary>
  17197. /// <param name="dto"></param>
  17198. /// <returns></returns>
  17199. [HttpPost]
  17200. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  17201. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  17202. {
  17203. try
  17204. {
  17205. #region 参数验证
  17206. if (dto.DiId < 0)
  17207. {
  17208. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  17209. }
  17210. List<int> cTableIds = new List<int>() {
  17211. 76 ,//酒店预订
  17212. 77 ,//行程
  17213. 79 ,//车/导游地接
  17214. 80 ,//签证
  17215. 81 ,//邀请/公务活
  17216. 82 ,//团组客户保险
  17217. 85 ,//机票预订
  17218. 98 ,//其他款项
  17219. 285 ,//收款退还
  17220. 751 ,//酒店早餐
  17221. 1015 // 超支费用
  17222. };
  17223. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  17224. {
  17225. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  17226. }
  17227. #endregion
  17228. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  17229. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  17230. if (_GroupCostParameters.Count <= 0)
  17231. {
  17232. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  17233. }
  17234. if (_GroupCostParameters[0].IsShare == 0)
  17235. {
  17236. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  17237. }
  17238. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17239. //处理date为空问题
  17240. if (_GroupCosts.Count > 0)
  17241. {
  17242. for (int i = 0; i < _GroupCosts.Count; i++)
  17243. {
  17244. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  17245. {
  17246. if (i > 0)
  17247. {
  17248. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  17249. }
  17250. }
  17251. }
  17252. }
  17253. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  17254. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  17255. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  17256. string currCode = "";
  17257. #region currCode 验证
  17258. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  17259. if (isInt)
  17260. {
  17261. var currData = currDatas.Find(it => it.Id == intCurrency);
  17262. if (currData != null)
  17263. {
  17264. currCode = currData.Name;
  17265. }
  17266. }
  17267. else
  17268. {
  17269. currCode = _GroupCostParameters[0].Currency.Trim();
  17270. }
  17271. #endregion
  17272. //op,酒店单段模式存储
  17273. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  17274. {
  17275. CurrencyCode = currCode,
  17276. Rate = _GroupCostParameters[0].Rate,
  17277. CostType = _GroupCostParameters[0].CostType,
  17278. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  17279. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  17280. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  17281. };
  17282. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  17283. if (_GroupCostParameters.Count == 2)
  17284. {
  17285. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  17286. }
  17287. foreach (var item in _GroupCostParameters)
  17288. {
  17289. decimal _rate = 1;
  17290. decimal _rate1 = item.Rate;
  17291. decimal _scale = 1;
  17292. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  17293. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  17294. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  17295. //if (userInfo != null)
  17296. //{
  17297. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  17298. // {
  17299. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  17300. // {
  17301. // _scale = 1.00M;
  17302. // }
  17303. // }
  17304. //}
  17305. #endregion
  17306. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  17307. {
  17308. CurrencyCode = currCode,
  17309. Rate = _rate1,
  17310. CostType = item.CostType,
  17311. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  17312. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  17313. CostTypeNumber = item.CostTypenumber
  17314. };
  17315. if (_GroupCostParameters.Count > 1)
  17316. {
  17317. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  17318. }
  17319. else
  17320. {
  17321. modulePromptInfo.CostTypeNumber = item.LYJRS;
  17322. }
  17323. if (dto.CTable == 79)//
  17324. {
  17325. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  17326. modulePromptInfo.TotalCost = item.DJCB;
  17327. }
  17328. List<string> costTypes = new List<string>() { "A", "B" };
  17329. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  17330. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  17331. if (_GroupCostsDuplicates.Count() == 1)
  17332. {
  17333. _GroupCostsTypeData = _GroupCosts;
  17334. }
  17335. else
  17336. {
  17337. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  17338. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  17339. }
  17340. /*
  17341. * 76 酒店预订
  17342. * 77 行程
  17343. * 79 车/导游地接
  17344. * 80 签证
  17345. * 81 邀请/公务活动
  17346. * 82 团组客户保险
  17347. * 85 机票预订
  17348. * 98 其他款项
  17349. * 285 收款退还
  17350. * 751 酒店早餐
  17351. * 1015 超支费用
  17352. */
  17353. switch (dto.CTable)
  17354. {
  17355. case 76: // 酒店预订
  17356. _ModuleSubPromptInfo.AddRange(
  17357. _GroupCostsTypeData.Select(it => new
  17358. {
  17359. it.DAY,
  17360. it.Date,
  17361. it.ACCON,
  17362. it.ITIN,
  17363. it.SGR,
  17364. it.TBR,
  17365. it.JS_ES,
  17366. it.Suite
  17367. })
  17368. );
  17369. break;
  17370. case 79: // 车/导游地接
  17371. _ModuleSubPromptInfo.AddRange(
  17372. _GroupCostsTypeData.Select(it => new
  17373. {
  17374. Date = it.Date, //日期
  17375. CarFee = it.CarCost * _rate * _scale, //车费用
  17376. CarType = it.CarType, //车型
  17377. DriverFee = it.CFS * _rate * _scale, //司机工资
  17378. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  17379. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  17380. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  17381. GuideFee = it.TGS * _rate * _scale, //导游费用
  17382. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  17383. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  17384. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  17385. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  17386. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  17387. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  17388. Breakfast = it.B * _rate * _scale, //早餐费
  17389. Lunch = it.L * _rate * _scale, //午餐费
  17390. Dinner = it.D * _rate * _scale, //晚餐费
  17391. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  17392. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  17393. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  17394. TicketFee = it.EF * _rate * _scale, //门票费
  17395. TicketRemark = it.EFR, //门票费描述
  17396. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  17397. TravelSupplies = it.TE * _rate * _scale, //出行物资
  17398. SpentCash = it.PC * _rate * _scale, //零用金
  17399. LeadersFee = it.TLF * _rate * _scale, //领队费
  17400. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  17401. })
  17402. );
  17403. break;
  17404. case 85: // 机票
  17405. List<dynamic> datas = new List<dynamic>();
  17406. datas.Add(
  17407. new
  17408. {
  17409. AirType = "经济舱",
  17410. AirNum = item.JJCRS,
  17411. AirDRCB = item.JJCCB,
  17412. AirZCB = (item.JJCRS * item.JJCCB)
  17413. }
  17414. );
  17415. datas.Add(
  17416. new
  17417. {
  17418. AirType = "公务舱",
  17419. AirNum = item.GWCRS,
  17420. AirDRCB = item.GWCCB,
  17421. AirZCB = (item.GWCRS * item.GWCCB)
  17422. }
  17423. );
  17424. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  17425. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  17426. modulePromptInfo.Data = new
  17427. {
  17428. airFeeData = datas,
  17429. airInitData = initDatas
  17430. };
  17431. _ModulePromptInfos.Add(modulePromptInfo);
  17432. break;
  17433. default:
  17434. break;
  17435. }
  17436. }
  17437. if (dto.CTable != 85)
  17438. {
  17439. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  17440. _ModulePromptInfos.Add(_ModulePromptInfo);
  17441. }
  17442. _view.ModulePromptInfos = _ModulePromptInfos;
  17443. return Ok(JsonView(true, "操作成功!", _view));
  17444. }
  17445. catch (Exception ex)
  17446. {
  17447. return Ok(JsonView(false, ex.Message));
  17448. }
  17449. }
  17450. /// <summary>
  17451. /// 根据黑屏代码重新生成行程
  17452. /// </summary>
  17453. /// <param name="dto"></param>
  17454. /// <returns></returns>
  17455. [HttpPost]
  17456. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  17457. {
  17458. var jw = JsonView(false, "Error");
  17459. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  17460. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  17461. .Select(x => new
  17462. {
  17463. x.Id,
  17464. x.Title
  17465. })
  17466. .ToList();
  17467. if (Create.Any())
  17468. {
  17469. jw.Msg = "获取成功!";
  17470. jw.Code = 200;
  17471. jw.Data = new
  17472. {
  17473. BlackCodeListSelect = Create,
  17474. blackCodeIsTrue = true
  17475. };
  17476. }
  17477. else
  17478. {
  17479. jw.Code = 400;
  17480. jw.Data = new
  17481. {
  17482. BlackCodeListSelect = Create,
  17483. blackCodeIsTrue = false,
  17484. };
  17485. }
  17486. return Ok(jw);
  17487. }
  17488. /// <summary>
  17489. /// 根据黑屏代码Id重新生成行程
  17490. /// </summary>
  17491. /// <param name="dto"></param>
  17492. /// <returns></returns>
  17493. [HttpPost]
  17494. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  17495. {
  17496. var jw = JsonView(false, "Error");
  17497. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  17498. if (result.Code == 0)
  17499. {
  17500. jw.Msg = "获取成功!";
  17501. jw.Code = 200;
  17502. jw.Data = new
  17503. {
  17504. groupCost = result.Data,
  17505. blackCodeIsTrue = true
  17506. };
  17507. }
  17508. else
  17509. {
  17510. jw.Code = 400;
  17511. jw.Data = new
  17512. {
  17513. groupCost = result.Data,
  17514. blackCodeIsTrue = false,
  17515. };
  17516. }
  17517. return Ok(jw);
  17518. }
  17519. /// <summary>
  17520. /// 成本获取OP历史车费用
  17521. /// </summary>
  17522. /// <param name="dto"></param>
  17523. /// <returns></returns>
  17524. [HttpPost]
  17525. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  17526. {
  17527. var jw = JsonView(false);
  17528. try
  17529. {
  17530. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  17531. //获取现有所有车的数据
  17532. if (!dto.Param.IsNullOrWhiteSpace())
  17533. {
  17534. string sql = $@"
  17535. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  17536. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  17537. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  17538. 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
  17539. AND gctggr.ServiceEndTime is not NULL
  17540. ORDER by gctggrc.id DESC
  17541. ";
  17542. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  17543. var numeberResult = await Task.Run(() =>
  17544. {
  17545. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  17546. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  17547. return numberArr;
  17548. });
  17549. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  17550. foreach (var item in numeberResult)
  17551. {
  17552. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  17553. {
  17554. Country = "数据异常!",
  17555. City = string.Empty,
  17556. };
  17557. item.Area = find.Country + " " + find.City;
  17558. }
  17559. dbResult.AddRange(numeberResult);
  17560. if (dto.Param.Contains("、"))
  17561. {
  17562. var sp = dto.Param.Split("、");
  17563. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17564. .Where(x =>
  17565. {
  17566. return System.Array.Exists(sp, e =>
  17567. {
  17568. bool where = false;
  17569. if (x.Area != null)
  17570. {
  17571. where = x.Area.Contains(e);
  17572. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17573. {
  17574. return false;
  17575. }
  17576. }
  17577. if (x.PriceName != null && !where)
  17578. {
  17579. where = x.PriceName.Contains(e);
  17580. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17581. {
  17582. return false;
  17583. }
  17584. }
  17585. return where;
  17586. });
  17587. }).ToList();
  17588. }
  17589. else
  17590. {
  17591. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  17592. .Where(x =>
  17593. {
  17594. bool where = false;
  17595. if (x.Area != null)
  17596. {
  17597. where = x.Area.Contains(dto.Param);
  17598. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  17599. {
  17600. return false;
  17601. }
  17602. }
  17603. if (x.PriceName != null && !where)
  17604. {
  17605. where = x.PriceName.Contains(dto.Param);
  17606. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  17607. {
  17608. return false;
  17609. }
  17610. }
  17611. return where;
  17612. }
  17613. )
  17614. .ToList();
  17615. }
  17616. }
  17617. var view = dbResult.Select(x =>
  17618. {
  17619. decimal dp = 0.00M;
  17620. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  17621. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  17622. if (string.IsNullOrWhiteSpace(x.DatePrice))
  17623. {
  17624. if (startB && endB)
  17625. {
  17626. var timesp = endD.Subtract(startD);
  17627. if ((timesp.Days + 1) != 0)
  17628. {
  17629. dp = x.Price / (timesp.Days + 1);
  17630. }
  17631. }
  17632. }
  17633. else
  17634. {
  17635. dp = x.Price;
  17636. }
  17637. return new
  17638. {
  17639. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  17640. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  17641. x.Area,
  17642. x.id,
  17643. price = x.Price.ToString("F2"),
  17644. x.PriceName,
  17645. x.PriceContent,
  17646. x.TeamName,
  17647. x.DatePrice,
  17648. dayPrice = dp.ToString("F2"),
  17649. };
  17650. }).OrderByDescending(x => x.id).ToList();
  17651. jw = JsonView(true, "获取成功!", view);
  17652. }
  17653. catch (Exception e)
  17654. {
  17655. jw = JsonView(false, e.Message);
  17656. }
  17657. return Ok(jw);
  17658. }
  17659. [HttpPost]
  17660. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  17661. {
  17662. var jw = JsonView(true);
  17663. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  17664. #region SQL语句
  17665. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  17666. //{
  17667. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17668. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17669. // WHEN COUNT(*) >= 0 THEN 'True'
  17670. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17671. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  17672. // ")
  17673. // .ToList();
  17674. //}
  17675. //else
  17676. //{
  17677. // string likeKey = string.Empty;
  17678. // foreach (var item in dto.Keyword)
  17679. // {
  17680. // likeKey += "%" + item;
  17681. // }
  17682. // likeKey += "%";
  17683. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17684. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17685. // WHEN COUNT(*) >= 0 THEN 'True'
  17686. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17687. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  17688. // ")
  17689. // .ToList();
  17690. //}
  17691. #endregion
  17692. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  17693. {
  17694. @KeyWord = dto.Keyword
  17695. });
  17696. if (table != null && table.Rows.Count > 0)
  17697. {
  17698. foreach (DataRow row in table.Rows)
  17699. {
  17700. matches.Add(new DelegationInfoAndIsTrueView
  17701. {
  17702. Id = row.Field<int>("Id"),
  17703. GroupName = row.Field<string>("GroupName"),
  17704. isTrue = row.Field<string>("isTrue")
  17705. });
  17706. }
  17707. }
  17708. if (matches.Any())
  17709. {
  17710. jw.Data = matches;
  17711. }
  17712. else
  17713. {
  17714. jw.Code = 201;
  17715. jw.Msg = "empty list";
  17716. jw.Data = new List<string>(1);
  17717. }
  17718. return Ok(jw);
  17719. }
  17720. /// <summary>
  17721. /// 报价Word下载
  17722. /// </summary>
  17723. /// <param name="dto"></param>
  17724. /// <returns></returns>
  17725. [HttpPost]
  17726. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  17727. {
  17728. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17729. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  17730. if (di == null)
  17731. {
  17732. return Ok(JsonView(false, "团组不存在!"));
  17733. }
  17734. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17735. if (mainPrice == null || mainPrice.IsShare == 0)
  17736. {
  17737. return Ok(JsonView(false, "团组成本不存在!"));
  17738. }
  17739. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  17740. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  17741. if (costTypeHotelNumbers == null)
  17742. {
  17743. return Ok(JsonView(false, "团组成本不存在!"));
  17744. }
  17745. //文件名
  17746. string strFileName = di.TeamName + "-收款账单.doc";
  17747. //获取模板
  17748. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  17749. //载入模板
  17750. Document doc = new Document(tmppath);
  17751. decimal allPrice = 0.00M;
  17752. string itemStr = string.Empty;
  17753. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  17754. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  17755. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  17756. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  17757. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  17758. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  17759. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  17760. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  17761. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  17762. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  17763. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  17764. {
  17765. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  17766. ("BXRS", "BXCB", "BXXS", "bx"),
  17767. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  17768. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  17769. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  17770. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  17771. ("CPRS", "CPCB", "CPXS", "cp"),
  17772. ("HSRS", "HSCB", "HSXS", "hsjc"),
  17773. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  17774. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  17775. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  17776. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  17777. ("DJRS", "DJCB", "DJXS", "dj"),
  17778. ("GWRS", "GWCB", "GWXS", "gw"),
  17779. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  17780. };
  17781. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  17782. var rightSum = 0.00M;
  17783. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  17784. {
  17785. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  17786. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  17787. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  17788. if (prefix == "tbr")
  17789. {
  17790. rsValue *= 2;
  17791. cbValue /= 2;
  17792. }
  17793. if (OtherCostPropertyBJ.Contains(prefix))
  17794. {
  17795. rightSum += cbValue * xsValue;
  17796. }
  17797. }
  17798. var hotelRooms = new Dictionary<string, int>
  17799. {
  17800. { "SGR", costTypeHotelNumbers.SGR },
  17801. { "TBR", costTypeHotelNumbers.TBR },
  17802. { "JSES", costTypeHotelNumbers.JSES },
  17803. { "SUITE", costTypeHotelNumbers.SUITE }
  17804. };
  17805. var flights = new Dictionary<string, int>
  17806. {
  17807. { "经济舱", mainPrice.JJCRS },
  17808. { "公务舱", mainPrice.GWCRS },
  17809. { "头等舱", mainPrice.TDCRS }
  17810. };
  17811. var flightRoomMatchingRules = new Dictionary<string, string[]>
  17812. {
  17813. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  17814. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  17815. { "头等舱", new[] { "SUITE", "JSES" } }
  17816. };
  17817. var result = new Dictionary<string, int>();
  17818. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  17819. foreach (var flight in flights.Keys)
  17820. {
  17821. // 获取当前舱位的匹配规则
  17822. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  17823. {
  17824. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  17825. }
  17826. }
  17827. #region right计算
  17828. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  17829. {
  17830. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17831. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  17832. airHotelPriceList.Add(new
  17833. AirHotelPrice
  17834. {
  17835. Name = "经济舱TBR",
  17836. Price = rightSum + air + hotel,
  17837. Count = result["经济舱TBR"] * 2
  17838. });
  17839. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  17840. }
  17841. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  17842. {
  17843. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17844. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17845. airHotelPriceList.Add(new
  17846. AirHotelPrice
  17847. {
  17848. Name = "经济舱SGR",
  17849. Price = rightSum + air + hotel,
  17850. Count = result["经济舱SGR"]
  17851. });
  17852. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  17853. }
  17854. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  17855. {
  17856. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17857. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  17858. airHotelPriceList.Add(new
  17859. AirHotelPrice
  17860. {
  17861. Name = "公务舱SGR",
  17862. Price = rightSum + air + hotel,
  17863. Count = result["公务舱SGR"]
  17864. });
  17865. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  17866. }
  17867. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  17868. {
  17869. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17870. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17871. airHotelPriceList.Add(new
  17872. AirHotelPrice
  17873. {
  17874. Name = "公务舱JSES",
  17875. Price = rightSum + air + hotel,
  17876. Count = result["公务舱JSES"]
  17877. });
  17878. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  17879. }
  17880. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  17881. {
  17882. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  17883. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17884. airHotelPriceList.Add(new
  17885. AirHotelPrice
  17886. {
  17887. Name = "公务舱SUITE",
  17888. Price = rightSum + air + hotel,
  17889. Count = result["公务舱SUITE"]
  17890. });
  17891. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  17892. }
  17893. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  17894. {
  17895. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17896. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17897. airHotelPriceList.Add(new
  17898. AirHotelPrice
  17899. {
  17900. Name = "经济舱SUITE",
  17901. Price = rightSum + air + hotel,
  17902. Count = result["经济舱SUITE"]
  17903. });
  17904. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  17905. }
  17906. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  17907. {
  17908. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17909. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17910. airHotelPriceList.Add(new
  17911. AirHotelPrice
  17912. {
  17913. Name = "头等舱JSES",
  17914. Price = rightSum + air + hotel,
  17915. Count = result["头等舱JSES"]
  17916. });
  17917. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  17918. }
  17919. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  17920. {
  17921. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  17922. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  17923. airHotelPriceList.Add(new
  17924. AirHotelPrice
  17925. {
  17926. Name = "头等舱SUITE",
  17927. Price = rightSum + air + hotel,
  17928. Count = result["头等舱SUITE"]
  17929. });
  17930. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  17931. }
  17932. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  17933. {
  17934. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  17935. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  17936. airHotelPriceList.Add(new
  17937. AirHotelPrice
  17938. {
  17939. Name = "经济舱JSES",
  17940. Price = rightSum + air + hotel,
  17941. Count = result["经济舱JSES"]
  17942. });
  17943. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  17944. }
  17945. #endregion
  17946. foreach (var item in airSouer.Keys)
  17947. {
  17948. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  17949. if (find != null && find.Count > 0)
  17950. {
  17951. if (item.Contains("TBR"))
  17952. {
  17953. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17954. }
  17955. else
  17956. {
  17957. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  17958. }
  17959. }
  17960. }
  17961. #region 替换Word模板书签内容
  17962. Dictionary<string, string> marks = new Dictionary<string, string>();
  17963. marks.Add("To", di.ClientUnit);//付款方
  17964. marks.Add("ToTel", di.TellPhone);//付款方电话
  17965. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17966. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17967. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17968. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17969. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17970. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17971. marks.Add("PayItemContent", itemStr);//详细信息
  17972. marks.Add("Total", allPrice.ToString("F2"));//合计
  17973. #endregion
  17974. foreach (var item in marks.Keys)
  17975. {
  17976. if (doc.Range.Bookmarks[item] != null)
  17977. {
  17978. Bookmark mark = doc.Range.Bookmarks[item];
  17979. mark.Text = marks[item];
  17980. }
  17981. }
  17982. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  17983. doc.Save(savePaht);
  17984. var jw = new JsonView();
  17985. jw.Msg = "生成成功!";
  17986. jw.Code = 200;
  17987. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  17988. return Ok(jw);
  17989. }
  17990. /// <summary>
  17991. /// 详细报价费用Excel下载
  17992. /// </summary>
  17993. /// <param name="dto"></param>
  17994. /// <returns></returns>
  17995. [HttpPost]
  17996. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  17997. {
  17998. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  17999. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  18000. if (di == null)
  18001. {
  18002. return Ok(JsonView(false, "团组不存在!"));
  18003. }
  18004. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  18005. if (mainPrice == null || mainPrice.IsShare == 0)
  18006. {
  18007. return Ok(JsonView(false, "团组成本不存在!"));
  18008. }
  18009. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  18010. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  18011. if (costTypeHotelNumbers == null)
  18012. {
  18013. return Ok(JsonView(false, "团组成本不存在!"));
  18014. }
  18015. WorkbookDesigner designer = new WorkbookDesigner();
  18016. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  18017. List<int> hideRowsList = new List<int>();
  18018. int conterStartIndex = 3;
  18019. int rowIndex = conterStartIndex;
  18020. designer.SetDataSource("GroupName", di.TeamName);
  18021. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  18022. {
  18023. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  18024. ("BXRS", "BXCB", "BXXS", "bx"),
  18025. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  18026. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  18027. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  18028. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  18029. ("CPRS", "CPCB", "CPXS", "cp") ,
  18030. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  18031. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  18032. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  18033. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  18034. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  18035. ("DJRS", "DJCB", "DJXS", "dj") ,
  18036. ("GWRS", "GWCB", "GWXS", "gw") ,
  18037. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  18038. };
  18039. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  18040. var rightSum = 0.00M;
  18041. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  18042. {
  18043. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  18044. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  18045. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  18046. if (prefix == "tbr")
  18047. {
  18048. rsValue *= 2;
  18049. cbValue /= 2;
  18050. }
  18051. if (OtherCostPropertyBJ.Contains(prefix))
  18052. {
  18053. rightSum += cbValue * xsValue;
  18054. }
  18055. if (rsValue == 0)
  18056. {
  18057. hideRowsList.Add(rowIndex);
  18058. }
  18059. else
  18060. {
  18061. designer.SetDataSource($"{prefix}rs", rsValue);
  18062. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  18063. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  18064. }
  18065. rowIndex += 2;
  18066. }
  18067. var hotelRooms = new Dictionary<string, int>
  18068. {
  18069. { "SGR", costTypeHotelNumbers.SGR },
  18070. { "TBR", costTypeHotelNumbers.TBR },
  18071. { "JSES", costTypeHotelNumbers.JSES },
  18072. { "SUITE", costTypeHotelNumbers.SUITE }
  18073. };
  18074. var flights = new Dictionary<string, int>
  18075. {
  18076. { "经济舱", mainPrice.JJCRS },
  18077. { "公务舱", mainPrice.GWCRS },
  18078. { "头等舱", mainPrice.TDCRS }
  18079. };
  18080. var flightRoomMatchingRules = new Dictionary<string, string[]>
  18081. {
  18082. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  18083. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  18084. { "头等舱", new[] { "SUITE", "JSES" } }
  18085. };
  18086. var result = new Dictionary<string, int>();
  18087. foreach (var flight in flights.Keys)
  18088. {
  18089. // 获取当前舱位的匹配规则
  18090. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  18091. {
  18092. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  18093. }
  18094. }
  18095. var allPrice = 0.00M;
  18096. #region right计算
  18097. int airRowIndex = 35;
  18098. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  18099. {
  18100. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18101. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  18102. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  18103. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  18104. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  18105. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  18106. }
  18107. else
  18108. {
  18109. hideRowsList.Add(airRowIndex);
  18110. }
  18111. airRowIndex += 2;
  18112. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  18113. {
  18114. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18115. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  18116. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  18117. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  18118. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  18119. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  18120. }
  18121. else
  18122. {
  18123. hideRowsList.Add(airRowIndex);
  18124. }
  18125. airRowIndex += 2;
  18126. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  18127. {
  18128. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18129. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  18130. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  18131. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  18132. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  18133. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  18134. }
  18135. else
  18136. {
  18137. hideRowsList.Add(airRowIndex);
  18138. }
  18139. airRowIndex += 2;
  18140. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  18141. {
  18142. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18143. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18144. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  18145. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  18146. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  18147. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  18148. }
  18149. else
  18150. {
  18151. hideRowsList.Add(airRowIndex);
  18152. }
  18153. airRowIndex += 2;
  18154. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  18155. {
  18156. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  18157. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18158. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  18159. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  18160. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  18161. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  18162. }
  18163. else
  18164. {
  18165. hideRowsList.Add(airRowIndex);
  18166. }
  18167. airRowIndex += 2;
  18168. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  18169. {
  18170. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18171. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18172. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  18173. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  18174. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  18175. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  18176. }
  18177. else
  18178. {
  18179. hideRowsList.Add(airRowIndex);
  18180. }
  18181. airRowIndex += 2;
  18182. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  18183. {
  18184. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18185. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18186. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  18187. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  18188. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  18189. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  18190. }
  18191. else
  18192. {
  18193. hideRowsList.Add(airRowIndex);
  18194. }
  18195. airRowIndex += 2;
  18196. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  18197. {
  18198. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  18199. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  18200. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  18201. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  18202. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  18203. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  18204. }
  18205. else
  18206. {
  18207. hideRowsList.Add(airRowIndex);
  18208. }
  18209. airRowIndex += 2;
  18210. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  18211. {
  18212. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  18213. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  18214. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  18215. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  18216. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  18217. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  18218. }
  18219. else
  18220. {
  18221. hideRowsList.Add(airRowIndex);
  18222. }
  18223. #endregion
  18224. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  18225. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  18226. var ws = designer.Workbook.Worksheets[0];
  18227. foreach (var Rowindex in hideRowsList)
  18228. {
  18229. ws.Cells.HideRows(Rowindex, 2);
  18230. }
  18231. designer.Process();
  18232. designer.Workbook.Save(savePaht);
  18233. return Ok(JsonView(true, "生成成功!", new
  18234. {
  18235. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  18236. }));
  18237. }
  18238. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  18239. {
  18240. foreach (var roomType in roomTypes)
  18241. {
  18242. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  18243. {
  18244. hotelRooms[roomType]--;
  18245. flights[flightType]--;
  18246. if (roomType == "TBR")
  18247. {
  18248. flights[flightType]--; // 双人间在减少1
  18249. }
  18250. string key = flightType + roomType;
  18251. if (result.Keys.Contains(key))
  18252. {
  18253. result[key]++;
  18254. }
  18255. else
  18256. {
  18257. result.Add(key, 1);
  18258. }
  18259. }
  18260. }
  18261. }
  18262. private class AirHotelPrice
  18263. {
  18264. public string Name { get; set; }
  18265. public decimal Price { get; set; }
  18266. public int Count { get; set; }
  18267. }
  18268. /// <summary>
  18269. /// 团组系数设置
  18270. /// </summary>
  18271. /// <param name="dto"></param>
  18272. /// <returns></returns>
  18273. [HttpPost]
  18274. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  18275. {
  18276. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  18277. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  18278. if (di == null)
  18279. {
  18280. return Ok(JsonView(false, "团组不存在!"));
  18281. }
  18282. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  18283. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  18284. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  18285. // FirstAsync(firstExpression.ToExpression());
  18286. #region JSON
  18287. string hcpJson = @"
  18288. [
  18289. {
  18290. ""min"": 1,
  18291. ""max"": 500,
  18292. ""value"": 1.50
  18293. },
  18294. {
  18295. ""min"": 501,
  18296. ""max"": 1000,
  18297. ""value"": 1.40
  18298. },
  18299. {
  18300. ""min"": 1001,
  18301. ""max"": 2000,
  18302. ""value"": 1.35
  18303. }
  18304. ]";
  18305. #endregion
  18306. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  18307. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  18308. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  18309. .ToList();
  18310. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  18311. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  18312. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  18313. // new List<(Predicate<decimal>, decimal)>()
  18314. // {
  18315. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  18316. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  18317. // }
  18318. // ));
  18319. #region 签证系数
  18320. var visaXS = 0.00M;
  18321. switch (dto.VisaCB)
  18322. {
  18323. case decimal n when (n > 1 && n < 500):
  18324. switch (dto.VisaRS)
  18325. {
  18326. case 2 or 3:
  18327. visaXS = 1.35M;
  18328. break;
  18329. case 4 or 5:
  18330. visaXS = 1.30M;
  18331. break;
  18332. case 6 or 7:
  18333. visaXS = 1.25M;
  18334. break;
  18335. case 8 or 9 or 10:
  18336. visaXS = 1.20M;
  18337. break;
  18338. case > 10:
  18339. visaXS = 1.15M;
  18340. break;
  18341. default:
  18342. visaXS = 0.00M;
  18343. break;
  18344. }
  18345. break;
  18346. case decimal n when (n >= 500 && n < 1000):
  18347. switch (dto.VisaRS)
  18348. {
  18349. case 2 or 3 or 4:
  18350. visaXS = 1.30M;
  18351. break;
  18352. case 5 or 6 or 7 or 8:
  18353. visaXS = 1.25M;
  18354. break;
  18355. case 9 or 10:
  18356. visaXS = 1.20M;
  18357. break;
  18358. case > 10:
  18359. visaXS = 1.15M;
  18360. break;
  18361. default:
  18362. visaXS = 0.00M;
  18363. break;
  18364. }
  18365. break;
  18366. default:
  18367. switch (dto.VisaRS)
  18368. {
  18369. case 2 or 3 or 4:
  18370. visaXS = 1.30M;
  18371. break;
  18372. case 5 or 6 or 7 or 8:
  18373. visaXS = 1.25M;
  18374. break;
  18375. case 9 or 10:
  18376. visaXS = 1.20M;
  18377. break;
  18378. case > 10:
  18379. visaXS = 1.15M;
  18380. break;
  18381. default:
  18382. visaXS = 0.00M;
  18383. break;
  18384. }
  18385. break;
  18386. }
  18387. #endregion
  18388. #region 火车系数
  18389. var hcpXS = 0.00M;
  18390. foreach (var (condition, result) in hcpSwitchDictionary)
  18391. {
  18392. if (condition(dto.HCPCB))
  18393. {
  18394. hcpXS = result;
  18395. break;
  18396. }
  18397. }
  18398. #endregion
  18399. #region 机票系数
  18400. #region 经济舱系数
  18401. var jjcXS = 0.00M;
  18402. switch (dto.JJCCB)
  18403. {
  18404. case decimal x when (x >= 1000 && x <= 3000):
  18405. jjcXS = 2.6M;
  18406. break;
  18407. case decimal x when (x >= 3001 && x <= 8000):
  18408. jjcXS = 2.3M;
  18409. break;
  18410. case decimal x when (x >= 8001 && x <= 15000):
  18411. jjcXS = 2.1M;
  18412. break;
  18413. case decimal x when (x >= 15001 && x <= 30000):
  18414. jjcXS = 1.95M;
  18415. break;
  18416. case > 30000:
  18417. jjcXS = 1.8M;
  18418. break;
  18419. default:
  18420. break;
  18421. }
  18422. #endregion
  18423. #region 公务舱系数
  18424. var gwcXS = 0.00M;
  18425. switch (dto.GWCCB)
  18426. {
  18427. case decimal x when (x >= 1000 && x <= 3000):
  18428. gwcXS = 2.5M;
  18429. break;
  18430. case decimal x when (x >= 3001 && x <= 8000):
  18431. gwcXS = 2.2M;
  18432. break;
  18433. case decimal x when (x >= 8001 && x <= 15000):
  18434. gwcXS = 2.0M;
  18435. break;
  18436. case decimal x when (x >= 15001 && x <= 30000):
  18437. gwcXS = 1.85M;
  18438. break;
  18439. case > 30000:
  18440. gwcXS = 1.7M;
  18441. break;
  18442. default:
  18443. break;
  18444. }
  18445. #endregion
  18446. #region 头等舱系数
  18447. var tdcXS = 0.00M;
  18448. switch (dto.TDCCB)
  18449. {
  18450. case > 70000:
  18451. tdcXS = 1.5M;
  18452. break;
  18453. default:
  18454. tdcXS = 1.9M;
  18455. break;
  18456. }
  18457. #endregion
  18458. #endregion
  18459. #region 酒店系数
  18460. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  18461. {
  18462. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  18463. {1.5M, new List<string>(){"越南社会主义共和国",
  18464. "老挝",
  18465. "柬埔寨",
  18466. "泰国",
  18467. "缅甸",
  18468. "马来西亚",
  18469. //"新加坡",
  18470. "文莱达鲁萨兰",
  18471. "印度尼西亚",
  18472. "东帝汶"}},
  18473. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  18474. };
  18475. #region SGR
  18476. var sgrXS = 1.25M;
  18477. #endregion
  18478. #region TBR
  18479. var tbrXS = 1.25M;
  18480. #endregion
  18481. #region JSES
  18482. var jsesXS = 1.25M;
  18483. #endregion
  18484. #region SUITE
  18485. var suiteXS = 1.25M;
  18486. #endregion
  18487. var countryArr = di.VisitCountry.Split("|");
  18488. foreach (var item in dic)
  18489. {
  18490. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  18491. .Count();
  18492. if (extsisCount > 0)
  18493. {
  18494. jsesXS = item.Key;
  18495. sgrXS = item.Key;
  18496. tbrXS = item.Key;
  18497. suiteXS = item.Key;
  18498. }
  18499. }
  18500. #endregion
  18501. #region 地接系数
  18502. var djXS = 0.00M;
  18503. switch (dto.DJRS)
  18504. {
  18505. case 2 or 3:
  18506. djXS = 2.65M;
  18507. break;
  18508. case 4:
  18509. djXS = 2.6M;
  18510. break;
  18511. case 5 or 6:
  18512. djXS = 2.5M;
  18513. break;
  18514. case 7 or 8:
  18515. djXS = 2.4M;
  18516. break;
  18517. case 9 or 10:
  18518. djXS = 2.3M;
  18519. break;
  18520. case 11:
  18521. djXS = 2.2M;
  18522. break;
  18523. case 12:
  18524. djXS = 2.1M;
  18525. break;
  18526. case 13 or 14:
  18527. djXS = 2M;
  18528. break;
  18529. case 15:
  18530. djXS = 1.9M;
  18531. break;
  18532. case 16 or 17 or 18:
  18533. djXS = 1.8M;
  18534. break;
  18535. case 19 or 20:
  18536. djXS = 1.7M;
  18537. break;
  18538. }
  18539. #endregion
  18540. #region 零用金系数
  18541. var lyjXS = 0.00M;
  18542. switch (dto.LYJRS)
  18543. {
  18544. case 2:
  18545. lyjXS = 1.25M;
  18546. break;
  18547. case 3 or 4 or 5:
  18548. lyjXS = 1.2M;
  18549. break;
  18550. case int number when (number > 5 && number < 10):
  18551. lyjXS = 1.15M;
  18552. break;
  18553. case > 10:
  18554. lyjXS = 1.1M;
  18555. break;
  18556. default:
  18557. break;
  18558. }
  18559. #endregion
  18560. return Ok(JsonView(true, "查询成功", new ArrayList()
  18561. {
  18562. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  18563. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  18564. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  18565. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  18566. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  18567. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  18568. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  18569. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  18570. new { label = "地接系数", value = djXS, key = "djXS" },
  18571. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  18572. new { label = "公务系数", value = 2M, key = "gwXS" }
  18573. }));
  18574. }
  18575. #endregion
  18576. #region 酒店预订 New 2023-12-28 17:45
  18577. /// <summary>
  18578. /// 酒店预订
  18579. /// 酒店费用列表 根据团组Id查询
  18580. /// </summary>
  18581. /// <param name="_dto"></param>
  18582. /// <returns></returns>
  18583. [HttpPost]
  18584. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18585. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  18586. {
  18587. #region 参数验证
  18588. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18589. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18590. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18591. #region 团组操作权限验证 76 酒店预定模块
  18592. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18593. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18594. #endregion
  18595. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18596. #region 页面操作权限验证
  18597. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18598. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18599. #endregion
  18600. #endregion
  18601. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  18602. }
  18603. /// <summary>
  18604. /// 酒店预订
  18605. /// 基础数据
  18606. /// </summary>
  18607. /// <param name="_dto"></param>
  18608. /// <returns></returns>
  18609. [HttpPost]
  18610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18611. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  18612. {
  18613. #region 参数验证
  18614. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18615. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18616. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18617. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18618. #region 页面操作权限验证
  18619. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18620. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18621. #endregion
  18622. #region 团组操作权限验证 76 酒店预定模块
  18623. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18624. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18625. #endregion
  18626. #endregion
  18627. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  18628. }
  18629. /// <summary>
  18630. /// 酒店预订
  18631. /// 创建 入住卷号码
  18632. /// </summary>
  18633. /// <param name="_dto"></param>
  18634. /// <returns></returns>
  18635. [HttpPost]
  18636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18637. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  18638. {
  18639. #region 参数验证
  18640. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18641. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18642. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18643. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18644. #region 页面操作权限验证
  18645. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18646. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18647. #endregion
  18648. #region 团组操作权限验证 76 酒店预定模块
  18649. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18650. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18651. #endregion
  18652. #endregion
  18653. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  18654. if (data.Code != 0)
  18655. {
  18656. return Ok(JsonView(false, data.Msg));
  18657. }
  18658. return Ok(JsonView(true, data.Msg, data.Data));
  18659. }
  18660. /// <summary>
  18661. /// 酒店预订
  18662. /// 详情
  18663. /// </summary>
  18664. /// <param name="_dto"></param>
  18665. /// <returns></returns>
  18666. [HttpPost]
  18667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18668. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  18669. {
  18670. #region 参数验证
  18671. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  18672. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18673. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  18674. #region 团组操作权限验证 76 酒店预定模块
  18675. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18676. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18677. #endregion
  18678. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18679. #region 页面操作权限验证
  18680. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18681. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  18682. #endregion
  18683. #endregion
  18684. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  18685. }
  18686. /// <summary>
  18687. /// 酒店预订
  18688. /// Add Or Edit
  18689. /// </summary>
  18690. /// <param name="_dto"></param>
  18691. /// <returns></returns>
  18692. [HttpPost]
  18693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18694. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  18695. {
  18696. #region 参数验证
  18697. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18698. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18699. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18700. #region 团组操作权限验证 76 酒店预定模块
  18701. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18702. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18703. #endregion
  18704. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18705. #region 页面操作权限验证
  18706. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18707. if (_dto.Id == 0) // Add
  18708. {
  18709. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  18710. }
  18711. else if (_dto.Id > 1) // Edit
  18712. {
  18713. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  18714. }
  18715. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  18716. #endregion
  18717. #endregion
  18718. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  18719. if (_view.Code != 200)
  18720. {
  18721. return Ok(_view);
  18722. }
  18723. #region 成本无酒店价格数据进入超支
  18724. _sqlSugar.BeginTran();
  18725. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  18726. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  18727. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  18728. for (int i = 0; i < groupCost.Count; i++)
  18729. {
  18730. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  18731. {
  18732. groupCost[i].Date = groupCost[i - 1].Date;
  18733. }
  18734. }
  18735. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  18736. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  18737. List<Fin_GroupExtraCostDto_OP>();
  18738. if (start_Bool && end_Bool)
  18739. {
  18740. while (start_Time < end_Time)
  18741. {
  18742. foreach (var item in groupCost_Grp)
  18743. {
  18744. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  18745. {
  18746. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  18747. {
  18748. extraCostList.Add(new
  18749. Fin_GroupExtraCostDto_OP
  18750. {
  18751. Area = _dto.AreaId,
  18752. coefficient = 1.5M,
  18753. createUser = _dto.UserId,
  18754. currency = _dto.CardPriceCurrency,
  18755. diId = _dto.DiId,
  18756. ManagerConfirm = 0,
  18757. SupervisorConfirm = 0,
  18758. SYsupervisorConfirm = 0,
  18759. editType = 1,
  18760. PortType = 1,
  18761. price = _dto.CardPrice,
  18762. PriceCount = 1,
  18763. priceType = 1027,
  18764. priceDetailType = 1044,
  18765. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  18766. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  18767. });
  18768. }
  18769. }
  18770. }
  18771. start_Time = start_Time.AddDays(1);
  18772. }
  18773. }
  18774. if (extraCostList.Any())
  18775. {
  18776. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  18777. }
  18778. _sqlSugar.CommitTran();
  18779. #endregion
  18780. #region 应用推送
  18781. try
  18782. {
  18783. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18784. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18785. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18786. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18787. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18788. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18789. var diId = _dto.DiId;
  18790. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18791. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18792. #region 操作记录
  18793. var opInfo = new Crm_TableOperationRecord()
  18794. {
  18795. TableName = "Grp_HotelReservations",
  18796. PortType = _dto.PortType,
  18797. DataId = hotelId,
  18798. CreateUserId = _dto.UserId
  18799. };
  18800. //var opStatus = OperationEnum.NoOperation;
  18801. if (_dto.Id < 1) //添加操作
  18802. {
  18803. opInfo.OperationItem = OperationEnum.Add;
  18804. }
  18805. else if (_dto.Id > 0)
  18806. {
  18807. opInfo.OperationItem = OperationEnum.Edit;
  18808. }
  18809. string opRemark = string.Empty;
  18810. if (ccpInfo != null)
  18811. {
  18812. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  18813. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  18814. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  18815. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  18816. }
  18817. opInfo.Remark = opRemark;
  18818. await _tableorRep.AddAsync(opInfo);
  18819. #endregion
  18820. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  18821. //2024-10-21 新增LZ UID
  18822. var userIds = new List<int>() { 21 };
  18823. string title = $"费用审核";
  18824. string content = "";
  18825. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18826. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18827. try
  18828. {
  18829. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  18830. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  18831. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  18832. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  18833. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  18834. }
  18835. catch (Exception ex)
  18836. {
  18837. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  18838. }
  18839. }
  18840. catch (Exception ex)
  18841. {
  18842. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  18843. }
  18844. try
  18845. {
  18846. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  18847. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  18848. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  18849. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  18850. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  18851. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  18852. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  18853. //自动审核
  18854. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  18855. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  18856. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  18857. //2024-10-21 新增LZ UID
  18858. var userIds = new List<int>() { 21 };
  18859. string title = $"系统通知";
  18860. var diId = _dto.DiId;
  18861. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  18862. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  18863. string content = "";
  18864. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18865. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  18866. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  18867. }
  18868. catch (Exception ex)
  18869. {
  18870. }
  18871. #endregion
  18872. return Ok(_view);
  18873. }
  18874. /// <summary>
  18875. /// 酒店自动审核测试
  18876. /// Add Or Edit
  18877. /// </summary>
  18878. /// <param name="diid"></param>
  18879. /// <param name="dataId"></param>
  18880. /// <returns></returns>
  18881. [HttpPost]
  18882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18883. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  18884. {
  18885. #region 应用推送
  18886. try
  18887. {
  18888. //自动审核
  18889. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  18890. }
  18891. catch (Exception ex)
  18892. {
  18893. return Ok(JsonView(false, ex.Message));
  18894. }
  18895. #endregion
  18896. return Ok(JsonView(false, "操作成功"));
  18897. }
  18898. /// <summary>
  18899. /// 酒店预订
  18900. /// Del
  18901. /// </summary>
  18902. /// <param name="_dto"></param>
  18903. /// <returns></returns>
  18904. [HttpPost]
  18905. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18906. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  18907. {
  18908. #region 参数验证
  18909. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18910. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18911. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18912. #region 团组操作权限验证 76 酒店预定模块
  18913. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18914. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18915. #endregion
  18916. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18917. #region 页面操作权限验证
  18918. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18919. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  18920. #endregion
  18921. #endregion
  18922. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  18923. #region 操作记录
  18924. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  18925. {
  18926. TableName = "Grp_HotelReservations",
  18927. PortType = _dto.PortType,
  18928. OperationItem = OperationEnum.Del,
  18929. DataId = _dto.Id,
  18930. CreateUserId = _dto.UserId
  18931. });
  18932. #endregion
  18933. return Ok(data);
  18934. }
  18935. /// <summary>
  18936. /// 酒店预订
  18937. /// 生成VOUCHER
  18938. /// 2024.05.06 之前版本
  18939. /// </summary>
  18940. /// <param name="_dto"></param>
  18941. /// <returns></returns>
  18942. [HttpPost]
  18943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  18944. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  18945. {
  18946. try
  18947. {
  18948. #region 参数验证
  18949. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  18950. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  18951. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  18952. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  18953. #region 团组操作权限验证 76 酒店预定模块
  18954. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  18955. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  18956. #endregion
  18957. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  18958. #region 页面操作权限验证
  18959. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  18960. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  18961. #endregion
  18962. #endregion
  18963. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  18964. //判断数据是否完整
  18965. if (hr != null)
  18966. {
  18967. if (!string.IsNullOrEmpty(hr.DetermineNo))
  18968. {
  18969. string strFileName = "HotelStatement/";
  18970. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  18971. if (dele != null)
  18972. strFileName += dele.TourCode;
  18973. //载入模板
  18974. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  18975. Document doc = new Document(sss);
  18976. DocumentBuilder builder = new DocumentBuilder(doc);
  18977. #region 替换Word模板书签内容
  18978. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  18979. //入住卷预定号码
  18980. if (doc.Range.Bookmarks["VNO"] != null)
  18981. {
  18982. Bookmark mark = doc.Range.Bookmarks["VNO"];
  18983. mark.Text = hr.CheckNumber;
  18984. }
  18985. //酒店时间
  18986. if (doc.Range.Bookmarks["Date"] != null)
  18987. {
  18988. Bookmark mark = doc.Range.Bookmarks["Date"];
  18989. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  18990. }
  18991. //团号
  18992. if (doc.Range.Bookmarks["TNo"] != null)
  18993. {
  18994. Bookmark mark = doc.Range.Bookmarks["TNo"];
  18995. mark.Text = dele.TourCode;
  18996. }
  18997. //预定号码
  18998. if (doc.Range.Bookmarks["BookingId"] != null)
  18999. {
  19000. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  19001. mark.Text = hr.ReservationsNo;
  19002. }
  19003. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  19004. {
  19005. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  19006. mark.Text = hr.DetermineNo;
  19007. }
  19008. //酒店城市
  19009. if (doc.Range.Bookmarks["City"] != null)
  19010. {
  19011. Bookmark mark = doc.Range.Bookmarks["City"];
  19012. mark.Text = hr.City;
  19013. }
  19014. //酒店名称
  19015. if (doc.Range.Bookmarks["HName"] != null)
  19016. {
  19017. Bookmark mark = doc.Range.Bookmarks["HName"];
  19018. mark.Text = hr.HotelName;
  19019. }
  19020. //酒店地址
  19021. if (doc.Range.Bookmarks["Address"] != null)
  19022. {
  19023. Bookmark mark = doc.Range.Bookmarks["Address"];
  19024. mark.Text = hr.HotelAddress;
  19025. }
  19026. //酒店电话
  19027. if (doc.Range.Bookmarks["Tel"] != null)
  19028. {
  19029. Bookmark mark = doc.Range.Bookmarks["Tel"];
  19030. mark.Text = hr.HotelTel;
  19031. }
  19032. //酒店传真
  19033. if (doc.Range.Bookmarks["Fax"] != null)
  19034. {
  19035. Bookmark mark = doc.Range.Bookmarks["Fax"];
  19036. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  19037. {
  19038. mark.Text = hr.HotelFax;
  19039. }
  19040. }
  19041. //入住时间
  19042. if (doc.Range.Bookmarks["CIn"] != null)
  19043. {
  19044. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  19045. Bookmark mark = doc.Range.Bookmarks["CIn"];
  19046. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  19047. }
  19048. //退房时间
  19049. if (doc.Range.Bookmarks["COut"] != null)
  19050. {
  19051. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  19052. Bookmark mark = doc.Range.Bookmarks["COut"];
  19053. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  19054. }
  19055. //客户名称
  19056. if (doc.Range.Bookmarks["GName"] != null)
  19057. {
  19058. string guestName = "";
  19059. string[] clients = Array.Empty<string>();
  19060. if (hr.GuestName.Contains(","))
  19061. {
  19062. clients = hr.GuestName.Split(",");
  19063. }
  19064. else
  19065. {
  19066. clients = new string[] { hr.GuestName };
  19067. }
  19068. List<int> clientIds_int = new List<int>();
  19069. if (clients.Length > 0)
  19070. {
  19071. foreach (var item in clients)
  19072. {
  19073. if (item.IsNumeric())
  19074. {
  19075. clientIds_int.Add(int.Parse(item));
  19076. }
  19077. }
  19078. }
  19079. if (clientIds_int.Count > 0)
  19080. {
  19081. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  19082. foreach (var client in _clientDatas)
  19083. {
  19084. //男
  19085. if (client.Sex == 0) guestName += $"Mr.";
  19086. //女
  19087. else if (client.Sex == 1) guestName += $"Ms.";
  19088. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  19089. {
  19090. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  19091. }
  19092. //guestName += $"{client.Pinyin},";
  19093. }
  19094. if (guestName.Length > 0)
  19095. {
  19096. guestName = guestName.Substring(0, guestName.Length - 1);
  19097. }
  19098. }
  19099. else
  19100. {
  19101. guestName = hr.GuestName;
  19102. }
  19103. Bookmark mark = doc.Range.Bookmarks["GName"];
  19104. mark.Text = guestName;
  19105. }
  19106. //房间介绍
  19107. if (doc.Range.Bookmarks["ROOM"] != null)
  19108. {
  19109. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  19110. mark.Text = hr.RoomExplanation;
  19111. }
  19112. //报价描述
  19113. if (doc.Range.Bookmarks["NOTE"] != null)
  19114. {
  19115. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  19116. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  19117. if (ss != null)
  19118. mark.Text = ss.Name;
  19119. }
  19120. //入住时间
  19121. if (doc.Range.Bookmarks["CheckIn"] != null)
  19122. {
  19123. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  19124. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  19125. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  19126. }
  19127. //退房时间
  19128. if (doc.Range.Bookmarks["CheckOut"] != null)
  19129. {
  19130. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  19131. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  19132. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  19133. }
  19134. //日期
  19135. if (doc.Range.Bookmarks["DT"] != null)
  19136. {
  19137. Bookmark mark = doc.Range.Bookmarks["DT"];
  19138. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  19139. }
  19140. //名称
  19141. if (doc.Range.Bookmarks["VName"] != null)
  19142. {
  19143. Bookmark mark = doc.Range.Bookmarks["VName"];
  19144. mark.Text = hr.HotelName;
  19145. }
  19146. //号码
  19147. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  19148. {
  19149. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  19150. mark.Text = hr.CheckNumber;
  19151. }
  19152. #endregion
  19153. strFileName += "VOUCHER.doc";
  19154. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19155. doc.Save(fileDir);
  19156. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19157. return Ok(JsonView(true, "操作成功!", Url));
  19158. }
  19159. else
  19160. {
  19161. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  19162. }
  19163. }
  19164. else
  19165. {
  19166. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  19167. }
  19168. }
  19169. catch (Exception ex)
  19170. {
  19171. return Ok(JsonView(false, ex.Message));
  19172. }
  19173. }
  19174. /// <summary>
  19175. /// 酒店预订
  19176. /// 生成VOUCHER
  19177. /// 2024.05.06 之后版本
  19178. /// </summary>
  19179. /// <param name="_dto"></param>
  19180. /// <returns></returns>
  19181. [HttpPost]
  19182. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19183. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  19184. {
  19185. #region 参数验证
  19186. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19187. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  19188. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19189. #region 团组操作权限验证 76 酒店预定模块
  19190. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19191. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19192. #endregion
  19193. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19194. #region 页面操作权限验证
  19195. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19196. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19197. #endregion
  19198. #endregion
  19199. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  19200. //判断数据是否完整
  19201. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19202. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19203. string strFileName = "HotelStatement/";
  19204. string guestNames = ""; //格式Mr.xxx Ms.xxx
  19205. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  19206. #region 数据处理
  19207. List<int> guestIds = new List<int>();
  19208. //int index = 0;
  19209. foreach (var item in hrDtas)
  19210. {
  19211. if (item.GuestName.Contains(","))
  19212. {
  19213. string[] guestIdArr = item.GuestName.Split(',');
  19214. foreach (var guestIdStr in guestIdArr)
  19215. {
  19216. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  19217. if (guestBool)
  19218. {
  19219. guestIds.Add(guestId);
  19220. }
  19221. }
  19222. }
  19223. else guestNames += item.GuestName;
  19224. var voucherInfo = new HotelVoucherInfoView()
  19225. {
  19226. HotelName = item.HotelName,
  19227. CheckInDate = item.CheckInDate,
  19228. CheckOutDate = item.CheckOutDate,
  19229. ConfirmationNumber = item.DetermineNo.Trim(),
  19230. RoomType = item.RoomExplanation
  19231. };
  19232. vouchers.Add(voucherInfo);
  19233. }
  19234. if (guestIds.Count > 0)
  19235. {
  19236. guestIds = guestIds.Distinct().ToList();
  19237. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  19238. if (guestDatas.Count > 0)
  19239. {
  19240. guestNames = "";
  19241. foreach (var guest in guestDatas)
  19242. {
  19243. string guestName = "";
  19244. if (guest.Sex == 0) guestName += @"MR.";
  19245. else if (guest.Sex == 1) guestName += @"MS.";
  19246. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19247. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19248. guestNames += @$"{guestName.Trim()}、";
  19249. }
  19250. if (guestNames.Length > 0)
  19251. {
  19252. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19253. }
  19254. }
  19255. }
  19256. #endregion
  19257. //载入模板
  19258. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  19259. Document doc = new Document(sss);
  19260. DocumentBuilder builder = new DocumentBuilder(doc);
  19261. if (doc.Range.Bookmarks["GuestName"] != null)
  19262. {
  19263. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  19264. mark.Text = guestNames;
  19265. }
  19266. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  19267. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  19268. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  19269. for (int i = 1; i <= vouchers.Count; i++)
  19270. {
  19271. HotelVoucherInfoView hviv = vouchers[i - 1];
  19272. builder.MoveToCell(0, i, 0, 0);
  19273. builder.Write(hviv.HotelName);
  19274. builder.MoveToCell(0, i, 1, 0);
  19275. builder.Write(hviv.CheckInDate);
  19276. builder.MoveToCell(0, i, 2, 0);
  19277. builder.Write(hviv.CheckOutDate);
  19278. builder.MoveToCell(0, i, 3, 0);
  19279. builder.Write(hviv.RoomType);
  19280. builder.MoveToCell(0, i, 4, 0);
  19281. builder.Write(hviv.ConfirmationNumber);
  19282. }
  19283. //删除多余行
  19284. int currRowIndex = vouchers.Count + 1;
  19285. int delRows = 21 - currRowIndex;
  19286. if (delRows > 0)
  19287. {
  19288. for (int i = 0; i < delRows; i++)
  19289. {
  19290. table.Rows.RemoveAt(currRowIndex);
  19291. //cultivateRowIndex++;
  19292. }
  19293. }
  19294. strFileName += "VOUCHER.docx";
  19295. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19296. doc.Save(fileDir);
  19297. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19298. return Ok(JsonView(true, "操作成功!", Url));
  19299. }
  19300. /// <summary>
  19301. /// 酒店预订
  19302. /// 生成VOUCHER 批量生成
  19303. /// New
  19304. /// </summary>
  19305. /// <param name="_dto"></param>
  19306. /// <returns></returns>
  19307. [HttpPost]
  19308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19309. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  19310. {
  19311. #region 参数验证
  19312. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  19313. if (_dto.PageId < 1) _dto.PageId = 28;
  19314. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  19315. #region 团组操作权限验证 76 酒店预定模块
  19316. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19317. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  19318. #endregion
  19319. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19320. #region 页面操作权限验证
  19321. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19322. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19323. #endregion
  19324. #endregion
  19325. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  19326. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  19327. .OrderBy(x => x.CheckInDate)
  19328. .ToListAsync();
  19329. //判断数据是否完整
  19330. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  19331. string strFileName = "HotelStatement/";
  19332. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  19333. if (dele != null)
  19334. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  19335. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  19336. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  19337. .Where(it => it.IsDel == 0)
  19338. .ToListAsync();
  19339. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  19340. for (int i = 0; i < hrDtas.Count; i++)
  19341. {
  19342. string guestNames = string.Empty;
  19343. List<int> guestIds = new List<int>();
  19344. var item = hrDtas[i];
  19345. //处理客户姓名
  19346. if (item.GuestName.Contains(","))
  19347. {
  19348. string[] guestIdArr = item.GuestName.Split(',');
  19349. foreach (var guestIdStr in guestIdArr)
  19350. if (int.TryParse(guestIdStr, out int guestId))
  19351. guestIds.Add(guestId);
  19352. }
  19353. else
  19354. {
  19355. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  19356. if (guestIdBool)
  19357. {
  19358. guestIds.Add(guestId);
  19359. }
  19360. //NaN
  19361. if (item.GuestName.Contains("NaN"))
  19362. {
  19363. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  19364. }
  19365. }
  19366. if (guestIds.Count > 0)
  19367. {
  19368. guestIds = guestIds.Distinct().ToList();
  19369. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  19370. if (guestDatas1.Count > 0)
  19371. {
  19372. guestNames = "";
  19373. foreach (var guest in guestDatas1)
  19374. {
  19375. string guestName = "";
  19376. if (guest.Sex == 0) guestName += @"MR.";
  19377. else if (guest.Sex == 1) guestName += @"MS.";
  19378. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  19379. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  19380. guestNames += @$"{guestName.Trim()}、";
  19381. }
  19382. if (guestNames.Length > 0)
  19383. {
  19384. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  19385. }
  19386. }
  19387. }
  19388. //if (!string.IsNullOrEmpty(guestNames))
  19389. //{
  19390. hrDtas[i].GuestName = guestNames;
  19391. //}
  19392. }
  19393. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  19394. Document doc = new Document();
  19395. DocumentBuilder builder = new DocumentBuilder(doc);
  19396. try
  19397. {
  19398. builder.MoveToDocumentStart();
  19399. foreach (var item in hrDtas)
  19400. {
  19401. //标题
  19402. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19403. builder.ParagraphFormat.LineSpacing = 1;
  19404. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19405. builder.ParagraphFormat.Style.Font.Size = 9;
  19406. builder.ParagraphFormat.Style.Font.Bold = true;
  19407. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19408. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  19409. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  19410. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  19411. builder.ParagraphFormat.LineSpacing = 1;
  19412. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19413. builder.ParagraphFormat.Style.Font.Size = 9;
  19414. builder.ParagraphFormat.Style.Font.Bold = true;
  19415. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  19416. builder.StartTable();
  19417. // 设置边框颜色
  19418. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  19419. //设置边框样式
  19420. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  19421. //表格
  19422. #region 第一行
  19423. builder.InsertCell();
  19424. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19425. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19426. //builder.CellFormat.AllowAutoFit = false;
  19427. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19428. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19429. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19430. builder.CellFormat.WrapText = true; //自动换行
  19431. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19432. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  19433. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19434. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19435. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19436. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19437. builder.Write("TOUR NO:");
  19438. builder.InsertCell();
  19439. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19440. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19441. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19442. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19443. builder.ParagraphFormat.Style.Font.Bold = false;
  19444. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19445. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19446. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19447. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19448. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19449. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19450. builder.Write($"{dele?.TourCode ?? "-"}");
  19451. builder.InsertCell();
  19452. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19453. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19454. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19455. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19456. builder.ParagraphFormat.Style.Font.Bold = false;
  19457. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19458. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19459. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19460. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19461. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19462. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19463. builder.Write($"CITY:");
  19464. builder.InsertCell();
  19465. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19466. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19467. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19468. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19469. builder.ParagraphFormat.Style.Font.Bold = false;
  19470. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19471. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19472. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19473. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19474. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19475. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19476. builder.Write($"{item.City}");
  19477. builder.EndRow();
  19478. #endregion
  19479. #region 第二行
  19480. builder.InsertCell();
  19481. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19482. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19483. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19484. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19485. builder.ParagraphFormat.Style.Font.Bold = false;
  19486. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19487. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19488. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19489. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19490. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19491. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19492. builder.Write("CONFIRMATION NO:");
  19493. builder.InsertCell();
  19494. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19495. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19496. builder.ParagraphFormat.Style.Font.Size = 8;
  19497. builder.ParagraphFormat.Style.Font.Bold = false;
  19498. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19499. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19500. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19501. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19502. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19503. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19504. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19505. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19506. builder.Write($"{item.DetermineNo}");
  19507. builder.InsertCell();
  19508. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19509. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19510. builder.InsertCell();
  19511. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19512. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19513. builder.EndRow();
  19514. #endregion
  19515. #region 第三行
  19516. builder.InsertCell();
  19517. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19518. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19519. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19520. builder.ParagraphFormat.Style.Font.Bold = false;
  19521. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19522. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19523. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19524. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19525. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19526. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19527. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19528. builder.Write($"HOTEL NAME:");
  19529. builder.InsertCell();
  19530. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19531. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19532. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19533. builder.ParagraphFormat.Style.Font.Bold = false;
  19534. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19535. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19536. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19537. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19538. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19539. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19540. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19541. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19542. builder.Write($"{item.HotelName}");
  19543. builder.InsertCell();
  19544. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19545. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19546. builder.InsertCell();
  19547. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19548. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19549. builder.EndRow();
  19550. #endregion
  19551. #region 第四行
  19552. builder.InsertCell();
  19553. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19554. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19555. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19556. builder.ParagraphFormat.Style.Font.Bold = false;
  19557. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19558. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19559. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19560. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19561. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19562. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19563. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19564. builder.Write($"HOTEL ADDRESS:");
  19565. builder.InsertCell();
  19566. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19567. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19568. builder.ParagraphFormat.Style.Font.Size = 8;
  19569. builder.ParagraphFormat.Style.Font.Bold = false;
  19570. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19571. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19572. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19573. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19574. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19575. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19576. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19577. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19578. builder.Write($"{item.HotelAddress}");
  19579. builder.InsertCell();
  19580. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19581. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19582. builder.InsertCell();
  19583. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19584. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19585. builder.EndRow();
  19586. #endregion
  19587. #region 第五行
  19588. builder.InsertCell();
  19589. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19590. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19591. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19592. builder.ParagraphFormat.Style.Font.Bold = false;
  19593. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19594. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19595. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19596. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19597. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19598. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19599. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19600. builder.Write("TEL:");
  19601. builder.InsertCell();
  19602. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19603. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19604. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19605. builder.ParagraphFormat.Style.Font.Bold = false;
  19606. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19607. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19608. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19609. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19610. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19611. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19612. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19613. builder.Write($"{item.HotelTel}");
  19614. builder.InsertCell();
  19615. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19616. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19617. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19618. builder.ParagraphFormat.Style.Font.Bold = false;
  19619. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19620. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19621. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19622. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19623. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19624. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19625. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19626. builder.Write($"FAX:");
  19627. builder.InsertCell();
  19628. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19629. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19630. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19631. builder.ParagraphFormat.Style.Font.Bold = false;
  19632. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19633. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19634. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19635. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19636. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19637. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19638. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19639. builder.Write($"{item.HotelFax}");
  19640. builder.EndRow();
  19641. #endregion
  19642. #region 第六行
  19643. builder.InsertCell();
  19644. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19645. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19646. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19647. builder.ParagraphFormat.Style.Font.Bold = false;
  19648. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19649. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19650. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19651. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19652. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19653. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19654. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19655. builder.Write("CHECK IN:");
  19656. builder.InsertCell();
  19657. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19658. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19659. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19660. builder.ParagraphFormat.Style.Font.Bold = false;
  19661. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19662. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19663. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19664. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19665. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19666. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19667. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19668. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  19669. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  19670. builder.Write($"{checkInStr}");
  19671. builder.InsertCell();
  19672. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19673. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19674. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19675. builder.ParagraphFormat.Style.Font.Bold = false;
  19676. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19677. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19678. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19679. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19680. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19681. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19682. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19683. builder.Write($"CHECK OUT:");
  19684. builder.InsertCell();
  19685. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19686. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19687. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19688. builder.ParagraphFormat.Style.Font.Bold = false;
  19689. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19690. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19691. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19692. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19693. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19694. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19695. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19696. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  19697. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  19698. builder.Write($"{checkOutStr}");
  19699. builder.EndRow();
  19700. #endregion
  19701. #region 第七行
  19702. builder.InsertCell();
  19703. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19704. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19705. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19706. builder.ParagraphFormat.Style.Font.Bold = false;
  19707. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19708. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19709. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19710. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19711. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19712. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19713. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19714. builder.Write($"GUEST NAME:");
  19715. builder.InsertCell();
  19716. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19717. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19718. builder.ParagraphFormat.Style.Font.Size = 8;
  19719. builder.ParagraphFormat.Style.Font.Bold = false;
  19720. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19721. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19722. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19723. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19724. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19725. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19726. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19727. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19728. builder.Write($"{item.GuestName.Trim()}");
  19729. builder.InsertCell();
  19730. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19731. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19732. builder.InsertCell();
  19733. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19734. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19735. builder.EndRow();
  19736. #endregion
  19737. #region 第八行
  19738. builder.InsertCell();
  19739. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19740. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19741. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19742. builder.ParagraphFormat.Style.Font.Bold = false;
  19743. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19744. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19745. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19746. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19747. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19748. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19749. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19750. builder.Write($"ROOM TYPE:");
  19751. builder.InsertCell();
  19752. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19753. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19754. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19755. builder.ParagraphFormat.Style.Font.Bold = false;
  19756. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19757. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19758. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19759. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19760. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19761. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19762. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19763. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19764. builder.Write($"{item.RoomExplanation}");
  19765. builder.InsertCell();
  19766. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19767. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19768. builder.InsertCell();
  19769. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19770. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19771. builder.EndRow();
  19772. #endregion
  19773. #region 第九行
  19774. builder.InsertCell();
  19775. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19776. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19777. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19778. builder.ParagraphFormat.Style.Font.Bold = false;
  19779. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19780. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19781. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  19782. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  19783. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  19784. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  19785. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  19786. builder.Write($"NOTE:");
  19787. builder.InsertCell();
  19788. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19789. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  19790. builder.ParagraphFormat.Style.Font.Size = 7.5;
  19791. builder.ParagraphFormat.Style.Font.Bold = false;
  19792. builder.CellFormat.HorizontalMerge = CellMerge.None;
  19793. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  19794. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  19795. builder.CellFormat.HorizontalMerge = CellMerge.First;
  19796. 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.");
  19797. builder.InsertCell();
  19798. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  19799. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19800. builder.InsertCell();
  19801. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  19802. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  19803. builder.EndRow();
  19804. #endregion
  19805. builder.EndTable();
  19806. //换行
  19807. builder.Writeln("");
  19808. builder.Writeln("");
  19809. }
  19810. #region 获取文档中的所有表格 设置文字自适应
  19811. // 获取文档中的所有表格。
  19812. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  19813. {
  19814. // 遍历表格中的所有行。
  19815. foreach (Aspose.Words.Tables.Row row in table.Rows)
  19816. {
  19817. foreach (Cell cell in row.Cells)
  19818. {
  19819. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  19820. cellFormat.Width = 0;
  19821. }
  19822. }
  19823. }
  19824. #endregion
  19825. #region 设置页眉
  19826. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  19827. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  19828. if (System.IO.File.Exists(voucherHeaderPath))
  19829. {
  19830. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  19831. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  19832. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  19833. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  19834. // 调整图片位置
  19835. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  19836. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  19837. shape.Top = 50; // 将图片距离页眉上边缘的距离
  19838. shape.Left = 0; // 将图片距离页面左边缘的距离
  19839. shape.Width = 81; // 设置图片宽度
  19840. shape.Height = 36; // 设置图片高度
  19841. }
  19842. //靠右
  19843. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  19844. //// 设置页脚上下边距
  19845. //builder.PageSetup.HeaderDistance = 42;
  19846. // 添加页眉线
  19847. Aspose.Words.Border borderHeader = null;
  19848. try
  19849. {
  19850. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  19851. }
  19852. catch (Exception e)
  19853. {
  19854. // TODO Auto-generated catch block
  19855. //e.printStackTrace();
  19856. }
  19857. borderHeader.Shadow = true;
  19858. borderHeader.DistanceFromText = 2;
  19859. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  19860. #endregion
  19861. }
  19862. catch (Exception ex)
  19863. {
  19864. }
  19865. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  19866. doc.Save(fileDir);
  19867. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  19868. return Ok(JsonView(true, "操作成功!", Url));
  19869. }
  19870. /// <summary>
  19871. /// 酒店预订
  19872. /// 生成 预定成本 Excel
  19873. /// </summary>
  19874. /// <param name="_dto"></param>
  19875. /// <returns></returns>
  19876. [HttpPost]
  19877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19878. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  19879. {
  19880. #region 参数验证
  19881. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  19882. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  19883. if (!vadalitorRes.IsValid)
  19884. {
  19885. var errors = new StringBuilder();
  19886. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  19887. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  19888. }
  19889. #region 团组操作权限验证 76 酒店预定模块
  19890. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  19891. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  19892. #endregion
  19893. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  19894. #region 页面操作权限验证
  19895. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  19896. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  19897. #endregion
  19898. #endregion
  19899. decimal _rate = 1.00M;
  19900. string _currency = string.Empty;
  19901. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  19902. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19903. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  19904. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  19905. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  19906. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  19907. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  19908. if (_GroupCostParameter == null)
  19909. {
  19910. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  19911. bool isIntType = int.TryParse(_currency, out int currId);
  19912. if (isIntType)
  19913. {
  19914. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  19915. }
  19916. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  19917. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  19918. if (currInfo == null)
  19919. {
  19920. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  19921. }
  19922. else _rate = currInfo.Rate;
  19923. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  19924. {
  19925. _rate = _GroupCostParameter.Rate;
  19926. }
  19927. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  19928. //string strFileName = "HotelStatement/";
  19929. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  19930. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  19931. var rateDatas = new List<dynamic>();
  19932. #region 数据处理
  19933. foreach (var item in hrDtas)
  19934. {
  19935. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  19936. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  19937. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  19938. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  19939. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  19940. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  19941. {
  19942. continue;
  19943. }
  19944. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  19945. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  19946. string singleRoomFeeStr = string.Empty,
  19947. doubleRoomFeeStr = string.Empty,
  19948. suiteRoomFeeStr = string.Empty,
  19949. otherRoomFeeStr = string.Empty,
  19950. payMoneyStr = string.Empty,
  19951. cardPriceStr = string.Empty;
  19952. if (roomCurr.Equals("CNY"))
  19953. {
  19954. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  19955. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19956. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19957. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19958. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19959. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  19960. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  19961. }
  19962. else
  19963. {
  19964. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  19965. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  19966. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  19967. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  19968. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  19969. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  19970. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19971. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19972. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19973. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  19974. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  19975. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  19976. if (ccpPaymentCurrency.Equals("CNY"))
  19977. {
  19978. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  19979. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19980. }
  19981. else
  19982. {
  19983. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  19984. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  19985. }
  19986. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  19987. if (hotelcardPriceCurrency.Equals("CNY"))
  19988. {
  19989. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  19990. }
  19991. else
  19992. {
  19993. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  19994. }
  19995. }
  19996. string breakfastPriceStr = string.Empty,
  19997. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  19998. governmentRentStr = string.Empty,
  19999. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  20000. cityTaxStr = string.Empty,
  20001. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  20002. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  20003. if (!string.IsNullOrEmpty(breakfastCurrency1))
  20004. {
  20005. if (breakfastCurrency1.Equals("CNY"))
  20006. {
  20007. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  20008. }
  20009. else
  20010. {
  20011. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  20012. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  20013. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  20014. }
  20015. }
  20016. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  20017. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  20018. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  20019. {
  20020. if (governmentRentCurrency.Equals("CNY"))
  20021. {
  20022. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  20023. }
  20024. else
  20025. {
  20026. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  20027. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  20028. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  20029. }
  20030. }
  20031. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  20032. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  20033. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  20034. {
  20035. if (cityTaxStrCurrency1.Equals("CNY"))
  20036. {
  20037. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  20038. }
  20039. else
  20040. {
  20041. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  20042. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  20043. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  20044. }
  20045. }
  20046. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  20047. int payDId = roomInfo?.PayDId ?? 0;
  20048. pcfds.Add(new HotelReservations_PCFD_View()
  20049. {
  20050. City = item.City,
  20051. HotelName = item.HotelName,
  20052. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  20053. // SingleRoomCount = item.SingleRoomCount,
  20054. SingleRoomPrice = singleRoomFeeStr,
  20055. // DoubleRoomCount = item.DoubleRoomCount,
  20056. DoubleRoomPrice = doubleRoomFeeStr,
  20057. //SuiteRoomCount = item.SuiteRoomCount,
  20058. SuiteRoomPrice = suiteRoomFeeStr,
  20059. OtherRoomPrice = otherRoomFeeStr,
  20060. //OtherRoomCount = item.OtherRoomCount,
  20061. BreakfastPrice = breakfastPriceStr,
  20062. GovernmentRent = governmentRentStr,
  20063. CityTax = cityTaxStr,
  20064. RoomExplanation = item.RoomExplanation,
  20065. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  20066. PayTime = roomInfo?.ConsumptionDate,
  20067. BankNo = roomInfo?.BankNo,
  20068. PayMoney = payMoneyStr,
  20069. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  20070. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  20071. CardPrice = cardPriceStr,
  20072. Remark = ccpInfo.Remark
  20073. });
  20074. }
  20075. #endregion
  20076. //载入模板
  20077. WorkbookDesigner designer = new WorkbookDesigner();
  20078. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  20079. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  20080. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  20081. designer.SetDataSource("TourNo", groupInfo.TourCode);
  20082. var rateDatas1 = rateDatas.Distinct();
  20083. var rateStr = string.Empty;
  20084. foreach (var item in rateDatas1)
  20085. {
  20086. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  20087. }
  20088. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  20089. designer.SetDataSource("Opertor", userInfo.CnName);
  20090. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  20091. dt.TableName = "ViewMyHotelReservations";
  20092. designer.SetDataSource(dt);
  20093. designer.Process();
  20094. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  20095. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  20096. designer.Workbook.Save(serverPath);
  20097. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  20098. #region 删除指定行
  20099. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  20100. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  20101. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  20102. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  20103. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  20104. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  20105. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  20106. cssIndex = dt.Columns["CityTax"].Ordinal,
  20107. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  20108. remarkIndex = dt.Columns["Remark"].Ordinal;
  20109. //删除指定列
  20110. foreach (DataRow item in dt.Rows)
  20111. {
  20112. string singleStr = item["SingleRoomPrice"].ToString();
  20113. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  20114. if (containsDigitButNotZero1) singleDel = false;
  20115. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  20116. string doubleStr = item["DoubleRoomPrice"].ToString();
  20117. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20118. if (containsDigitButNotZero2) doubleDel = false;
  20119. string suiteStr = item["SuiteRoomPrice"].ToString();
  20120. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20121. if (containsDigitButNotZero3) suiteDel = false;
  20122. string otherStr = item["OtherRoomPrice"].ToString();
  20123. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  20124. if (containsDigitButNotZero4) otherDel = false;
  20125. string zcStr = item["BreakfastPrice"].ToString();
  20126. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  20127. if (containsDigitButNotZero5) zcDel = false;
  20128. string dsStr = item["GovernmentRent"].ToString();
  20129. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  20130. if (containsDigitButNotZero6) dsDel = false;
  20131. string cssStr = item["CityTax"].ToString();
  20132. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  20133. if (containsDigitButNotZero7) cssDel = false;
  20134. string cpStr = item["ConsumptionPatterns"].ToString();
  20135. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  20136. string remarkStr = item["Remark"].ToString();
  20137. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  20138. }
  20139. DeleteColumn(serverPath, remarkIndex, remarkDel);
  20140. DeleteColumn(serverPath, cpIndex, cpDel);
  20141. DeleteColumn(serverPath, dsIndex, dsDel);
  20142. DeleteColumn(serverPath, cssIndex, cssDel);
  20143. DeleteColumn(serverPath, zcIndex, zcDel);
  20144. DeleteColumn(serverPath, otherIndex, otherDel);
  20145. DeleteColumn(serverPath, suiteIndex, suiteDel);
  20146. DeleteColumn(serverPath, doubleIndex, doubleDel);
  20147. DeleteColumn(serverPath, singleIndex, singleDel);
  20148. #endregion
  20149. //只保留第一个表格
  20150. DeleteSheet(serverPath);
  20151. return Ok(JsonView(true, "操作成功", url = rst));
  20152. }
  20153. else
  20154. {
  20155. _currency = _GroupCostParameter.Currency;
  20156. bool isIntType = int.TryParse(_currency, out int currId);
  20157. if (isIntType)
  20158. {
  20159. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  20160. }
  20161. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  20162. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  20163. if (currInfo == null)
  20164. {
  20165. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  20166. }
  20167. if (!_currency.ToUpper().Equals("CNY"))
  20168. {
  20169. _rate = _GroupCostParameter.Rate;
  20170. }
  20171. _rate = currInfo.Rate;
  20172. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  20173. //string strFileName = "HotelStatement/";
  20174. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  20175. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  20176. #region 数据处理
  20177. foreach (var item in hrDtas)
  20178. {
  20179. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  20180. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  20181. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  20182. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  20183. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  20184. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  20185. string singleRoomFeeStr = string.Empty,
  20186. doubleRoomFeeStr = string.Empty,
  20187. suiteRoomFeeStr = string.Empty,
  20188. otherRoomFeeStr = string.Empty,
  20189. payMoneyStr = string.Empty,
  20190. cardPriceStr = string.Empty;
  20191. if (roomCurr.Equals(_currency))
  20192. {
  20193. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  20194. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  20195. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  20196. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  20197. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  20198. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  20199. }
  20200. else
  20201. {
  20202. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  20203. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  20204. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  20205. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  20206. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  20207. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  20208. }
  20209. string breakfastPriceStr = string.Empty,
  20210. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  20211. governmentRentStr = string.Empty,
  20212. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  20213. cityTaxStrStr = string.Empty,
  20214. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  20215. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  20216. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  20217. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  20218. int payDId = roomInfo?.PayDId ?? 0;
  20219. pcfds.Add(new HotelReservations_PCFD_View()
  20220. {
  20221. City = item.City,
  20222. HotelName = item.HotelName,
  20223. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  20224. // SingleRoomCount = item.SingleRoomCount,
  20225. SingleRoomPrice = singleRoomFeeStr,
  20226. // DoubleRoomCount = item.DoubleRoomCount,
  20227. DoubleRoomPrice = doubleRoomFeeStr,
  20228. //SuiteRoomCount = item.SuiteRoomCount,
  20229. SuiteRoomPrice = suiteRoomFeeStr,
  20230. OtherRoomPrice = otherRoomFeeStr,
  20231. //OtherRoomCount = item.OtherRoomCount,
  20232. BreakfastPrice = breakfastPriceStr,
  20233. GovernmentRent = governmentRentStr,
  20234. CityTax = cityTaxStrStr,
  20235. RoomExplanation = item.RoomExplanation,
  20236. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  20237. PayTime = roomInfo?.ConsumptionDate,
  20238. BankNo = roomInfo?.BankNo,
  20239. PayMoney = payMoneyStr,
  20240. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  20241. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  20242. CardPrice = cardPriceStr,
  20243. Remark = ccpInfo.Remark
  20244. });
  20245. }
  20246. #endregion
  20247. //载入模板
  20248. WorkbookDesigner designer = new WorkbookDesigner();
  20249. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  20250. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  20251. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  20252. designer.SetDataSource("TourNo", groupInfo.TourCode);
  20253. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  20254. designer.SetDataSource("Opertor", userInfo.CnName);
  20255. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  20256. dt.TableName = "ViewMyHotelReservations";
  20257. designer.SetDataSource(dt);
  20258. designer.Process();
  20259. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  20260. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  20261. designer.Workbook.Save(serverPath);
  20262. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  20263. #region 删除指定行
  20264. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  20265. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  20266. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  20267. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  20268. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  20269. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  20270. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  20271. cssIndex = dt.Columns["CityTax"].Ordinal,
  20272. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  20273. remarkIndex = dt.Columns["Remark"].Ordinal;
  20274. //删除指定列
  20275. foreach (DataRow item in dt.Rows)
  20276. {
  20277. string singleStr = item["SingleRoomPrice"].ToString();
  20278. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  20279. if (containsDigitButNotZero1) singleDel = false;
  20280. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  20281. string doubleStr = item["DoubleRoomPrice"].ToString();
  20282. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20283. if (containsDigitButNotZero2) doubleDel = false;
  20284. string suiteStr = item["SuiteRoomPrice"].ToString();
  20285. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  20286. if (containsDigitButNotZero3) suiteDel = false;
  20287. string otherStr = item["OtherRoomPrice"].ToString();
  20288. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  20289. if (containsDigitButNotZero4) otherDel = false;
  20290. string zcStr = item["BreakfastPrice"].ToString();
  20291. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  20292. if (containsDigitButNotZero5) zcDel = false;
  20293. string dsStr = item["GovernmentRent"].ToString();
  20294. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  20295. if (containsDigitButNotZero6) dsDel = false;
  20296. string cssStr = item["CityTax"].ToString();
  20297. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  20298. if (containsDigitButNotZero7) cssDel = false;
  20299. string cpStr = item["ConsumptionPatterns"].ToString();
  20300. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  20301. string remarkStr = item["Remark"].ToString();
  20302. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  20303. }
  20304. DeleteColumn(serverPath, remarkIndex, remarkDel);
  20305. DeleteColumn(serverPath, cpIndex, cpDel);
  20306. DeleteColumn(serverPath, dsIndex, dsDel);
  20307. DeleteColumn(serverPath, cssIndex, cssDel);
  20308. DeleteColumn(serverPath, zcIndex, zcDel);
  20309. DeleteColumn(serverPath, otherIndex, otherDel);
  20310. DeleteColumn(serverPath, suiteIndex, suiteDel);
  20311. DeleteColumn(serverPath, doubleIndex, doubleDel);
  20312. DeleteColumn(serverPath, singleIndex, singleDel);
  20313. #endregion
  20314. //只保留第一个表格
  20315. DeleteSheet(serverPath);
  20316. return Ok(JsonView(true, "操作成功", url = rst));
  20317. }
  20318. //return Ok(JsonView(false));
  20319. }
  20320. /// <summary>
  20321. /// 删除指定列
  20322. /// </summary>
  20323. /// <param name="file"></param>
  20324. /// <param name="columnIndex"></param>
  20325. /// <param name="isDel"></param>
  20326. private void DeleteColumn(string file, int columnIndex, bool isDel)
  20327. {
  20328. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20329. //wb.Save(file);
  20330. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  20331. if (sheet1 != null)
  20332. {
  20333. if (isDel)
  20334. {
  20335. Cells cells = sheet1.Cells;
  20336. cells.DeleteColumn(columnIndex);
  20337. }
  20338. }
  20339. wb.Save(file);
  20340. }
  20341. /// <summary>
  20342. /// 删除sheet
  20343. /// </summary>
  20344. /// <param name="file"></param>
  20345. private void DeleteSheet(string file)
  20346. {
  20347. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  20348. //wb.Save(file);
  20349. List<string> sheets = new List<string>();
  20350. foreach (var item in wb.Worksheets)
  20351. {
  20352. sheets.Add(item.Name);
  20353. }
  20354. if (sheets.Count > 0)
  20355. {
  20356. sheets.RemoveAt(0);//不删除第一个sheet
  20357. foreach (var item in sheets)
  20358. {
  20359. wb.Worksheets.RemoveAt(item);
  20360. }
  20361. }
  20362. wb.Save(file);
  20363. }
  20364. /// <summary>
  20365. /// 酒店预订
  20366. /// 确认单
  20367. /// </summary>
  20368. /// <param name="_dto"></param>
  20369. /// <returns></returns>
  20370. [HttpPost]
  20371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20372. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  20373. {
  20374. try
  20375. {
  20376. #region 参数验证
  20377. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  20378. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20379. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  20380. #region 团组操作权限验证 76 酒店预定模块
  20381. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20382. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  20383. #endregion
  20384. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20385. #region 页面操作权限验证
  20386. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20387. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20388. #endregion
  20389. #endregion
  20390. //团组信息
  20391. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  20392. //酒店数据
  20393. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  20394. if (listhoteldata.Count < 0)
  20395. {
  20396. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  20397. }
  20398. //利datatable存储
  20399. DataTable dt = new DataTable();
  20400. dt.Columns.Add("CheckInDate", typeof(string));
  20401. dt.Columns.Add("City", typeof(string));
  20402. dt.Columns.Add("Hotel", typeof(string));
  20403. dt.Columns.Add("Room", typeof(string));
  20404. for (int i = 0; i < listhoteldata.Count; i++)
  20405. {
  20406. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  20407. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  20408. while (dayStart < dayEnd)
  20409. {
  20410. string temp = "";
  20411. DataRow row = dt.NewRow();
  20412. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  20413. row["City"] = listhoteldata[i].City;
  20414. row["Hotel"] = listhoteldata[i].HotelName;
  20415. if (listhoteldata[i].SingleRoomCount > 0)
  20416. {
  20417. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  20418. }
  20419. if (listhoteldata[i].DoubleRoomCount > 0)
  20420. {
  20421. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  20422. }
  20423. if (listhoteldata[i].SuiteRoomCount > 0)
  20424. {
  20425. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  20426. }
  20427. if (listhoteldata[i].OtherRoomCount > 0)
  20428. {
  20429. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  20430. }
  20431. row["Room"] = temp;
  20432. dt.Rows.Add(row);
  20433. dayStart = dayStart.AddDays(1);
  20434. }
  20435. }
  20436. Dictionary<string, string> dic = new Dictionary<string, string>();
  20437. dic.Add("Dele", di.TeamName);
  20438. dic.Add("City", di.VisitCountry);
  20439. //模板路径
  20440. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  20441. //载入模板
  20442. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  20443. DocumentBuilder builder = new DocumentBuilder(doc);
  20444. foreach (var key in dic.Keys)
  20445. {
  20446. builder.MoveToBookmark(key);
  20447. builder.Write(dic[key]);
  20448. }
  20449. //获取word里所有表格
  20450. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  20451. //获取所填表格的序数
  20452. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  20453. var rowStart = tableOne.Rows[0]; //获取第1行
  20454. //循环赋值
  20455. for (int i = 0; i < dt.Rows.Count; i++)
  20456. {
  20457. builder.MoveToCell(0, i + 1, 0, 0);
  20458. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  20459. builder.MoveToCell(0, i + 1, 1, 0);
  20460. builder.Write(dt.Rows[i]["City"].ToString());
  20461. builder.MoveToCell(0, i + 1, 2, 0);
  20462. builder.Write(dt.Rows[i]["Hotel"].ToString());
  20463. builder.MoveToCell(0, i + 1, 3, 0);
  20464. builder.Write(dt.Rows[i]["Room"].ToString());
  20465. }
  20466. //删除多余行
  20467. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  20468. {
  20469. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  20470. }
  20471. string strFileName = di.TeamName + "酒店确认单.doc";
  20472. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  20473. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  20474. return Ok(JsonView(true, "成功", url));
  20475. }
  20476. catch (Exception ex)
  20477. {
  20478. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  20479. }
  20480. }
  20481. #endregion
  20482. #region 团组状态
  20483. /// <summary>
  20484. /// 团组状态列表 Page
  20485. /// </summary>
  20486. /// <param name="dto">团组列表请求dto</param>
  20487. /// <returns></returns>
  20488. [HttpPost]
  20489. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20490. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  20491. {
  20492. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20493. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  20494. {
  20495. string sqlWhere = string.Empty;
  20496. if (dto.IsSure == 0) //未完成
  20497. {
  20498. sqlWhere += string.Format(@" And IsSure = 0");
  20499. }
  20500. else if (dto.IsSure == 1) //已完成
  20501. {
  20502. sqlWhere += string.Format(@" And IsSure = 1");
  20503. }
  20504. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  20505. {
  20506. string tj = dto.SearchCriteria;
  20507. 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}%')",
  20508. tj, tj, tj, tj, tj);
  20509. }
  20510. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  20511. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  20512. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  20513. From (
  20514. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  20515. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  20516. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  20517. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  20518. From Grp_DelegationInfo gdi
  20519. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  20520. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  20521. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  20522. Where gdi.IsDel = 0 {0}
  20523. ) temp ", sqlWhere);
  20524. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  20525. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  20526. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  20527. }
  20528. else
  20529. {
  20530. return Ok(JsonView(false, "查询失败"));
  20531. }
  20532. }
  20533. /// <summary>
  20534. /// 团组状态
  20535. /// 设置操作完成
  20536. /// </summary>
  20537. /// <param name="dto">团组列表请求dto</param>
  20538. /// <returns></returns>
  20539. [HttpPost]
  20540. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20541. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  20542. {
  20543. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  20544. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  20545. {
  20546. Id = dto.Id,
  20547. IsSure = 1
  20548. };
  20549. var result = await _sqlSugar.Updateable(_DelegationInfo)
  20550. .UpdateColumns(it => new { it.IsSure })
  20551. .WhereColumns(it => new { it.Id })
  20552. .ExecuteCommandAsync();
  20553. if (result > 0)
  20554. {
  20555. return Ok(JsonView(true, "操作完成!"));
  20556. }
  20557. return Ok(JsonView(false, "操作失败!"));
  20558. }
  20559. #endregion
  20560. #region 保险费用录入
  20561. /// <summary>
  20562. /// 根据团组Id查询保险费用列表
  20563. /// </summary>
  20564. /// <param name="dto"></param>
  20565. /// <returns></returns>
  20566. [HttpPost]
  20567. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20568. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  20569. {
  20570. Result groupData = await _customersRep.CustomersByDiId(dto);
  20571. if (groupData.Code != 0)
  20572. {
  20573. return Ok(JsonView(false, groupData.Msg));
  20574. }
  20575. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20576. }
  20577. /// <summary>
  20578. /// 根据保险费用Id查询保险费用详细
  20579. /// </summary>
  20580. /// <param name="dto"></param>
  20581. /// <returns></returns>
  20582. [HttpPost]
  20583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20584. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  20585. {
  20586. try
  20587. {
  20588. Result groupData = await _customersRep.CustomersById(dto);
  20589. if (groupData.Code != 0)
  20590. {
  20591. return Ok(JsonView(false, groupData.Msg));
  20592. }
  20593. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20594. }
  20595. catch (Exception ex)
  20596. {
  20597. return Ok(JsonView(false, ex.Message));
  20598. }
  20599. }
  20600. /// <summary>
  20601. /// 保险费用录入页面初始化绑定
  20602. /// </summary>
  20603. /// <param name="dto"></param>
  20604. /// <returns></returns>
  20605. [HttpPost]
  20606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20607. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  20608. {
  20609. try
  20610. {
  20611. Result groupData = await _customersRep.CustomersInitialize(dto);
  20612. if (groupData.Code != 0)
  20613. {
  20614. return Ok(JsonView(false, groupData.Msg));
  20615. }
  20616. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20617. }
  20618. catch (Exception ex)
  20619. {
  20620. return Ok(JsonView(false, ex.Message));
  20621. }
  20622. }
  20623. /// <summary>
  20624. /// 保险费用操作(Status:1.新增,2.修改)
  20625. /// </summary>
  20626. /// <param name="dto"></param>
  20627. /// <returns></returns>
  20628. [HttpPost]
  20629. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20630. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  20631. {
  20632. Result groupData = await _customersRep.OpCustomers(dto);
  20633. if (groupData.Code != 0)
  20634. {
  20635. return Ok(JsonView(false, groupData.Msg));
  20636. }
  20637. #region 应用推送
  20638. try
  20639. {
  20640. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  20641. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  20642. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  20643. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  20644. //自动审核
  20645. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  20646. //2024-10-21 新增LZ UID
  20647. var userIds = new List<int>() { 21 };
  20648. string title = $"系统通知";
  20649. var diId = dto.DiId;
  20650. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20651. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20652. string content = "";
  20653. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20654. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20655. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  20656. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  20657. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  20658. }
  20659. catch (Exception ex)
  20660. {
  20661. }
  20662. #endregion
  20663. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  20664. }
  20665. /// <summary>
  20666. /// 保险文件上传
  20667. /// </summary>
  20668. /// <param name="file"></param>
  20669. /// <returns></returns>
  20670. [HttpPost]
  20671. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20672. public async Task<IActionResult> UploadCus(IFormFile file)
  20673. {
  20674. try
  20675. {
  20676. if (file != null)
  20677. {
  20678. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20679. //文件名称
  20680. string projectFileName = file.FileName;
  20681. //上传的文件的路径
  20682. string filePath = "";
  20683. if (!Directory.Exists(fileDir))
  20684. {
  20685. Directory.CreateDirectory(fileDir);
  20686. }
  20687. //上传的文件的路径
  20688. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  20689. using (FileStream fs = System.IO.File.Create(filePath))
  20690. {
  20691. file.CopyTo(fs);
  20692. fs.Flush();
  20693. }
  20694. return Ok(JsonView(true, "上传成功!", projectFileName));
  20695. }
  20696. else
  20697. {
  20698. return Ok(JsonView(false, "上传失败!"));
  20699. }
  20700. }
  20701. catch (Exception ex)
  20702. {
  20703. return Ok(JsonView(false, ex.Message));
  20704. }
  20705. }
  20706. /// <summary>
  20707. /// 保险删除指定文件
  20708. /// </summary>
  20709. /// <param name="dto"></param>
  20710. /// <returns></returns>
  20711. [HttpPost]
  20712. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20713. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  20714. {
  20715. try
  20716. {
  20717. string filePath = "";
  20718. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  20719. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  20720. //int id = 0;
  20721. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  20722. // 删除该文件
  20723. try
  20724. {
  20725. System.IO.File.Delete(filePath);
  20726. 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()
  20727. {
  20728. Attachment = "",
  20729. }).ExecuteCommandAsync();
  20730. if (result != 0)
  20731. {
  20732. return Ok(JsonView(true, "成功!"));
  20733. }
  20734. else
  20735. {
  20736. return Ok(JsonView(false, "失败!"));
  20737. }
  20738. }
  20739. catch (Exception)
  20740. {
  20741. 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()
  20742. {
  20743. Attachment = "",
  20744. }).ExecuteCommandAsync();
  20745. if (result != 0)
  20746. {
  20747. return Ok(JsonView(true, "成功!"));
  20748. }
  20749. else
  20750. {
  20751. return Ok(JsonView(false, "失败!"));
  20752. }
  20753. }
  20754. }
  20755. catch (Exception ex)
  20756. {
  20757. return Ok(JsonView(false, "程序错误!"));
  20758. throw;
  20759. }
  20760. }
  20761. /// <summary>
  20762. /// 保险费用操作(删除)
  20763. /// </summary>
  20764. /// <param name="dto"></param>
  20765. /// <returns></returns>
  20766. [HttpPost]
  20767. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20768. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  20769. {
  20770. try
  20771. {
  20772. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  20773. if (!res)
  20774. {
  20775. return Ok(JsonView(false, "删除失败"));
  20776. }
  20777. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  20778. {
  20779. IsDel = 1,
  20780. DeleteUserId = dto.DeleteUserId,
  20781. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  20782. }).ExecuteCommandAsync();
  20783. return Ok(JsonView(true, "删除成功!"));
  20784. }
  20785. catch (Exception ex)
  20786. {
  20787. return Ok(JsonView(false, "程序错误!"));
  20788. throw;
  20789. }
  20790. }
  20791. #endregion
  20792. #region 接团客户名单 PageId 104
  20793. /// <summary>
  20794. /// 接团客户名单
  20795. /// 迁移数据(慎用!)
  20796. /// </summary>
  20797. /// <returns></returns>
  20798. [HttpPost]
  20799. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20800. public async Task<IActionResult> PostTourClientListChange()
  20801. {
  20802. try
  20803. {
  20804. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  20805. //var groupClinetData1
  20806. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  20807. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  20808. int updateCount = 0;
  20809. if (oldOAClientList.Count > 0)
  20810. {
  20811. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  20812. _sqlSugar.BeginTran();
  20813. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  20814. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  20815. foreach (var item in oldOAClientList)
  20816. {
  20817. int comId = 0;
  20818. string format = "yyyy-MM-dd HH:mm:ss";
  20819. string data11 = "1990-01-01 00:00";
  20820. var data1 = IsValidDate(item.OPdate, format);
  20821. if (data1) data11 = item.OPdate;
  20822. //客户公司验证
  20823. if (!string.IsNullOrEmpty(item.Company))
  20824. {
  20825. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  20826. if (clientComInfo == null) // add
  20827. {
  20828. var addInfo = new Crm_CustomerCompany()
  20829. {
  20830. CompanyAbbreviation = "",
  20831. CompanyFullName = item.Company,
  20832. Address = "",
  20833. PostCodes = "",
  20834. LastedOpUserId = item.OPer,
  20835. LastedOpDt = Convert.ToDateTime(data11),
  20836. CreateUserId = item.OPer,
  20837. CreateTime = Convert.ToDateTime(data11),
  20838. IsDel = 0
  20839. };
  20840. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  20841. if (comId1 > 0) comId = comId1;
  20842. }
  20843. else comId = clientComInfo.Id;
  20844. }
  20845. //客户人员验证
  20846. int clientId = 0;
  20847. string name = item.LastName + item.Name;
  20848. if (!string.IsNullOrEmpty(name))
  20849. {
  20850. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  20851. if (clientInfo == null)
  20852. {
  20853. DateTime? dateTime = null;
  20854. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  20855. if (isDt) dateTime = birthDayDt;
  20856. var addInfo1 = new Crm_DeleClient()
  20857. {
  20858. CrmCompanyId = comId,
  20859. DiId = -1,
  20860. LastName = item.LastName,
  20861. FirstName = item.Name,
  20862. OldName = "",
  20863. Pinyin = item.Pinyin,
  20864. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  20865. Marriage = 0,
  20866. Phone = item.Phone,
  20867. Job = item.Job,
  20868. BirthDay = dateTime
  20869. };
  20870. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  20871. if (clientId1 > 0) clientId = clientId1;
  20872. }
  20873. else clientId = clientInfo.Id;
  20874. }
  20875. if (clientId < 1)
  20876. {
  20877. continue;
  20878. }
  20879. int airType = 0;
  20880. if (item.AirType == "超经舱") airType = 459;
  20881. else if (item.AirType == "公务舱") airType = 458;
  20882. else if (item.AirType == "经济舱") airType = 460;
  20883. else if (item.AirType == "其他") airType = 565;
  20884. else if (item.AirType == "头等舱") airType = 457;
  20885. var _TourClientListEntity = new Grp_TourClientList()
  20886. {
  20887. DiId = item.Diid,
  20888. ClientId = clientId,
  20889. CreateUserId = item.OPer,
  20890. CreateTime = Convert.ToDateTime(data11),
  20891. Remark = item.Remark,
  20892. IsDel = item.Isdel,
  20893. ShippingSpaceTypeId = airType,
  20894. ShippingSpaceSpecialNeeds = item.AirRemark,
  20895. HotelSpecialNeeds = item.RoomType
  20896. };
  20897. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  20898. if (_TourClientList > 0)
  20899. {
  20900. updateCount++;
  20901. }
  20902. }
  20903. _sqlSugar.CommitTran();
  20904. }
  20905. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  20906. }
  20907. catch (Exception ex)
  20908. {
  20909. _sqlSugar.RollbackTran();
  20910. return Ok(JsonView(false, ex.Message));
  20911. }
  20912. //return Ok(JsonView(true));
  20913. }
  20914. private bool IsValidDate(string dateString, string format)
  20915. {
  20916. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  20917. }
  20918. /// <summary>
  20919. /// 接团客户名单
  20920. /// 根据团组Id查询List
  20921. /// </summary>
  20922. /// <param name="_dto"></param>
  20923. /// <returns></returns>
  20924. [HttpPost]
  20925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20926. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  20927. {
  20928. #region 参数验证
  20929. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  20930. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  20931. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  20932. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20933. #region 页面操作权限验证
  20934. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20935. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20936. #endregion
  20937. #endregion
  20938. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  20939. if (viewData.Code != 0)
  20940. {
  20941. return Ok(JsonView(false, viewData.Msg));
  20942. }
  20943. return Ok(JsonView(viewData.Data));
  20944. }
  20945. /// <summary>
  20946. /// 接团客户名单
  20947. /// 基础数据 Init
  20948. /// </summary>
  20949. /// <param name="_dto"></param>
  20950. /// <returns></returns>
  20951. [HttpPost]
  20952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20953. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  20954. {
  20955. #region 参数验证
  20956. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20957. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20958. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20959. #region 页面操作权限验证
  20960. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20961. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20962. #endregion
  20963. #endregion
  20964. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  20965. }
  20966. /// <summary>
  20967. /// 接团客户名单
  20968. /// 根据 Id查询 Details
  20969. /// </summary>
  20970. /// <param name="_dto"></param>
  20971. /// <returns></returns>
  20972. [HttpPost]
  20973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20974. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  20975. {
  20976. #region 参数验证
  20977. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  20978. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  20979. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  20980. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20981. #region 页面操作权限验证
  20982. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20983. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20984. #endregion
  20985. #endregion
  20986. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  20987. if (viewData.Code != 0)
  20988. {
  20989. return Ok(JsonView(false, viewData.Msg));
  20990. }
  20991. return Ok(JsonView(viewData.Data));
  20992. }
  20993. /// <summary>
  20994. /// 接团客户名单
  20995. /// Add Or Edit
  20996. /// </summary>
  20997. /// <param name="_dto"></param>
  20998. /// <returns></returns>
  20999. [HttpPost]
  21000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21001. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  21002. {
  21003. #region 参数验证
  21004. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21005. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21006. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  21007. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21008. #region 页面操作权限验证
  21009. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21010. if (_dto.Id == 0) //添加
  21011. {
  21012. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  21013. }
  21014. else if (_dto.Id >= 0) //修改
  21015. {
  21016. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  21017. }
  21018. #endregion
  21019. #endregion
  21020. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  21021. if (viewData.Code != 0)
  21022. {
  21023. return Ok(JsonView(false, viewData.Msg));
  21024. }
  21025. return Ok(JsonView(true));
  21026. }
  21027. /// <summary>
  21028. /// 接团客户名单
  21029. /// json字符串 AddMultiple(添加多个)
  21030. /// </summary>
  21031. /// <param name="_dto"></param>
  21032. /// <returns></returns>
  21033. [HttpPost]
  21034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21035. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  21036. {
  21037. #region 参数验证
  21038. string jsonLabel = _dto.JsonLabel;
  21039. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21040. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21041. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21042. #region 页面操作权限验证
  21043. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21044. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  21045. #endregion
  21046. #endregion
  21047. var request = new TourClientListAddMultipleDto();
  21048. request.DiId = _dto.DiId;
  21049. request.UserId = _dto.UserId;
  21050. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  21051. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  21052. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  21053. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  21054. var infos = new List<TourClientListInfo>();
  21055. foreach (var data in datas)
  21056. {
  21057. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  21058. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  21059. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  21060. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  21061. {
  21062. continue;
  21063. }
  21064. infos.Add(new TourClientListInfo()
  21065. {
  21066. IsAccompany = 1,
  21067. LastName = lastName,
  21068. FirstName = firstName,
  21069. Pinyin = lastNameEn + @"/" + firstNameEn,
  21070. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  21071. CompanyFullName = data.CompanyFullName,
  21072. Job = data.Job
  21073. });
  21074. }
  21075. if (infos.Any())
  21076. {
  21077. var viewData = await _tourClientListRep._AddMultiple(request);
  21078. if (viewData.Code != 0)
  21079. {
  21080. return Ok(JsonView(false, viewData.Msg));
  21081. }
  21082. return Ok(JsonView(true));
  21083. }
  21084. return Ok(JsonView(false));
  21085. }
  21086. /// <summary>
  21087. /// 接团客户名单
  21088. /// AddMultiple(添加多个)
  21089. /// </summary>
  21090. /// <param name="_dto"></param>
  21091. /// <returns></returns>
  21092. [HttpPost]
  21093. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21094. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  21095. {
  21096. #region 参数验证
  21097. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21098. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21099. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21100. #region 页面操作权限验证
  21101. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21102. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  21103. #endregion
  21104. #endregion
  21105. var viewData = await _tourClientListRep._AddMultiple(_dto);
  21106. if (viewData.Code != 0)
  21107. {
  21108. return Ok(JsonView(false, viewData.Msg));
  21109. }
  21110. return Ok(JsonView(true));
  21111. }
  21112. /// <summary>
  21113. /// 接团客户名单
  21114. /// Del
  21115. /// </summary>
  21116. /// <param name="_dto"></param>
  21117. /// <returns></returns>
  21118. [HttpPost]
  21119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21120. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  21121. {
  21122. #region 参数验证
  21123. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21124. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21125. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21126. #region 页面操作权限验证
  21127. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21128. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  21129. #endregion
  21130. #endregion
  21131. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  21132. if (viewData.Code != 0)
  21133. {
  21134. return Ok(JsonView(false, viewData.Msg));
  21135. }
  21136. return Ok(JsonView(true));
  21137. }
  21138. /// <summary>
  21139. /// 接团客户名单
  21140. /// 文件下载 客户名单
  21141. /// </summary>
  21142. /// <param name="_dto"></param>
  21143. /// <returns></returns>
  21144. [HttpPost]
  21145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21146. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  21147. {
  21148. #region 参数验证
  21149. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  21150. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  21151. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  21152. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21153. #region 页面操作权限验证
  21154. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21155. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21156. #endregion
  21157. #endregion
  21158. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  21159. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  21160. From Grp_TourClientList tcl
  21161. Left Join
  21162. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  21163. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  21164. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  21165. From Crm_DeleClient dc
  21166. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  21167. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  21168. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  21169. Where dc.IsDel = 0) temp
  21170. On temp.DcId =tcl.ClientId
  21171. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  21172. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  21173. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  21174. //载入模板
  21175. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  21176. if (_dto.Language == 1)
  21177. {
  21178. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  21179. }
  21180. //载入模板
  21181. var doc = new Document(tempPath);
  21182. DocumentBuilder builder = new DocumentBuilder(doc);
  21183. //获取word里所有表格
  21184. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21185. //获取所填表格的序数
  21186. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  21187. var rowStart = tableOne.Rows[0]; //获取第1行
  21188. if (_dto.Language == 0)
  21189. {
  21190. //循环赋值
  21191. for (int i = 0; i < DcList.Count; i++)
  21192. {
  21193. EncryptionProcessor.DecryptProperties(DcList[i]);
  21194. builder.MoveToCell(0, i + 1, 0, 0);
  21195. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  21196. builder.MoveToCell(0, i + 1, 1, 0);
  21197. int sex = DcList[i].Sex;
  21198. string sexStr = string.Empty;
  21199. if (sex == 0) sexStr = "男";
  21200. else if (sex == 1) sexStr = "女";
  21201. else sexStr = "未设置";
  21202. builder.Write(sexStr);
  21203. builder.MoveToCell(0, i + 1, 2, 0);
  21204. string birthDay = DcList[i].BirthDay;
  21205. string birthDayStr = string.Empty;
  21206. if (!string.IsNullOrEmpty(birthDay))
  21207. {
  21208. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  21209. }
  21210. builder.Write(birthDayStr);
  21211. builder.MoveToCell(0, i + 1, 3, 0);
  21212. string company = "";
  21213. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21214. {
  21215. company = DcList[i].CompanyFullName.ToString();
  21216. }
  21217. builder.Write(company);
  21218. builder.MoveToCell(0, i + 1, 4, 0);
  21219. builder.Write(DcList[i].Job);
  21220. }
  21221. }
  21222. else if (_dto.Language == 1)
  21223. {
  21224. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  21225. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  21226. List<string> transArrayStr = new List<string>();
  21227. string transStrRes1 = "";
  21228. var clientEnglishs = new List<ClientEnglishView>();
  21229. for (int i = 0; i < DcList.Count; i++)
  21230. {
  21231. var dc = DcList[i];
  21232. EncryptionProcessor.DecryptProperties(dc);
  21233. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  21234. if (dc.Job.Equals("暂无")) dc.Job = "-";
  21235. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  21236. if (DcList.Count - 1 == i) transStrRes1 += str1;
  21237. else transStrRes1 += $"{str1}|";
  21238. clientEnglishs.Add(new()
  21239. {
  21240. Id = dc.Id,
  21241. LastName = dc.LastName,
  21242. FirstName = dc.FirstName,
  21243. Pinyin = dc.Pinyin,
  21244. Sex = dc.Sex,
  21245. CompanyFullName = dc.CompanyFullName,
  21246. Job = dc.Job,
  21247. IDCardNo = dc.IDCardNo,
  21248. BirthDay = dc.BirthDay,
  21249. });
  21250. }
  21251. #region AI转英文
  21252. string jsonValue = JsonConvert.SerializeObject(clientEnglishs);
  21253. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  21254. List<SeedMessages> messages = new List<SeedMessages>()
  21255. {
  21256. new SeedMessages
  21257. {
  21258. Role = KimiRole.user,
  21259. Content = jsonValue + text
  21260. }
  21261. };
  21262. KiMiApiClient client = new KiMiApiClient();
  21263. var kimiApiResult = await client.SeedMessage(messages);
  21264. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21265. string clients = kimiApiResult_JObject["content"].ToString();
  21266. string startStr = "```json", endStr = "```";
  21267. // 判断并清除开头部分
  21268. if (clients.StartsWith(startStr))
  21269. {
  21270. clients = clients.Remove(0, startStr.Length);
  21271. }
  21272. // 判断并清除结尾部分
  21273. if (clients.EndsWith(endStr))
  21274. {
  21275. clients = clients.Remove(clients.Length - endStr.Length);
  21276. }
  21277. var en_Json = JsonConvert.DeserializeObject<List<ClientEnglishView>>(clients);
  21278. //循环赋值
  21279. for (int i = 0; i < en_Json.Count; i++)
  21280. {
  21281. var dc = en_Json[i];
  21282. var dc1 = DcList.Find(x => x.Id == dc.Id);
  21283. string PYName = dc.FirstName + " " + dc.LastName;
  21284. builder.MoveToCell(0, i + 1, 0, 0);
  21285. builder.Write(PYName);
  21286. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  21287. builder.MoveToCell(0, i + 1, 1, 0);
  21288. builder.Write(sex);
  21289. DateTime birthDt;
  21290. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  21291. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21292. builder.MoveToCell(0, i + 1, 2, 0);
  21293. builder.Write(birthday);
  21294. string company = string.Empty, job = string.Empty;
  21295. company = dc.CompanyFullName;
  21296. job = dc.Job;
  21297. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  21298. {
  21299. //查询对照表
  21300. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  21301. if (tempCec != null)
  21302. {
  21303. company = tempCec.enName;
  21304. }
  21305. }
  21306. builder.MoveToCell(0, i + 1, 3, 0);
  21307. builder.Write(company);
  21308. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  21309. {
  21310. //查询对照表
  21311. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  21312. if (tempPec != null)
  21313. {
  21314. job = tempPec.enName;
  21315. }
  21316. }
  21317. builder.MoveToCell(0, i + 1, 4, 0);
  21318. builder.Write(job);
  21319. }
  21320. #endregion
  21321. #region 旧翻译英文处理
  21322. ////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";
  21323. //string transStrRes = "";
  21324. //if (transStrRes1.Length > 0)
  21325. //{
  21326. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  21327. //}
  21328. ////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
  21329. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  21330. ////List<string> transArray = new List<string> { };
  21331. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  21332. //if (transStrRes.Contains("|"))
  21333. //{
  21334. // string[] transArray1 = transStrRes.Split('|');
  21335. // if (transArray1.Length > 0)
  21336. // {
  21337. // foreach (var item in transArray1)
  21338. // {
  21339. // if (item.Contains("&"))
  21340. // {
  21341. // string[] transArray2 = item.Split('&');
  21342. // int index = 0;
  21343. // string companyName = "", job = "";
  21344. // if (transArray2.Length > 0)
  21345. // {
  21346. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  21347. // if (1 < transArray2.Length) companyName = transArray2[1];
  21348. // if (2 < transArray2.Length) job = transArray2[2];
  21349. // }
  21350. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  21351. // }
  21352. // }
  21353. // }
  21354. //}
  21355. ////循环赋值
  21356. //for (int i = 0; i < DcList.Count; i++)
  21357. //{
  21358. // string PYName = "";
  21359. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  21360. // {
  21361. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  21362. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  21363. // PYName = PY_First + " " + PY_Last;
  21364. // }
  21365. // else
  21366. // {
  21367. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  21368. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  21369. // PYName = PY_First + " " + PY_Last;
  21370. // }
  21371. // builder.MoveToCell(0, i + 1, 0, 0);
  21372. // builder.Write(PYName);
  21373. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  21374. // builder.MoveToCell(0, i + 1, 1, 0);
  21375. // builder.Write(sex);
  21376. // DateTime birthDt;
  21377. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  21378. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  21379. // builder.MoveToCell(0, i + 1, 2, 0);
  21380. // builder.Write(birthday);
  21381. // string company = string.Empty, job = string.Empty;
  21382. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  21383. // if (dcTransInfo != null)
  21384. // {
  21385. // company = dcTransInfo.CompanyName;
  21386. // job = dcTransInfo.Job;
  21387. // }
  21388. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  21389. // {
  21390. // //查询对照表
  21391. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  21392. // if (tempCec != null)
  21393. // {
  21394. // company = tempCec.enName;
  21395. // }
  21396. // //翻译
  21397. // else
  21398. // {
  21399. // }
  21400. // }
  21401. // builder.MoveToCell(0, i + 1, 3, 0);
  21402. // builder.Write(company);
  21403. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  21404. // {
  21405. // //查询对照表
  21406. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  21407. // if (tempPec != null)
  21408. // {
  21409. // job = tempPec.enName;
  21410. // }
  21411. // //翻译
  21412. // else
  21413. // {
  21414. // }
  21415. // }
  21416. // builder.MoveToCell(0, i + 1, 4, 0);
  21417. // builder.Write(job);
  21418. //}
  21419. #endregion
  21420. }
  21421. //删除多余行
  21422. while (tableOne.Rows.Count > DcList.Count + 1)
  21423. {
  21424. tableOne.Rows.RemoveAt(DcList.Count + 1);
  21425. }
  21426. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  21427. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  21428. doc.Save(fileDir);
  21429. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  21430. return Ok(JsonView(true, "操作成功!", Url));
  21431. }
  21432. private class TranslateInfo
  21433. {
  21434. public int Index { get; set; }
  21435. public string CompanyName { get; set; }
  21436. public string Job { get; set; }
  21437. }
  21438. [HttpPost]
  21439. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  21440. {
  21441. if (files.Count == 0)
  21442. {
  21443. return Ok(JsonView(false, "文件为空"));
  21444. }
  21445. KiMiApiClient KiMiApi = new KiMiApiClient();
  21446. var seedConter = await KiMiApi.UploadFilesAsync(files);
  21447. if (seedConter.Count == 0)
  21448. {
  21449. return Ok(JsonView(false, "上传结果为空!"));
  21450. }
  21451. var messages = new List<SeedMessages>
  21452. {
  21453. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  21454. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  21455. };
  21456. messages.InsertRange(1, seedConter);
  21457. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  21458. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  21459. string clients = kimiApiResult_JObject["content"].ToString();
  21460. string startStr = "```json", endStr = "```";
  21461. // 判断并清除开头部分
  21462. if (clients.StartsWith(startStr))
  21463. {
  21464. clients = clients.Remove(0, startStr.Length);
  21465. }
  21466. // 判断并清除结尾部分
  21467. if (clients.EndsWith(endStr))
  21468. {
  21469. clients = clients.Remove(clients.Length - endStr.Length);
  21470. }
  21471. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  21472. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  21473. {
  21474. {"姓", "LastName" },
  21475. {"名", "FirstName" },
  21476. {"姓名拼音", "Pinyin" },
  21477. {"性别", "Sex" },
  21478. {"单位", "CompanyFullName" },
  21479. {"职务", "Job" },
  21480. {"出生日期", "Birthday" },
  21481. };
  21482. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  21483. foreach (var item in clients_JObject)
  21484. {
  21485. BaiduClientOCRView cdc = new BaiduClientOCRView();
  21486. foreach (var field in clientFieldMap.Keys)
  21487. {
  21488. if (item.TryGetValue(field, out JToken value))
  21489. {
  21490. var getValue = value.ToString();
  21491. System.Type type = cdc.GetType();
  21492. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  21493. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  21494. propertyInfo.SetValue(cdc, propertyValue);
  21495. }
  21496. }
  21497. crmClients.Add(cdc);
  21498. }
  21499. return Ok(JsonView(new
  21500. {
  21501. fileCount = files.Count,
  21502. UploadCount = seedConter.Count,
  21503. ApiResult = clients,
  21504. CrmClients = crmClients
  21505. }));
  21506. }
  21507. #endregion
  21508. #region 团组倒推表
  21509. /// <summary>
  21510. /// 倒推表基础数据
  21511. /// Init
  21512. /// </summary>
  21513. /// <returns></returns>
  21514. [HttpPost]
  21515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21516. public async Task<IActionResult> PostInvertedListInit()
  21517. {
  21518. var viewData = await _invertedListRep._Init();
  21519. if (viewData.Code != 0)
  21520. {
  21521. return Ok(JsonView(false, viewData.Msg));
  21522. }
  21523. return Ok(JsonView(viewData.Data));
  21524. }
  21525. /// <summary>
  21526. /// 倒推表
  21527. /// Info
  21528. /// </summary>
  21529. /// <param name="dto"></param>
  21530. /// <returns></returns>
  21531. [HttpPost]
  21532. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21533. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  21534. {
  21535. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  21536. if (viewData.Code != 0)
  21537. {
  21538. return Ok(JsonView(false, viewData.Msg));
  21539. }
  21540. return Ok(JsonView(viewData.Data));
  21541. }
  21542. /// <summary>
  21543. /// 倒推表
  21544. /// Create
  21545. /// </summary>
  21546. /// <param name="dto"></param>
  21547. /// <returns></returns>
  21548. [HttpPost]
  21549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21550. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  21551. {
  21552. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  21553. if (viewData.Code != 0)
  21554. {
  21555. return Ok(JsonView(false, viewData.Msg));
  21556. }
  21557. return Ok(JsonView(viewData.Data));
  21558. }
  21559. /// <summary>
  21560. /// 倒推表
  21561. /// Update
  21562. /// </summary>
  21563. /// <param name="dto"></param>
  21564. /// <returns></returns>
  21565. [HttpPost]
  21566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21567. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  21568. {
  21569. var viewData = await _invertedListRep._Update(dto);
  21570. if (viewData.Code != 0)
  21571. {
  21572. return Ok(JsonView(false, viewData.Msg));
  21573. }
  21574. return Ok(JsonView(viewData.Data));
  21575. }
  21576. /// <summary>
  21577. /// 倒推表
  21578. /// File Download
  21579. /// </summary>
  21580. /// <param name="dto"></param>
  21581. /// <returns></returns>
  21582. [HttpPost]
  21583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21584. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  21585. {
  21586. var info2 = await _invertedListRep._Info(1, dto.DiId);
  21587. if (info2.Code != 0)
  21588. {
  21589. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  21590. }
  21591. var info1 = info2.Data as InvertedListInfoView;
  21592. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  21593. string teamName = "";
  21594. if (info != null) teamName = info.TeamName;
  21595. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  21596. var doc = new Document();
  21597. var builder = new DocumentBuilder(doc);
  21598. #region old insert
  21599. ////载入模板
  21600. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  21601. //Document doc = new Document(tempPath);
  21602. //DocumentBuilder builder = new DocumentBuilder(doc);
  21603. //利用键值对存放数据
  21604. //Dictionary<string, string> dic = new Dictionary<string, string>();
  21605. //dic.Add("TeamName", teamName);
  21606. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  21607. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  21608. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  21609. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  21610. //dic.Add("SQRemark", info1.ApprovalRemark);
  21611. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  21612. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  21613. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  21614. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  21615. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  21616. //dic.Add("QZRemark", info1.VisaInformationRemark);
  21617. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  21618. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  21619. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  21620. //dic.Add("CQRemark", info1.IssueVisaRemark);
  21621. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  21622. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  21623. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  21624. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  21625. //#region 填充word模板书签内容
  21626. //foreach (var key in dic.Keys)
  21627. //{
  21628. // builder.MoveToBookmark(key);
  21629. // builder.Write(dic[key]);
  21630. //}
  21631. //#endregion
  21632. #endregion
  21633. #region New Insert
  21634. string titleFont = $"仿宋",
  21635. contentFont = $"仿宋";
  21636. var fontColor = Color.FromArgb(64, 64, 64);
  21637. //设置标题 团组名称
  21638. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21639. builder.Font.Name = titleFont;
  21640. builder.Font.Color = fontColor;
  21641. builder.Font.Size = 12;
  21642. builder.Font.Bold = true;
  21643. builder.Writeln(teamName);
  21644. //设置副标题 团组出访时间
  21645. builder.Font.Size = 12;
  21646. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  21647. builder.Writeln();
  21648. var backgroundColor = Color.FromArgb(199, 199, 199);
  21649. var table = builder.StartTable();
  21650. builder.InsertCell();
  21651. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  21652. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  21653. builder.CellFormat.Borders.LineWidth = 1;
  21654. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  21655. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  21656. builder.RowFormat.Height = 40;
  21657. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21658. builder.Font.Name = contentFont;
  21659. builder.Font.Size = 12;
  21660. builder.Font.Bold = true;
  21661. builder.Font.Color = fontColor;
  21662. builder.Write("时间");
  21663. builder.InsertCell();
  21664. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  21665. builder.Write("流程");
  21666. builder.InsertCell();
  21667. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  21668. builder.Write("说明");
  21669. builder.EndRow();
  21670. //报批资料准备
  21671. if (info1.IsSelectedAirportd)
  21672. {
  21673. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  21674. }
  21675. //报批/提供送签资料
  21676. if (info1.IsSelectedApprovalData)
  21677. {
  21678. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  21679. }
  21680. //出批件护照办理
  21681. if (info1.IsSelectedIssueApproval)
  21682. {
  21683. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  21684. }
  21685. //签证资料准备
  21686. if (info1.IsSelectedVisaInfo)
  21687. {
  21688. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  21689. }
  21690. //送签
  21691. if (info1.IsSelectedSendVisa)
  21692. {
  21693. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  21694. }
  21695. //出签
  21696. if (info1.IsSelectedIssueVisa)
  21697. {
  21698. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  21699. }
  21700. //机票
  21701. if (info1.IsSelectedAirTicket)
  21702. {
  21703. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  21704. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  21705. }
  21706. //酒店
  21707. if (info1.IsSelectedHotel)
  21708. {
  21709. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  21710. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  21711. }
  21712. //开行前会
  21713. if (info1.IsSelectedPreTripMeeting)
  21714. {
  21715. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  21716. }
  21717. //送机
  21718. if (info1.IsSelectedAirportdDropOff)
  21719. {
  21720. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  21721. }
  21722. builder.EndTable();
  21723. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  21724. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  21725. for (int i = 0; i < table.Rows.Count; i++)
  21726. {
  21727. var row = table.Rows[i];
  21728. //设置宽度
  21729. row.Cells[0].CellFormat.Width = 20.00;
  21730. row.Cells[1].CellFormat.Width = 30.00;
  21731. row.Cells[2].CellFormat.Width = 50.00;
  21732. if (i != 0)
  21733. {
  21734. //边框设置
  21735. InvertedListFileDownloadSetBorders(row.Cells, 0);
  21736. InvertedListFileDownloadSetBorders(row.Cells, 1);
  21737. InvertedListFileDownloadSetBorders(row.Cells, 2);
  21738. }
  21739. }
  21740. #region 页脚插入图片
  21741. // 创建页脚
  21742. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  21743. doc.FirstSection.HeadersFooters.Add(footer);
  21744. Paragraph para = new Paragraph(doc);
  21745. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  21746. footer.AppendChild(para);
  21747. builder.MoveTo(para);
  21748. string imagePath = "./Images/FMGJ_Log.png";
  21749. builder.InsertImage(imagePath);
  21750. #endregion
  21751. #endregion
  21752. var fileDir = AppSettingsHelper.Get("WordBasePath");
  21753. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  21754. string filePath = fileDir + $@"InvertedList/{fileName}";
  21755. doc.Save(filePath);
  21756. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  21757. return Ok(JsonView(true, "操作成功!", Url));
  21758. }
  21759. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  21760. {
  21761. var fontColor = Color.FromArgb(64, 64, 64);
  21762. builder.InsertCell();
  21763. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  21764. builder.RowFormat.Height = 40;
  21765. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21766. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21767. builder.Font.Name = fontName;
  21768. builder.Font.Size = 8;
  21769. builder.Font.Bold = true;
  21770. builder.Font.Color = fontColor;
  21771. builder.Write(dateTime);
  21772. builder.InsertCell();
  21773. builder.Font.Size = 9;
  21774. builder.Font.Bold = true;
  21775. builder.Font.Color = fontColor;
  21776. builder.Write(content);
  21777. builder.InsertCell();
  21778. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  21779. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  21780. builder.Font.Size = 9;
  21781. builder.Font.Bold = false;
  21782. builder.Font.Color = fontColor;
  21783. builder.Write(reamrk);
  21784. builder.EndRow();
  21785. }
  21786. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  21787. {
  21788. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  21789. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  21790. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  21791. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  21792. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  21793. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  21794. }
  21795. #endregion
  21796. #region 会务倒推表
  21797. /// <summary>
  21798. /// 会务倒推表
  21799. /// Init
  21800. /// </summary>
  21801. /// <returns></returns>
  21802. [HttpPost]
  21803. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21804. public async Task<IActionResult> InforRetrogressTableInit()
  21805. {
  21806. var groupData = await _groupRepository.PostShareGroupInfos(1);
  21807. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  21808. return Ok(JsonView(false, groupData.Msg));
  21809. }
  21810. /// <summary>
  21811. /// 会务倒推表
  21812. /// ExcelDownload
  21813. /// </summary>
  21814. /// <param name="dto"></param>
  21815. /// <returns></returns>
  21816. [HttpPost]
  21817. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  21818. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21819. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  21820. {
  21821. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  21822. var validatorRes = await validator.ValidateAsync(dto);
  21823. if (!validatorRes.IsValid)
  21824. {
  21825. StringBuilder sb = new StringBuilder();
  21826. foreach (var item in validatorRes.Errors)
  21827. {
  21828. sb.AppendLine(item.ErrorMessage);
  21829. }
  21830. return Ok(JsonView(false, sb.ToString()));
  21831. }
  21832. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  21833. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  21834. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  21835. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  21836. #region Excel
  21837. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  21838. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  21839. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  21840. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  21841. var fileNamePrefix = string.Empty;
  21842. if (days >= 30)
  21843. {
  21844. tempPath += $"会务工作倒推进度表(30天).xlsx";
  21845. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  21846. }
  21847. else if (days < 30 && days > 7)
  21848. {
  21849. tempPath += $"会务工作倒推进度表(15天).xlsx";
  21850. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  21851. }
  21852. else if (days <= 7)
  21853. {
  21854. tempPath += $"会务工作倒推进度表(7天).xlsx";
  21855. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  21856. }
  21857. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  21858. fileName = CommonFun.ValidFileName(fileName);
  21859. //载入模板
  21860. WorkbookDesigner designer = new WorkbookDesigner();
  21861. designer.Workbook = new Workbook(tempPath);
  21862. designer.Process();
  21863. if (!Directory.Exists(savePath))
  21864. {
  21865. Directory.CreateDirectory(savePath);
  21866. }
  21867. string serverPath = $"{savePath}{fileName}";
  21868. designer.Workbook.Save(serverPath);
  21869. string rst = $"{servicePath}{ftpPath}{fileName}";
  21870. #endregion
  21871. return Ok(JsonView(new { url = rst }));
  21872. }
  21873. #endregion
  21874. #region 三公签证费用(签证费、代办费)
  21875. /// <summary>
  21876. /// 三公签证费用(签证费、代办费)
  21877. /// List
  21878. /// </summary>
  21879. /// <returns></returns>
  21880. [HttpPost]
  21881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21882. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  21883. {
  21884. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  21885. }
  21886. /// <summary>
  21887. /// 三公签证费用(签证费、代办费)
  21888. /// Add Or Update
  21889. /// </summary>
  21890. /// <returns></returns>
  21891. [HttpPost]
  21892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21893. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  21894. {
  21895. var _view = await _visaFeeInfoRep.Update(_dto);
  21896. if (_view.Code != 0)
  21897. {
  21898. return Ok(JsonView(false, _view.Msg));
  21899. }
  21900. return Ok(JsonView(true, _view.Msg));
  21901. }
  21902. #endregion
  21903. #region 酒店询价
  21904. /// <summary>
  21905. /// 酒店询价
  21906. /// Init
  21907. /// </summary>
  21908. /// <returns></returns>
  21909. [HttpPost]
  21910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21911. public async Task<IActionResult> PostHotelInquiryInit()
  21912. {
  21913. var res = await _hotelInquiryRep._Init();
  21914. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21915. return Ok(JsonView(true, res.Msg, res.Data));
  21916. }
  21917. /// <summary>
  21918. /// 酒店询价
  21919. /// page Item
  21920. /// </summary>
  21921. /// <param name="_dto"></param>
  21922. /// <returns></returns>
  21923. [HttpPost]
  21924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21925. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  21926. {
  21927. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  21928. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21929. var view = res.Data as PageDataViewBase;
  21930. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  21931. }
  21932. /// <summary>
  21933. /// 酒店询价
  21934. /// info
  21935. /// </summary>
  21936. /// <param name="_dto"></param>
  21937. /// <returns></returns>
  21938. [HttpPost]
  21939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21940. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  21941. {
  21942. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  21943. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21944. return Ok(JsonView(true, res.Msg, res.Data));
  21945. }
  21946. /// <summary>
  21947. /// 酒店询价
  21948. /// Add Or Edit
  21949. /// </summary>
  21950. /// <param name="_dto"></param>
  21951. /// <returns></returns>
  21952. [HttpPost]
  21953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21954. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  21955. {
  21956. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  21957. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21958. return Ok(JsonView(true, res.Msg, res.Data));
  21959. }
  21960. /// <summary>
  21961. /// 酒店询价
  21962. /// Del
  21963. /// </summary>
  21964. /// <param name="_dto"></param>
  21965. /// <returns></returns>
  21966. [HttpPost]
  21967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21968. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  21969. {
  21970. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  21971. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  21972. return Ok(JsonView(true, res.Msg, res.Data));
  21973. }
  21974. #endregion
  21975. #region 下载匹配op行程单
  21976. /// <summary>
  21977. /// 匹配op行程单
  21978. /// Init
  21979. /// </summary>
  21980. /// <param name="dto">团组列表请求dto</param>
  21981. /// <returns></returns>
  21982. [HttpPost]
  21983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21984. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  21985. {
  21986. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  21987. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  21988. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  21989. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  21990. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  21991. .Where(it => it.IsDel == 0)
  21992. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  21993. .OrderByDescending(it => it.VisitStartDate)
  21994. .ToList();
  21995. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  21996. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  21997. var diids = groupInfos.Select(it => it.Id).ToList();
  21998. List<string> countrys = new List<string>();
  21999. foreach (var item in country)
  22000. {
  22001. var data = _groupRepository.FormartTeamName(item);
  22002. var dataArray = _groupRepository.GroupSplitCountry(data);
  22003. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  22004. }
  22005. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  22006. List<string> areaArray = new List<string>(); //GetGroupCityLine
  22007. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  22008. foreach (var item in areaItem)
  22009. {
  22010. string areaStr = item.Value;
  22011. if (!string.IsNullOrEmpty(areaStr))
  22012. {
  22013. string[] str1 = areaStr.Split("-");
  22014. if (str1.Length > 0)
  22015. {
  22016. areaArray.AddRange(str1);
  22017. }
  22018. }
  22019. }
  22020. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  22021. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  22022. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  22023. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  22024. .ToList();
  22025. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  22026. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  22027. .Where(it => countriesIds.Contains(it.Id))
  22028. .Select(it => new { it.Id, Name = it.Name_CN })
  22029. .ToList();
  22030. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  22031. .Select(it => it.TeamName).ToList();
  22032. stopwatch.Stop();
  22033. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  22034. }
  22035. ///// <summary>
  22036. ///// 匹配op行程单
  22037. ///// Init 查询区域数据
  22038. ///// </summary>
  22039. ///// <param name="dto">团组列表请求dto</param>
  22040. ///// <returns></returns>
  22041. //[HttpPost]
  22042. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22043. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  22044. //{
  22045. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  22046. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  22047. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  22048. // if (string.IsNullOrEmpty(countriesDataStr))
  22049. // {
  22050. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  22051. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  22052. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  22053. // }
  22054. // else
  22055. // {
  22056. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  22057. // }
  22058. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  22059. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  22060. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  22061. // List<dynamic> childList = new List<dynamic>();
  22062. // int parentId = dto.CountriesId;
  22063. // if (provinceData.Count > 1)
  22064. // {
  22065. // foreach (var item1 in provinceData)
  22066. // {
  22067. // List<dynamic> childList1 = new List<dynamic>();
  22068. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  22069. // foreach (var item2 in citiesData1)
  22070. // {
  22071. // List<dynamic> childList2 = new List<dynamic>();
  22072. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  22073. // foreach (var item3 in countiesData1)
  22074. // {
  22075. // childList2.Add(new
  22076. // {
  22077. // id = item3.Id,
  22078. // parentId = item2.Id,
  22079. // level = "district",
  22080. // name = item3.Name_CN,
  22081. // });
  22082. // }
  22083. // childList1.Add(new
  22084. // {
  22085. // id = item2.Id,
  22086. // parentId = item1.Id,
  22087. // level = "city",
  22088. // name = item2.Name_CN,
  22089. // childList = childList2
  22090. // });
  22091. // }
  22092. // childList.Add(new
  22093. // {
  22094. // id = item1.Id,
  22095. // parentId = parentId,
  22096. // level = "province",
  22097. // name = item1.Name_CN,
  22098. // childList = childList1
  22099. // });
  22100. // }
  22101. // //城市
  22102. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  22103. // foreach (var item2 in citiesData2)
  22104. // {
  22105. // List<dynamic> childList22 = new List<dynamic>();
  22106. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  22107. // foreach (var item3 in countiesData1)
  22108. // {
  22109. // childList22.Add(new
  22110. // {
  22111. // id = item3.Id,
  22112. // parentId = item2.Id,
  22113. // level = "district",
  22114. // name = item3.Name_CN,
  22115. // });
  22116. // }
  22117. // childList.Add(new
  22118. // {
  22119. // id = item2.Id,
  22120. // parentId = parentId,
  22121. // level = "city",
  22122. // name = item2.Name_CN,
  22123. // childList = childList22
  22124. // });
  22125. // }
  22126. // }
  22127. // else
  22128. // {
  22129. // foreach (var item2 in citiesData)
  22130. // {
  22131. // string cname = item2.Name_CN;
  22132. // List<dynamic> childList1 = new List<dynamic>();
  22133. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  22134. // foreach (var item3 in countiesData1)
  22135. // {
  22136. // childList1.Add(new
  22137. // {
  22138. // Id = item3.Id,
  22139. // parentId = item2.Id,
  22140. // level = "district",
  22141. // name = item3.Name_CN
  22142. // });
  22143. // }
  22144. // childList.Add(new
  22145. // {
  22146. // id = item2.Id,
  22147. // parentId = parentId,
  22148. // level = "city",
  22149. // name = item2.Name_CN,
  22150. // childList = childList1
  22151. // });
  22152. // }
  22153. // }
  22154. // stopwatch.Stop();
  22155. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  22156. //}
  22157. /// <summary>
  22158. /// 匹配op行程单
  22159. /// 接团信息列表 Page
  22160. /// </summary>
  22161. /// <param name="dto">团组列表请求dto</param>
  22162. /// <returns></returns>
  22163. [HttpPost]
  22164. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22165. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  22166. {
  22167. var swatch = new Stopwatch();
  22168. swatch.Start();
  22169. #region 参数验证
  22170. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  22171. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  22172. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22173. #region 页面操作权限验证
  22174. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  22175. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  22176. #endregion
  22177. #endregion
  22178. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  22179. {
  22180. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  22181. //string sqlWhere = "";
  22182. if (!string.IsNullOrEmpty(dto.Country))
  22183. {
  22184. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  22185. }
  22186. if (!string.IsNullOrEmpty(dto.Area))
  22187. {
  22188. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  22189. }
  22190. if (!string.IsNullOrEmpty(dto.TeamName))
  22191. {
  22192. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  22193. }
  22194. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  22195. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  22196. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  22197. swatch.Stop();
  22198. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  22199. }
  22200. else
  22201. {
  22202. return Ok(JsonView(false, "查询失败"));
  22203. }
  22204. }
  22205. /// <summary>
  22206. /// 匹配op行程单
  22207. /// 行程单下载
  22208. /// </summary>
  22209. /// <param name="dto">团组列表请求dto</param>
  22210. /// <returns></returns>
  22211. [HttpPost]
  22212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22213. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  22214. {
  22215. #region 参数验证
  22216. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  22217. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  22218. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22219. #region 页面操作权限验证
  22220. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  22221. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  22222. #endregion
  22223. #endregion
  22224. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  22225. {
  22226. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  22227. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  22228. }
  22229. else
  22230. {
  22231. return Ok(JsonView(false, "下载失败!"));
  22232. }
  22233. }
  22234. #endregion
  22235. #region 国家信息 数据 注释
  22236. //[HttpPost]
  22237. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  22238. //{
  22239. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  22240. // foreach (var item in dto)
  22241. // {
  22242. // infos.Add(new Grp_GroupsTaskAssignment()
  22243. // {
  22244. // DIId = item,
  22245. // CTId = 82,
  22246. // UId = 248,
  22247. // IsEnable = 1,
  22248. // CreateUserId = 233,
  22249. // CreateTime = DateTime.Now,
  22250. // IsDel = 0
  22251. // });
  22252. // infos.Add(new Grp_GroupsTaskAssignment()
  22253. // {
  22254. // DIId = item,
  22255. // CTId = 82,
  22256. // UId = 286,
  22257. // IsEnable = 1,
  22258. // CreateUserId = 233,
  22259. // CreateTime = DateTime.Now,
  22260. // IsDel = 0
  22261. // });
  22262. // }
  22263. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  22264. // return Ok("操作成功");
  22265. //}
  22266. //public class paramJsonDto
  22267. //{
  22268. // public List<CountriesInfo> str { get; set; }
  22269. //}
  22270. //[HttpPost]
  22271. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  22272. //{
  22273. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  22274. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  22275. // List<Sys_Cities> cities = new List<Sys_Cities>();
  22276. // List<Sys_Cities> districts = new List<Sys_Cities>();
  22277. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22278. // _sqlSugar.BeginTran();
  22279. // int countitiesIndex = 0;
  22280. // foreach (var item in dto.str)
  22281. // {
  22282. // dynamic data = item.c;
  22283. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  22284. // if (data != null)
  22285. // {
  22286. // countitiesIndex++;
  22287. // foreach (var item1 in data)
  22288. // {
  22289. // string cnname = item1.cn;
  22290. // string enname = item1.en;
  22291. // Sys_Cities provinceInfo = new Sys_Cities()
  22292. // {
  22293. // CountriesId = countriesId,
  22294. // Name_CN = cnname,
  22295. // Name_EN = enname,
  22296. // ParentId = 0,
  22297. // IsCapital = 1,
  22298. // CreateUserId = 208,
  22299. // CreateTime = DateTime.Now,
  22300. // IsDel = 0
  22301. // };
  22302. // if (item1.lv == "province") //省份
  22303. // {
  22304. // provinceInfo.Level = 1;
  22305. // int provinceId = 0;
  22306. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  22307. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  22308. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22309. // var data1 = item1.c;
  22310. // foreach (var item2 in data1)
  22311. // {
  22312. // if (item2.lv == "city")
  22313. // {
  22314. // string citycnname = item2.cn;
  22315. // string cityenname = item2.en;
  22316. // Sys_Cities cityInfo = new Sys_Cities()
  22317. // {
  22318. // CountriesId = countriesId,
  22319. // ParentId = provinceId,
  22320. // Level = 2,
  22321. // Name_CN = citycnname,
  22322. // Name_EN = cityenname,
  22323. // IsCapital = 1,
  22324. // CreateUserId = 208,
  22325. // CreateTime = DateTime.Now,
  22326. // IsDel = 0
  22327. // };
  22328. // if (item2.c != null)
  22329. // {
  22330. // int cityId = 0;
  22331. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  22332. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22333. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  22334. // foreach (var item3 in item2.c)
  22335. // {
  22336. // if (item3.lv == "district")
  22337. // {
  22338. // var districtInfo = new Sys_Cities()
  22339. // {
  22340. // CountriesId = countriesId,
  22341. // Name_CN = item3.cn,
  22342. // Name_EN = item3.en,
  22343. // Level = 3,
  22344. // ParentId = cityId,
  22345. // IsCapital = 1,
  22346. // CreateUserId = 208,
  22347. // CreateTime = DateTime.Now,
  22348. // IsDel = 0
  22349. // };
  22350. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22351. // //{
  22352. // districts.Add(districtInfo);
  22353. // //}
  22354. // }
  22355. // }
  22356. // }
  22357. // else
  22358. // {
  22359. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  22360. // //{
  22361. // cities.Add(cityInfo);
  22362. // //}
  22363. // }
  22364. // }
  22365. // }
  22366. // }
  22367. // else if (item1.lv == "city")//城市
  22368. // {
  22369. // provinceInfo.Level = 2;
  22370. // if (item1.c != null)
  22371. // {
  22372. // int cityId = 0;
  22373. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  22374. // if (citiesInfo != null) cityId = citiesInfo.Id;
  22375. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  22376. // foreach (var item3 in item1.c)
  22377. // {
  22378. // if (item3.lv == "district")
  22379. // {
  22380. // var districtInfo = new Sys_Cities()
  22381. // {
  22382. // CountriesId = countriesId,
  22383. // Name_CN = item3.cn,
  22384. // Name_EN = item3.en,
  22385. // Level = 3,
  22386. // ParentId = cityId,
  22387. // IsCapital = 1,
  22388. // CreateUserId = 208,
  22389. // CreateTime = DateTime.Now,
  22390. // IsDel = 0
  22391. // };
  22392. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  22393. // //{
  22394. // districts.Add(districtInfo);
  22395. // //}
  22396. // }
  22397. // }
  22398. // }
  22399. // else
  22400. // {
  22401. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  22402. // //{
  22403. // cities.Add(provinceInfo);
  22404. // //}
  22405. // }
  22406. // }
  22407. // }
  22408. // }
  22409. // }
  22410. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  22411. // cities = cities.Distinct().ToList();
  22412. // districts = districts.Distinct().ToList();
  22413. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  22414. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  22415. // cities.AddRange(districts);
  22416. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  22417. // //_sqlSugar.RollbackTran();
  22418. // _sqlSugar.CommitTran();
  22419. // return Ok(JsonView(false, "操作成功!"));
  22420. //}
  22421. //[HttpPost]
  22422. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  22423. //{
  22424. // List<CountitiesInfo> infos = dto.MyProperty;
  22425. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  22426. // _sqlSugar.BeginTran();
  22427. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  22428. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  22429. // foreach (var item in infos)
  22430. // {
  22431. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  22432. // if (countryInfo != null)
  22433. // {
  22434. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  22435. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  22436. // if (cityInfo1 != null)
  22437. // {
  22438. // cityInfo1.IsCapital = 0;
  22439. // cityInfos.Add(cityInfo1);
  22440. // }
  22441. // }
  22442. // }
  22443. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  22444. // .UpdateColumns(it => it.IsCapital)
  22445. // .WhereColumns(it => it.Id)
  22446. // .ExecuteCommand();
  22447. // //_sqlSugar.RollbackTran();
  22448. // _sqlSugar.CommitTran();
  22449. // return Ok(JsonView(false, "操作成功!"));
  22450. //}
  22451. //public class CounrtiesDto
  22452. //{
  22453. // public List<CountitiesInfo> MyProperty { get; set; }
  22454. //}
  22455. //public class CountitiesInfo
  22456. //{
  22457. // /// <summary>
  22458. // /// 圣约翰
  22459. // /// </summary>
  22460. // public string capital_name_chinese { get; set; }
  22461. // /// <summary>
  22462. // ///
  22463. // /// </summary>
  22464. // public string capital_name { get; set; }
  22465. // /// <summary>
  22466. // ///
  22467. // /// </summary>
  22468. // public string country_type { get; set; }
  22469. // /// <summary>
  22470. // /// 安提瓜和巴布达
  22471. // /// </summary>
  22472. // public string country_name_chinese { get; set; }
  22473. // /// <summary>
  22474. // /// 安提瓜和巴布达
  22475. // /// </summary>
  22476. // public string country_name_chinese_short { get; set; }
  22477. // /// <summary>
  22478. // /// 安提瓜和巴布达
  22479. // /// </summary>
  22480. // public string country_name_chinese_UN { get; set; }
  22481. // /// <summary>
  22482. // ///
  22483. // /// </summary>
  22484. // public string country_name_english_abbreviation { get; set; }
  22485. // /// <summary>
  22486. // ///
  22487. // /// </summary>
  22488. // public string country_name_english_formal { get; set; }
  22489. // /// <summary>
  22490. // ///
  22491. // /// </summary>
  22492. // public string country_name_english_UN { get; set; }
  22493. // /// <summary>
  22494. // ///
  22495. // /// </summary>
  22496. // public string continent_name { get; set; }
  22497. // /// <summary>
  22498. // ///
  22499. // /// </summary>
  22500. // public string subregion_name { get; set; }
  22501. // /// <summary>
  22502. // ///
  22503. // /// </summary>
  22504. // public string country_code2 { get; set; }
  22505. // /// <summary>
  22506. // ///
  22507. // /// </summary>
  22508. // public string country_code3 { get; set; }
  22509. // /// <summary>
  22510. // ///
  22511. // /// </summary>
  22512. // public string phone_code { get; set; }
  22513. //}
  22514. //public class CountriesInfo : BasicInfo
  22515. //{
  22516. // public List<CitiesInfo> c { get; set; }
  22517. //}
  22518. //public class CitiesInfo : BasicInfo
  22519. //{
  22520. // public List<AreaInfo> c { get; set; }
  22521. //}
  22522. //public class AreaInfo : BasicInfo
  22523. //{
  22524. // public List<AreaInfo> c { get; set; }
  22525. //}
  22526. //public class BasicInfo
  22527. //{
  22528. // public string code { get; set; }
  22529. // public string cn { get; set; }
  22530. // public string lv { get; set; }
  22531. // public string en { get; set; }
  22532. //}
  22533. #endregion
  22534. #region 查看邀请方
  22535. /// <summary>
  22536. /// 查看邀请方
  22537. /// 邀请方信息 Init
  22538. /// </summary>
  22539. /// <param name="dto"></param>
  22540. /// <returns></returns>
  22541. [HttpPost]
  22542. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22543. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  22544. {
  22545. string sqlWhere = string.Empty;
  22546. if (!string.IsNullOrEmpty(dto.Search))
  22547. {
  22548. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  22549. }
  22550. string sql = string.Format($@"Select
  22551. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  22552. Id,
  22553. UnitName
  22554. From Res_InvitationOfficialActivityData
  22555. Where IsDel = 0
  22556. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  22557. RefAsync<int> total = 0;
  22558. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22559. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  22560. }
  22561. /// <summary>
  22562. /// 查看邀请方
  22563. /// 国家信息 Init
  22564. /// </summary>
  22565. /// <param name="dto"></param>
  22566. /// <returns></returns>
  22567. [HttpPost]
  22568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22569. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  22570. {
  22571. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  22572. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  22573. var diids = groupInfos.Select(it => it.Id).ToList();
  22574. List<string> countrys = new List<string>();
  22575. foreach (var item in country)
  22576. {
  22577. var data = _groupRepository.FormartTeamName(item);
  22578. var dataArray = _groupRepository.GroupSplitCountry(data);
  22579. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  22580. }
  22581. countrys = countrys.Distinct().ToList();
  22582. for (int i = 0; i < countrys.Count; i++)
  22583. {
  22584. string item = countrys[i];
  22585. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  22586. {
  22587. countrys.Remove(item);
  22588. i--;
  22589. }
  22590. }
  22591. RefAsync<int> total = 0;
  22592. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  22593. .Where(it => countrys.Contains(it.Name_CN))
  22594. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22595. .Select(it => new { id = it.Id, name = it.Name_CN })
  22596. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22597. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22598. }
  22599. /// <summary>
  22600. /// 查看邀请方
  22601. /// 城市信息 Init
  22602. /// </summary>
  22603. /// <param name="dto"></param>
  22604. /// <returns></returns>
  22605. [HttpPost]
  22606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22607. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  22608. {
  22609. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  22610. RefAsync<int> total = 0;
  22611. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  22612. .Where(it => it.CountriesId == dto.CountiesId)
  22613. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  22614. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  22615. .Select(it => new { id = it.Id, name = it.Name_CN })
  22616. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22617. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  22618. }
  22619. /// <summary>
  22620. /// 查看邀请方
  22621. /// 团组名称 Init
  22622. /// </summary>
  22623. /// <param name="dto"></param>
  22624. /// <returns></returns>
  22625. [HttpPost]
  22626. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22627. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  22628. {
  22629. var watch = new Stopwatch();
  22630. watch.Start();
  22631. RefAsync<int> total = 0;
  22632. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  22633. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  22634. .Where((oa, di) => oa.IsDel == 0)
  22635. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  22636. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  22637. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  22638. .Distinct()
  22639. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22640. watch.Stop();
  22641. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  22642. }
  22643. /// <summary>
  22644. /// 查看邀请方
  22645. /// 团组 & 邀请方信息
  22646. /// </summary>
  22647. /// <param name="dto"></param>
  22648. /// <returns></returns>
  22649. [HttpPost]
  22650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22651. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  22652. {
  22653. var watch = new Stopwatch();
  22654. watch.Start();
  22655. RefAsync<int> total = 0;
  22656. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  22657. .AS("Grp_DelegationInfo")
  22658. .Includes(x => x.InvitingInfos)
  22659. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  22660. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  22661. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  22662. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  22663. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  22664. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  22665. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  22666. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  22667. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  22668. infos.ForEach(x =>
  22669. {
  22670. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  22671. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  22672. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  22673. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  22674. });
  22675. watch.Stop();
  22676. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  22677. }
  22678. #endregion
  22679. #region 报批行程
  22680. /// <summary>
  22681. /// 报批行程初始化
  22682. /// </summary>
  22683. /// <param name="dto"></param>
  22684. /// <returns></returns>
  22685. [HttpPost]
  22686. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  22687. {
  22688. const int chiNumber = 5;
  22689. var jw = JsonView(false);
  22690. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  22691. var group = groupList.First();
  22692. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  22693. group = groupList.First(x => x.Id == diid);
  22694. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22695. .Where(x => x.DiId == diid && x.IsDel == 0)
  22696. .ToArray();
  22697. var count = 1;
  22698. foreach (var item in blackCodeList)
  22699. {
  22700. if (string.IsNullOrWhiteSpace(item.Title))
  22701. {
  22702. item.Title = "未设置名称数据" + count;
  22703. }
  22704. count++;
  22705. }
  22706. ;
  22707. if (group == null)
  22708. {
  22709. jw.Msg = "暂无团组!";
  22710. return Ok(jw);
  22711. }
  22712. var data = new
  22713. {
  22714. groupList = groupList.Select(x => new
  22715. {
  22716. x.TeamName,
  22717. x.Id
  22718. }),
  22719. content = new ArrayList(),
  22720. groupInfo = new
  22721. {
  22722. group.VisitDays,
  22723. group.TourCode,
  22724. group.VisitPNumber,
  22725. group.TeamName,
  22726. group.Id,
  22727. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  22728. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  22729. group.ClientUnit
  22730. },
  22731. blackCodeList = blackCodeList.Select(x => new
  22732. {
  22733. x.Title,
  22734. x.Id
  22735. }),
  22736. FileTempList = new ArrayList()
  22737. {
  22738. new { Index = 1,FileName = "旧模板" },
  22739. new { Index = 2,FileName = "省外办" },
  22740. new { Index = 3,FileName = "市外办" },
  22741. }
  22742. };
  22743. var resultArr = new ArrayList();
  22744. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  22745. #region 默认不生成行程
  22746. //if (content.Count == 0)
  22747. //{
  22748. // var stay = "-";
  22749. // var cityPath = "-";
  22750. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  22751. // .Where(x => x.DiId == diid && x.IsDel == 0)
  22752. // .ToList();
  22753. // //添加城市路径以及住宿地
  22754. // //黑屏代码数据
  22755. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  22756. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  22757. // {
  22758. // jw = JsonView(true, "黑屏代码有误!", data);
  22759. // return Ok(jw);
  22760. // }
  22761. // data = data with
  22762. // {
  22763. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  22764. // {
  22765. // x.Title,
  22766. // x.Id,
  22767. // }).ToArray())
  22768. // };
  22769. // foreach (DataRow row in dtBlack.Rows)
  22770. // {
  22771. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  22772. // {
  22773. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  22774. // return Ok(jw);
  22775. // }
  22776. // }
  22777. // //黑屏代码获取时间区间
  22778. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  22779. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  22780. // _sqlSugar.BeginTran();
  22781. // for (int i = 0; i < timeArr.Count; i++)
  22782. // {
  22783. // stay = "-";
  22784. // cityPath = "-";
  22785. // DateTime NewData = DateTime.Parse(timeArr[i]);
  22786. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  22787. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  22788. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  22789. // if (tbSelect.Length > 0)
  22790. // {
  22791. // List<string> threeCodeStr = new List<string>();
  22792. // foreach (var item in tbSelect)
  22793. // {
  22794. // var threeCode = item["Three"].ToString() ?? "";
  22795. // if (threeCode.Length == 6)
  22796. // {
  22797. // var start = threeCode.Substring(0, 3);
  22798. // var end = threeCode.Substring(3, 3);
  22799. // if (threeCodeStr.Count == 0)
  22800. // {
  22801. // threeCodeStr.Add(start);
  22802. // threeCodeStr.Add(end);
  22803. // }
  22804. // else
  22805. // {
  22806. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  22807. // {
  22808. // threeCodeStr.Add(end);
  22809. // }
  22810. // else
  22811. // {
  22812. // threeCodeStr.Add(start);
  22813. // threeCodeStr.Add(end);
  22814. // }
  22815. // }
  22816. // }
  22817. // }
  22818. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  22819. // var last = threeCodeStr.Last();
  22820. // foreach (var item in threeCodeStr)
  22821. // {
  22822. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  22823. // if (item.Equals(last))
  22824. // {
  22825. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  22826. // }
  22827. // }
  22828. // cityPath = cityPath.Trim('-');
  22829. // }
  22830. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  22831. // appro.Diid = diid ?? -1;
  22832. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  22833. // appro.Id = thisId;
  22834. // appro.CreateUserId = dto.UserId;
  22835. // appro.CreateTime = DateTime.Now;
  22836. // content.Add(appro);
  22837. // }
  22838. // _sqlSugar.CommitTran();
  22839. //}
  22840. #endregion
  22841. foreach (var x in content)
  22842. {
  22843. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  22844. if (chiList.Count < chiNumber)
  22845. {
  22846. for (int i = chiList.Count; i < chiNumber; i++)
  22847. {
  22848. chiList.Add(new Grp_ApprovalTravelDetails());
  22849. }
  22850. }
  22851. resultArr.Add(new
  22852. {
  22853. x.Id,
  22854. x.Date,
  22855. x.Diid,
  22856. chiList = chiList.Select(x1 => new
  22857. {
  22858. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  22859. x1.Details,
  22860. x1.ParentId,
  22861. x1.Id
  22862. })
  22863. });
  22864. }
  22865. data = data with
  22866. {
  22867. content = resultArr,
  22868. };
  22869. jw = JsonView(true, "获取成功!", data);
  22870. return Ok(jw);
  22871. }
  22872. /// <summary>
  22873. /// 报批行程删除
  22874. /// </summary>
  22875. /// <param name="dto"></param>
  22876. /// <returns></returns>
  22877. [HttpPost]
  22878. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  22879. {
  22880. var jw = JsonView(false);
  22881. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  22882. if (group == null)
  22883. {
  22884. jw.Msg = "团组参数有误!";
  22885. return Ok(jw);
  22886. }
  22887. try
  22888. {
  22889. _sqlSugar.BeginTran();
  22890. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  22891. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  22892. {
  22893. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22894. DeleteUserId = dto.uesrId,
  22895. IsDel = 1
  22896. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  22897. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  22898. {
  22899. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22900. DeleteUserId = dto.uesrId,
  22901. IsDel = 1
  22902. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  22903. _sqlSugar.CommitTran();
  22904. jw = JsonView(true, "删除成功");
  22905. }
  22906. catch (Exception ex)
  22907. {
  22908. jw = JsonView(false, ex.Message);
  22909. }
  22910. return Ok(jw);
  22911. }
  22912. /// <summary>
  22913. /// 报批行程保存
  22914. /// </summary>
  22915. /// <param name="dto"></param>
  22916. /// <returns></returns>
  22917. [HttpPost]
  22918. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  22919. {
  22920. var jw = JsonView(false);
  22921. var Find = dto.Arr.Find(x => x.id == 0);
  22922. if (Find != null)
  22923. {
  22924. jw.Msg = "生成的ID为0!";
  22925. return Ok(jw);
  22926. }
  22927. foreach (var item in dto.Arr)
  22928. {
  22929. foreach (var chi in item.chiList)
  22930. {
  22931. if (chi.parentId == 0)
  22932. {
  22933. chi.parentId = item.id;
  22934. }
  22935. }
  22936. }
  22937. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  22938. _sqlSugar.BeginTran();
  22939. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  22940. {
  22941. var parentIds = dto.Arr.Select(x => x.id).ToList();
  22942. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  22943. {
  22944. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  22945. DeleteUserId = dto.UserId,
  22946. IsDel = 1
  22947. }).ExecuteCommand();
  22948. }
  22949. try
  22950. {
  22951. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  22952. {
  22953. CreateTime = DateTime.Now,
  22954. CreateUserId = dto.UserId,
  22955. Details = x.details,
  22956. ParentId = x.parentId,
  22957. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22958. Remark = "",
  22959. IsDel = 0
  22960. }).ToList()).ExecuteCommand();
  22961. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  22962. {
  22963. Id = x.id,
  22964. Details = x.details,
  22965. ParentId = x.parentId,
  22966. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  22967. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  22968. {
  22969. Details = x.Details,
  22970. ParentId = x.ParentId,
  22971. Time = x.Time
  22972. }).ExecuteCommand();
  22973. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  22974. {
  22975. Id = x.id,
  22976. Date = x.date,
  22977. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  22978. {
  22979. Date = x.Date
  22980. }).ExecuteCommand();
  22981. _sqlSugar.CommitTran();
  22982. jw = JsonView(true, "保存成功!");
  22983. }
  22984. catch (Exception ex)
  22985. {
  22986. _sqlSugar.RollbackTran();
  22987. jw = JsonView(false, "保存失败!" + ex.Message);
  22988. }
  22989. return Ok(jw);
  22990. }
  22991. /// <summary>
  22992. /// 报批行程生成
  22993. /// </summary>
  22994. /// <param name="dto"></param>
  22995. /// <returns></returns>
  22996. [HttpPost]
  22997. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  22998. {
  22999. var jw = JsonView(false);
  23000. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  23001. if (group == null)
  23002. {
  23003. jw.Msg = "暂无该团组!";
  23004. return Ok(jw);
  23005. }
  23006. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  23007. //黑屏代码数据
  23008. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  23009. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  23010. {
  23011. jw.Msg = "黑屏代码有误!";
  23012. return Ok(jw);
  23013. }
  23014. foreach (DataRow row in dtBlack.Rows)
  23015. {
  23016. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  23017. {
  23018. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  23019. return Ok(jw);
  23020. }
  23021. }
  23022. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  23023. var resultArr = new ArrayList();
  23024. //if (officialActivitiesArr.Count == 0)
  23025. //{
  23026. // jw.Msg = "暂无公务出访信息!";
  23027. // return Ok(jw);
  23028. //}
  23029. try
  23030. {
  23031. _sqlSugar.BeginTran();
  23032. DeleteApprovalJourney(new
  23033. Domain.Dtos.Groups.DeleteApprovalJourney
  23034. {
  23035. Diid = dto.Diid,
  23036. uesrId = dto.Userid
  23037. });
  23038. var stay = "-";
  23039. var cityPath = "-";
  23040. var arriveCountry = string.Empty;
  23041. //添加城市路径以及住宿地
  23042. //黑屏代码获取时间区间
  23043. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  23044. var empty = "【未收入该三字码!请机票同事录入】";
  23045. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  23046. #region 配置公务活动时间
  23047. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  23048. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  23049. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  23050. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  23051. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  23052. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  23053. {
  23054. 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" }),
  23055. 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"}),
  23056. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  23057. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  23058. };
  23059. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  23060. {
  23061. 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" }),
  23062. 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"}),
  23063. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  23064. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  23065. };
  23066. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  23067. {
  23068. 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" }),
  23069. 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"}),
  23070. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  23071. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  23072. };
  23073. #endregion
  23074. var nextDayNum = 0;
  23075. for (int i = 0; i < timeArr.Count; i++)
  23076. {
  23077. stay = "-";
  23078. cityPath = "-";
  23079. var chiarr = new List<Grp_ApprovalTravelDetails>();
  23080. DateTime NewData = DateTime.Parse(timeArr[i]);
  23081. //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();
  23082. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  23083. if (nextDayNum > 0)
  23084. {
  23085. nextDayNum--;
  23086. }
  23087. if (tbSelect.Length > 0)
  23088. {
  23089. List<string> threeCodeStr = new List<string>();
  23090. bool isTrade = false;
  23091. string trip = string.Empty;
  23092. foreach (var item in tbSelect)
  23093. {
  23094. if (nextDayNum == 0)
  23095. {
  23096. nextDayNum = Convert.ToInt32(item["Sign"]);
  23097. }
  23098. var airStartTime = item["StartTime"].ToString() ?? "0000";
  23099. var airEndTime = item["EndTime"].ToString() ?? "0000";
  23100. var takeOffTime = DateTime.Parse(timeArr[i]);
  23101. var fallToTime = DateTime.Parse(timeArr[i]);
  23102. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  23103. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  23104. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  23105. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  23106. if (nextDayNum > 0)
  23107. {
  23108. fallToTime = fallToTime.AddDays(nextDayNum);
  23109. }
  23110. trip = string.Empty;
  23111. var start = string.Empty;
  23112. var end = string.Empty;
  23113. var threeCode = item["Three"].ToString() ?? "";
  23114. if (threeCode.Length == 6)
  23115. {
  23116. start = threeCode.Substring(0, 3);
  23117. end = threeCode.Substring(3, 3);
  23118. if (threeCodeStr.Count == 0)
  23119. {
  23120. threeCodeStr.Add(start);
  23121. threeCodeStr.Add(end);
  23122. }
  23123. else
  23124. {
  23125. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  23126. {
  23127. threeCodeStr.Add(end);
  23128. }
  23129. else
  23130. {
  23131. threeCodeStr.Add(start);
  23132. threeCodeStr.Add(end);
  23133. }
  23134. }
  23135. }
  23136. //处理机票信息
  23137. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  23138. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  23139. if (start_Object == null)
  23140. {
  23141. start_Object = new Res_ThreeCode()
  23142. {
  23143. AirPort = empty,
  23144. AirPort_En = empty,
  23145. City = empty,
  23146. Country = empty,
  23147. Four = empty,
  23148. Three = empty,
  23149. };
  23150. }
  23151. if (end_Object == null)
  23152. {
  23153. end_Object = new Res_ThreeCode()
  23154. {
  23155. AirPort = empty,
  23156. AirPort_En = empty,
  23157. City = empty,
  23158. Country = empty,
  23159. Four = empty,
  23160. Three = empty,
  23161. };
  23162. }
  23163. //机型判断
  23164. string airModel = item["AirModel"].ToString();
  23165. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  23166. string flightTime = item["FlightTime"].ToString();
  23167. flightTime = ParseBlackTime(flightTime);
  23168. //航班号
  23169. string flightcode = item["Fliagtcode"].ToString();
  23170. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  23171. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  23172. if (aircompany == null)
  23173. {
  23174. aircompany = new Res_AirCompany
  23175. {
  23176. CnName = hsEmpty,
  23177. EnName = hsEmpty,
  23178. ShortCode = hsEmpty,
  23179. };
  23180. }
  23181. //航班前公务安排
  23182. if (tbSelect.First().Equals(item) && i != 0)
  23183. {
  23184. foreach (var takeoff in takeoffTimes)
  23185. {
  23186. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  23187. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  23188. {
  23189. foreach (var addTime in takeoff.Item2)
  23190. {
  23191. chiarr.Add(new Grp_ApprovalTravelDetails
  23192. {
  23193. Time = addTime,
  23194. CreateTime = DateTime.Now,
  23195. CreateUserId = dto.Userid,
  23196. ParentId = 0,
  23197. Details = "公务活动"
  23198. });
  23199. }
  23200. break;
  23201. }
  23202. }
  23203. }
  23204. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  23205. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  23206. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  23207. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  23208. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  23209. if (isTrade)
  23210. {
  23211. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  23212. trip += "(转机不出机场)。";
  23213. }
  23214. //else
  23215. //{
  23216. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  23217. //}
  23218. chiarr.Add(new Grp_ApprovalTravelDetails
  23219. {
  23220. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  23221. CreateTime = DateTime.Now,
  23222. CreateUserId = dto.Userid,
  23223. ParentId = 0,
  23224. Details = trip
  23225. });
  23226. //最后一条到达的时间安排公务
  23227. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  23228. {
  23229. bool isCheckCountry = false;
  23230. if (end_Object.Country != arriveCountry)
  23231. {
  23232. arriveCountry = end_Object.Country;
  23233. isCheckCountry = true;
  23234. }
  23235. if (nextDayNum == 0)
  23236. {
  23237. //需要入境的情况
  23238. if (isCheckCountry)
  23239. {
  23240. foreach (var fallTime in fallTimesCheckCountry)
  23241. {
  23242. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23243. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23244. {
  23245. foreach (var addTime in fallTime.Item2)
  23246. {
  23247. chiarr.Add(new Grp_ApprovalTravelDetails
  23248. {
  23249. Time = addTime,
  23250. CreateTime = DateTime.Now,
  23251. CreateUserId = dto.Userid,
  23252. ParentId = 0,
  23253. Details = "公务活动"
  23254. });
  23255. }
  23256. break;
  23257. }
  23258. }
  23259. }
  23260. else
  23261. {
  23262. foreach (var fallTime in fallTimesNotCheckCountry)
  23263. {
  23264. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  23265. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  23266. {
  23267. foreach (var addTime in fallTime.Item2)
  23268. {
  23269. chiarr.Add(new Grp_ApprovalTravelDetails
  23270. {
  23271. Time = addTime,
  23272. CreateTime = DateTime.Now,
  23273. CreateUserId = dto.Userid,
  23274. ParentId = 0,
  23275. Details = "公务活动"
  23276. });
  23277. }
  23278. break;
  23279. }
  23280. }
  23281. }
  23282. }
  23283. }
  23284. }
  23285. //添加乘车语句
  23286. //chiarr.Add(new Grp_ApprovalTravelDetails
  23287. //{
  23288. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  23289. // CreateTime = DateTime.Now,
  23290. // CreateUserId = dto.Userid,
  23291. // ParentId = 0,
  23292. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  23293. //});
  23294. //if (i != timeArr.Count - 1)
  23295. //{
  23296. // fallToTime = fallToTime.AddHours(2.5);
  23297. // foreach (var item in Times)
  23298. // {
  23299. // //排列公务时间
  23300. // if (fallToTime.Hour < item.Item1)
  23301. // {
  23302. // chiarr.Add(new Grp_ApprovalTravelDetails
  23303. // {
  23304. // Time = $"{item.Item2} - {item.Item3}",
  23305. // CreateTime = DateTime.Now,
  23306. // CreateUserId = dto.Userid,
  23307. // ParentId = 0,
  23308. // Details = "公务活动"
  23309. // });
  23310. // }
  23311. // }
  23312. //}
  23313. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  23314. var last = threeCodeStr.Last();
  23315. foreach (var item in threeCodeStr)
  23316. {
  23317. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  23318. if (item.Equals(last))
  23319. {
  23320. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  23321. }
  23322. }
  23323. cityPath = cityPath.Trim('-');
  23324. }
  23325. else
  23326. {
  23327. foreach (var item in Times)
  23328. {
  23329. chiarr.Add(new Grp_ApprovalTravelDetails
  23330. {
  23331. Time = $"{item.Item2} - {item.Item3}",
  23332. CreateTime = DateTime.Now,
  23333. CreateUserId = dto.Userid,
  23334. ParentId = 0,
  23335. Details = "公务活动"
  23336. });
  23337. }
  23338. }
  23339. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  23340. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  23341. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  23342. appro.Diid = dto.Diid;
  23343. appro.CreateUserId = dto.Userid;
  23344. appro.CreateTime = DateTime.Now;
  23345. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  23346. appro.Id = thisId;
  23347. //foreach (var item in gwinfo)
  23348. //{
  23349. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  23350. // chi.Details = "拜访" + item.Client;
  23351. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  23352. // {
  23353. // chi.Details += "," + item.ReqSample;
  23354. // }
  23355. // chi.ParentId = thisId;
  23356. // chi.Time = item.Time;
  23357. // chiarr.Add(chi);
  23358. //}
  23359. if (chiarr.Count < 6)
  23360. {
  23361. for (int j = chiarr.Count; j < 6; j++)
  23362. {
  23363. chiarr.Add(new
  23364. Grp_ApprovalTravelDetails());
  23365. }
  23366. }
  23367. resultArr.Add(new
  23368. {
  23369. appro.Id,
  23370. appro.Date,
  23371. appro.Diid,
  23372. chiList = chiarr.Select(x1 => new
  23373. {
  23374. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  23375. x1.Details,
  23376. x1.ParentId,
  23377. x1.Id
  23378. })
  23379. });
  23380. }
  23381. _sqlSugar.CommitTran();
  23382. jw = JsonView(true, "生成成功!", resultArr);
  23383. }
  23384. catch (Exception ex)
  23385. {
  23386. jw.Code = 400;
  23387. jw.Msg = "生成失败!" + ex.Message;
  23388. }
  23389. return Ok(jw);
  23390. }
  23391. /// <summary>
  23392. /// 报批行程word导出
  23393. /// </summary>
  23394. /// <param name="dto"></param>
  23395. /// <returns></returns>
  23396. [HttpPost]
  23397. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  23398. {
  23399. var jw = JsonView(false);
  23400. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  23401. if (group == null)
  23402. {
  23403. jw.Msg = "暂无该团组!";
  23404. return Ok(jw);
  23405. }
  23406. //模板路径
  23407. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  23408. var fileName = string.Empty;
  23409. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  23410. bool bold = false;
  23411. if (dto.FileIndex == 1)
  23412. {
  23413. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  23414. }
  23415. else if (dto.FileIndex == 2)
  23416. {
  23417. fileName = "省外办-报批.docx";
  23418. bold = false;
  23419. titleFont = "方正黑体简体";
  23420. timeFont = "Times New Roman";
  23421. contentFont = "方正仿宋_GBK";
  23422. }
  23423. else if (dto.FileIndex == 3)
  23424. {
  23425. fileName = "市外办-报批.docx";
  23426. titleFont = "方正黑体简体";
  23427. timeFont = "Times New Roman";
  23428. contentFont = "方正仿宋简体";
  23429. }
  23430. tempPath = tempPath + fileName;
  23431. //载入模板
  23432. Document doc = new Document(tempPath);
  23433. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  23434. //获取所填表格的序数
  23435. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  23436. Aspose.Words.Tables.Row titleRowClone = null;
  23437. Aspose.Words.Tables.Row CenterRowClone = null;
  23438. int index = 0;
  23439. int indexChi = 0;
  23440. int SetIndex = 0;
  23441. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  23442. //获取数据,放到datatable
  23443. foreach (var item in ApprovalTravelArr)
  23444. {
  23445. if (index > 0)
  23446. {
  23447. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  23448. tableOne.AppendChild(titleRowClone);
  23449. }
  23450. var textTime = item.Date;
  23451. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  23452. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  23453. SetIndex++;
  23454. if (ChiRep.Count > 0)
  23455. {
  23456. foreach (var itemChi in ChiRep)
  23457. {
  23458. var txtTime = itemChi.Time;
  23459. var txtDetail = itemChi.Details;
  23460. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  23461. {
  23462. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  23463. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23464. //indexChi++;
  23465. //SetIndex++;
  23466. break;
  23467. }
  23468. if (indexChi > 0)
  23469. {
  23470. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23471. tableOne.AppendChild(CenterRowClone);
  23472. }
  23473. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  23474. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  23475. indexChi++;
  23476. SetIndex++;
  23477. }
  23478. }
  23479. //else
  23480. //{
  23481. // if (indexChi > 0)
  23482. // {
  23483. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  23484. // tableOne.AppendChild(CenterRowClone);
  23485. // }
  23486. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  23487. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  23488. // indexChi++;
  23489. // SetIndex++;
  23490. //}
  23491. index++;
  23492. }
  23493. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  23494. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23495. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  23496. jw.Code = 200;
  23497. jw.Msg = "";
  23498. return Ok(jw);
  23499. }
  23500. private string ParseBlackTime(string time)
  23501. {
  23502. // 匹配可能只有分钟的情况
  23503. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  23504. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  23505. if (match.Success)
  23506. {
  23507. string hours = match.Groups[1].Value;
  23508. string minutes = match.Groups[2].Value;
  23509. // 如果小时部分为空,则只显示分钟
  23510. if (string.IsNullOrEmpty(hours))
  23511. {
  23512. return $"{minutes}分钟";
  23513. }
  23514. // 如果分钟部分为空,则只显示小时
  23515. else if (string.IsNullOrEmpty(minutes))
  23516. {
  23517. return $"{hours}小时";
  23518. }
  23519. // 否则显示完整格式
  23520. else
  23521. {
  23522. return $"{hours}小时{minutes}分钟";
  23523. }
  23524. }
  23525. else
  23526. {
  23527. return "未知时长";
  23528. }
  23529. }
  23530. private string intToString(int numberVal)
  23531. {
  23532. string numberval = numberVal.ToString();
  23533. Dictionary<char, string> Number = new Dictionary<char, string>();
  23534. Number.Add('1', "一");
  23535. Number.Add('2', "二");
  23536. Number.Add('3', "三");
  23537. Number.Add('4', "四");
  23538. Number.Add('5', "五");
  23539. Number.Add('6', "六");
  23540. Number.Add('7', "七");
  23541. Number.Add('8', "八");
  23542. Number.Add('9', "九");
  23543. string stringNumberVal = string.Empty;
  23544. for (int i = 0; i < numberval.Length; i++)
  23545. {
  23546. if (i == 0)
  23547. {
  23548. stringNumberVal += Number[numberval[i]];
  23549. }
  23550. else if (i >= 1)
  23551. {
  23552. if (numberval[i] == '0')
  23553. {
  23554. stringNumberVal = "十";
  23555. }
  23556. else
  23557. {
  23558. stringNumberVal += "十" + Number[numberval[i]];
  23559. }
  23560. }
  23561. }
  23562. return stringNumberVal;
  23563. }
  23564. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  23565. {
  23566. //获取table中的某个单元格,从0开始
  23567. Cell lshCell = table.Rows[rows].Cells[cells];
  23568. //将单元格中段落移除
  23569. foreach (Paragraph item in lshCell.Paragraphs)
  23570. {
  23571. lshCell.Paragraphs.Remove(item);
  23572. }
  23573. if (val.Contains("\r\n"))
  23574. {
  23575. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  23576. foreach (var item in spArr)
  23577. {
  23578. //新建一个段落
  23579. Paragraph p = new Paragraph(doc);
  23580. var r = new Run(doc, item);
  23581. //设置字体
  23582. if (!string.IsNullOrEmpty(font))
  23583. {
  23584. r.Font.Name = font;
  23585. }
  23586. r.Font.Bold = bold;
  23587. //把设置的值赋给之前新建的段落
  23588. p.AppendChild(r);
  23589. //将此段落加到单元格内
  23590. lshCell.AppendChild(p);
  23591. }
  23592. }
  23593. else
  23594. {
  23595. //新建一个段落
  23596. Paragraph p = new Paragraph(doc);
  23597. var r = new Run(doc, val);
  23598. //设置字体
  23599. if (!string.IsNullOrEmpty(font))
  23600. {
  23601. r.Font.Name = font;
  23602. }
  23603. r.Font.Bold = bold;
  23604. //把设置的值赋给之前新建的段落
  23605. p.AppendChild(r);
  23606. //将此段落加到单元格内
  23607. lshCell.AppendChild(p);
  23608. }
  23609. }
  23610. /// <summary>
  23611. /// 报批行程AI续写
  23612. /// </summary>
  23613. /// <returns></returns>
  23614. [HttpPost]
  23615. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  23616. {
  23617. var jw = JsonView(false);
  23618. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  23619. {
  23620. jw.Msg = "参数有误!";
  23621. return Ok(jw);
  23622. }
  23623. KiMiApiClient kiMi = new KiMiApiClient();
  23624. List<SeedMessages> messages = new List<SeedMessages>() {
  23625. new SeedMessages
  23626. {
  23627. Role = KimiRole.system,
  23628. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  23629. },
  23630. new SeedMessages
  23631. {
  23632. Role = KimiRole.user,
  23633. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  23634. }
  23635. };
  23636. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  23637. string data = kimi_result.Choices[0]?.Message.Content;
  23638. if (string.IsNullOrWhiteSpace(data))
  23639. {
  23640. jw.Data = "Ai续写失败!";
  23641. }
  23642. else
  23643. {
  23644. jw = JsonView(true, "success!", data);
  23645. }
  23646. return Ok(jw);
  23647. }
  23648. #endregion
  23649. #region 团组接待意见调查
  23650. /// <summary>
  23651. /// 团组接待意见调查 - 信息管理
  23652. /// 基础数据(团组)
  23653. /// </summary>
  23654. /// <returns></returns>
  23655. [HttpGet]
  23656. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23657. public async Task<IActionResult> OpinionaireInit()
  23658. {
  23659. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  23660. .Select(x => new
  23661. {
  23662. x.Id,
  23663. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  23664. })
  23665. .OrderByDescending(x => x.Id)
  23666. .ToListAsync();
  23667. return Ok(JsonView(groupData, groupData.Count));
  23668. }
  23669. /// <summary>
  23670. /// 团组接待意见调查 - 信息管理
  23671. /// 列表
  23672. /// </summary>
  23673. /// <param name="groupId"></param>
  23674. /// <returns></returns>
  23675. [HttpGet("{groupId}")]
  23676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23677. public async Task<IActionResult> OpinionaireManageList(int groupId)
  23678. {
  23679. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23680. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  23681. .Select(x => new
  23682. {
  23683. x.Id,
  23684. x.TourGuideName,
  23685. x.CityName,
  23686. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  23687. x.CreateTime
  23688. })
  23689. .OrderBy(x => x.Id)
  23690. .ToListAsync();
  23691. return Ok(JsonView(data));
  23692. }
  23693. /// <summary>
  23694. /// 团组接待意见调查 - 信息管理
  23695. /// 保存
  23696. /// </summary>
  23697. /// <param name="dto"></param>
  23698. /// <returns></returns>
  23699. [HttpPost]
  23700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23701. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  23702. {
  23703. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23704. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23705. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23706. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  23707. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  23708. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  23709. _opinionaireRep.BeginTran();
  23710. if (addData != null && addData.Count > 0)
  23711. {
  23712. foreach (var item in addData)
  23713. {
  23714. item.CreateUserId = currUserInfo.UserId;
  23715. item.DiId = dto.DiId;
  23716. }
  23717. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  23718. }
  23719. if (updData != null && updData.Count > 0)
  23720. {
  23721. var upd = await _opinionaireRep._sqlSugar
  23722. .Updateable(updData)
  23723. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  23724. .WhereColumns(x => new { x.Id })
  23725. .ExecuteCommandAsync();
  23726. }
  23727. _opinionaireRep.CommitTran();
  23728. return Ok(JsonView("操作成功!"));
  23729. }
  23730. /// <summary>
  23731. /// 团组接待意见调查 - 信息管理
  23732. /// 删除
  23733. /// </summary>
  23734. /// <param name="id"></param>
  23735. /// <returns></returns>
  23736. [HttpDelete("{id}")]
  23737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23738. public async Task<IActionResult> OpinionaireManageDel(int id)
  23739. {
  23740. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  23741. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  23742. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  23743. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  23744. if (!del) return Ok(JsonView("操作失败!"));
  23745. return Ok(JsonView("操作成功!"));
  23746. }
  23747. /// <summary>
  23748. /// 团组接待意见调查 - 用户
  23749. /// 列表
  23750. /// </summary>
  23751. /// <param name="diId"></param>
  23752. /// <returns></returns>
  23753. [HttpGet("{diId}")]
  23754. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23755. public async Task<IActionResult> OpinionaireUserList(int diId)
  23756. {
  23757. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  23758. var sql = string.Format(@"
  23759. SELECT
  23760. o.Id,
  23761. o.DiId,
  23762. di.TeamName AS 'GroupName',
  23763. di.VisitPNumber AS 'PeopleNumber',
  23764. di.ClientName AS 'LeadGroup',
  23765. di.VisitCountry AS 'Travel',
  23766. di.VisitDays AS 'Days',
  23767. o.CityName,
  23768. o.TourGuideName,
  23769. o.Catering,
  23770. o.CateringReason,
  23771. o.Stay,
  23772. o.StayReason,
  23773. o.[Route],
  23774. o.RouteReason,
  23775. o.OfficialActivity,
  23776. o.OfficialActivityReason,
  23777. o.TourGuide,
  23778. o.TourGuideReason,
  23779. o.[Translate],
  23780. o.TranslateReason,
  23781. o.Trip,
  23782. o.TripReason,
  23783. o.ESFileName,
  23784. o.SignatureDate,
  23785. o.Remark
  23786. FROM
  23787. Grp_Opinionaire o
  23788. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  23789. WHERE
  23790. o.IsDel = 0
  23791. AND o.DiId = {0}
  23792. ORDER BY
  23793. o.Id ASC", diId);
  23794. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  23795. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  23796. return Ok(JsonView(data));
  23797. }
  23798. /// <summary>
  23799. /// 团组接待意见调查 - 用户
  23800. /// 保存
  23801. /// </summary>
  23802. /// <param name="dto"></param>
  23803. /// <returns></returns>
  23804. [HttpPost]
  23805. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23806. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  23807. {
  23808. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  23809. foreach (var item in dto)
  23810. {
  23811. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  23812. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  23813. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  23814. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  23815. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  23816. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  23817. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  23818. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  23819. }
  23820. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  23821. if (!Directory.Exists(filePathBase))
  23822. {
  23823. Directory.CreateDirectory(filePathBase);
  23824. }
  23825. #region 上传文件
  23826. var filePaths = new List<string>();
  23827. foreach (var item in dto)
  23828. {
  23829. var file = item.File;
  23830. // 将文件保存到指定位置
  23831. var filePath = Path.Combine(filePathBase, file.FileName);
  23832. using (var stream = new FileStream(filePath, FileMode.Create))
  23833. {
  23834. await file.CopyToAsync(stream);
  23835. }
  23836. //验证文件是否上传成功
  23837. if (!System.IO.File.Exists(filePath))
  23838. {
  23839. foreach (var filePathStr in filePaths)
  23840. {
  23841. System.IO.File.Delete(filePathStr);
  23842. }
  23843. return Ok(JsonView(false, "文件上传失败!"));
  23844. }
  23845. item.ESFileName = file.FileName;
  23846. }
  23847. #endregion
  23848. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  23849. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  23850. .UpdateColumns(x => new
  23851. {
  23852. x.Catering,
  23853. x.CateringReason,
  23854. x.Stay,
  23855. x.StayReason,
  23856. x.Route,
  23857. x.RouteReason,
  23858. x.OfficialActivity,
  23859. x.OfficialActivityReason,
  23860. x.TourGuide,
  23861. x.TourGuideReason,
  23862. x.Translate,
  23863. x.TranslateReason,
  23864. x.Trip,
  23865. x.TripReason,
  23866. x.ESFileName,
  23867. x.SignatureDate,
  23868. x.Remark
  23869. })
  23870. .WhereColumns(x => new { x.Id })
  23871. .ExecuteCommandAsync();
  23872. if (upd < 1)
  23873. {
  23874. foreach (var filePathStr in filePaths)
  23875. {
  23876. System.IO.File.Delete(filePathStr);
  23877. }
  23878. return Ok(JsonView(false));
  23879. }
  23880. return Ok(JsonView(true));
  23881. }
  23882. #endregion
  23883. #region 团组餐厅相关信息
  23884. /// <summary>
  23885. /// 团组相关餐厅信息
  23886. /// 基础数据(团组)
  23887. /// </summary>
  23888. /// <returns></returns>
  23889. [HttpGet]
  23890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23891. public async Task<IActionResult> RestaurantInit()
  23892. {
  23893. return Ok(await _restaurantRep.InitAsync());
  23894. }
  23895. /// <summary>
  23896. /// 团组相关餐厅信息
  23897. /// Item
  23898. /// </summary>
  23899. /// <param name="dto"></param>
  23900. /// <returns></returns>
  23901. [HttpPost]
  23902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23903. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  23904. {
  23905. int portType = dto.PortType,
  23906. groupId = dto.GroupId;
  23907. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23908. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23909. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  23910. }
  23911. /// <summary>
  23912. /// 团组相关餐厅信息
  23913. /// List
  23914. /// </summary>
  23915. /// <param name="dto"></param>
  23916. /// <returns></returns>
  23917. [HttpPost]
  23918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23919. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  23920. {
  23921. int portType = dto.PortType,
  23922. groupId = dto.GroupId;
  23923. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23924. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23925. var sql = string.Format(@" SELECT
  23926. ri.Id,
  23927. ri.GroupId,
  23928. ri.Date,
  23929. ri.StartTime,
  23930. ri.EndTime,
  23931. CASE WHEN ri.Type = 1 THEN '早餐'
  23932. WHEN ri.Type = 2 THEN '午餐'
  23933. WHEN ri.Type = 3 THEN '晚餐'
  23934. ELSE '其他'
  23935. END AS 'Type',
  23936. ri.Name,
  23937. ri.Address,
  23938. ri.Tel,
  23939. ri.Remark,
  23940. ri.CreateTime,
  23941. u.CnName AS CreateUserName
  23942. FROM
  23943. Grp_RestaurantInfo ri
  23944. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  23945. WHERE
  23946. ri.IsDel = 0
  23947. AND ri.GroupId = {0}
  23948. ORDER BY
  23949. ri.Date ASC
  23950. ", groupId);
  23951. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  23952. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  23953. return Ok(JsonView(infos));
  23954. }
  23955. /// <summary>
  23956. /// 团组相关餐厅信息
  23957. /// Info
  23958. /// </summary>
  23959. /// <param name="dto"></param>
  23960. /// <returns></returns>
  23961. [HttpPost]
  23962. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23963. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  23964. {
  23965. int portType = dto.PortType,
  23966. id = dto.Id;
  23967. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  23968. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  23969. return Ok(await _restaurantRep.InfoAsync(portType, id));
  23970. }
  23971. /// <summary>
  23972. /// 团组相关餐厅信息
  23973. /// Op
  23974. /// </summary>
  23975. /// <param name="dto"></param>
  23976. /// <returns></returns>
  23977. [HttpPost]
  23978. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23979. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  23980. {
  23981. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23982. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  23983. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  23984. return Ok(await _restaurantRep.OpAsync(dto));
  23985. }
  23986. /// <summary>
  23987. /// 团组相关餐厅信息
  23988. /// Del
  23989. /// </summary>
  23990. /// <param name="dto"></param>
  23991. /// <returns></returns>
  23992. [HttpPost]
  23993. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23994. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  23995. {
  23996. int userId = dto.DeleteUserId;
  23997. var id = dto.Id;
  23998. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23999. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  24000. return Ok(await _restaurantRep.DelAsync(dto));
  24001. }
  24002. #endregion
  24003. #region 团组会务成本
  24004. /// <summary>
  24005. /// 团组会务成本数据初始化
  24006. /// </summary>
  24007. /// <returns></returns>
  24008. [HttpPost]
  24009. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  24010. {
  24011. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  24012. .OrderByDescending(x => x.CreateTime)
  24013. .Where(x => x.IsDel == 0)
  24014. .Select<DelegationEasyView>();
  24015. DelegationEasyView di = Dto.GroupId == 0 ?
  24016. expr.First() :
  24017. expr.First(x => x.Id == Dto.GroupId);
  24018. if (di == null)
  24019. {
  24020. return Ok(JsonView(false, "团组信息不存在!"));
  24021. }
  24022. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  24023. .Where(x => x.IsDel == 0 && x.STid == 21)
  24024. .Select(x => new { x.Id, Text = x.Name })
  24025. .ToListAsync();
  24026. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  24027. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  24028. .Select(x => x.Id)
  24029. .ToList();
  24030. //仅检索会务团组
  24031. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24032. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  24033. .OrderByDescending(x => x.VisitDate)
  24034. .Select(x => new { x.Id, x.TeamName })
  24035. .ToListAsync();
  24036. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  24037. var userList = await _sqlSugar.Queryable<Sys_Users>()
  24038. .Where(x => x.IsDel == 0)
  24039. .Select(x => new { x.Id, x.CnName })
  24040. .ToListAsync();
  24041. var units = await _sqlSugar.Queryable<Sys_SetData>()
  24042. .Where(x => x.IsDel == 0 && x.STid == 119)
  24043. .Select(x => new { x.Id, Text = x.Name })
  24044. .ToListAsync();
  24045. var FileType = new[]
  24046. {
  24047. new { Id = 0 , Name = "成本下载" },
  24048. new { Id = 1 , Name = "报价下载" },
  24049. new { Id = 2 , Name = "总表下载" },
  24050. };
  24051. var GM = new List<int>();
  24052. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  24053. try
  24054. {
  24055. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  24056. }
  24057. catch (Exception ex)
  24058. {
  24059. GM = new List<int>() { 21 };
  24060. }
  24061. var isReview = Dto.UserId == 21;
  24062. var isGM = GM.Contains(Dto.UserId);
  24063. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  24064. .Where(x => x.IsDel == 0)
  24065. .Select<ConferenceAffairsCostView>()
  24066. .First(x => x.Diid == di.Id);
  24067. if (ConferenceAffairsCost == null)
  24068. {
  24069. ConferenceAffairsCost = new ConferenceAffairsCostView();
  24070. ConferenceAffairsCost.Diid = di.Id;
  24071. }
  24072. #region 权限校验
  24073. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  24074. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  24075. .Select(x => x.UserId)
  24076. .Distinct()
  24077. .ToList();
  24078. if (!ids.Contains(Dto.UserId) && !isGM)
  24079. {
  24080. return Ok(JsonView(201, "暂无权限!", new
  24081. {
  24082. typeData,
  24083. groupList,
  24084. currenyList,
  24085. isGM,
  24086. userList,
  24087. units,
  24088. isReview,
  24089. operatorUser = ids,
  24090. di,
  24091. FileType
  24092. }));
  24093. }
  24094. #endregion
  24095. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  24096. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  24097. .Select<ConferenceAffairsCostChildView>()
  24098. .OrderBy(x => x.Index)
  24099. .ToList();
  24100. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  24101. {
  24102. ConferenceAffairsCostChi[i - 1].Index = i;
  24103. }
  24104. var backData = new
  24105. {
  24106. ConferenceAffairsCost,
  24107. ConferenceAffairsCostChi,
  24108. typeData,
  24109. groupList,
  24110. currenyList,
  24111. isGM,
  24112. userList,
  24113. units,
  24114. isReview,
  24115. operatorUser = ids,
  24116. di,
  24117. FileType
  24118. };
  24119. return Ok(JsonView(true, "SUCCESS", backData));
  24120. }
  24121. /// <summary>
  24122. /// 会务成本保存
  24123. /// </summary>
  24124. /// <returns></returns>
  24125. [HttpPost]
  24126. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  24127. {
  24128. _sqlSugar.BeginTran();
  24129. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  24130. var childResult = new
  24131. {
  24132. success = 0,
  24133. error = 0
  24134. };
  24135. try
  24136. {
  24137. if (data.Id == 0)
  24138. {
  24139. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  24140. .Where(x => x.Diid == Dto.GroupId)
  24141. .SetColumns(x => new Grp_ConferenceAffairsCost
  24142. {
  24143. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24144. DeleteUserId = Dto.UserId
  24145. })
  24146. .ExecuteCommand();
  24147. data.Diid = Dto.GroupId;
  24148. data.CreateTime = DateTime.Now;
  24149. data.CreateUserId = Dto.UserId;
  24150. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  24151. .ExecuteReturnIdentity();
  24152. }
  24153. else
  24154. {
  24155. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  24156. .ExecuteCommand();
  24157. data.Id = data.Id;
  24158. }
  24159. if (Dto.ConferenceAffairsCostChild.Any())
  24160. {
  24161. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  24162. var insertArr = datas.Where(x => x.Id == 0).ToList();
  24163. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  24164. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  24165. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  24166. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  24167. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  24168. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  24169. .ExecuteCommand() : 0;
  24170. childResult = childResult with
  24171. {
  24172. error = notUpdateArr.Count(),
  24173. success = inrsetCount + updateCount
  24174. };
  24175. }
  24176. _sqlSugar.CommitTran();
  24177. }
  24178. catch (Exception ex)
  24179. {
  24180. _sqlSugar.RollbackTran();
  24181. return Ok(JsonView(false, "失败!" + ex.Message));
  24182. }
  24183. return Ok(JsonView(true, "操作成功!", childResult));
  24184. }
  24185. [HttpPost]
  24186. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  24187. {
  24188. var count = 0;
  24189. if (Dto.ConferenceAffairsCostChildids.Any())
  24190. {
  24191. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  24192. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  24193. SetColumns(x => new Grp_ConferenceAffairsCostChild
  24194. {
  24195. ReviewStatus = Dto.ReviewStatus
  24196. }).
  24197. ExecuteCommand();
  24198. }
  24199. return Ok(JsonView(true, "操作成功!", count));
  24200. }
  24201. /// <summary>
  24202. /// 会务成本所有数据清除
  24203. /// </summary>
  24204. /// <param name="Dto"></param>
  24205. /// <returns></returns>
  24206. [HttpPost]
  24207. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  24208. {
  24209. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24210. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  24211. _sqlSugar.BeginTran();
  24212. try
  24213. {
  24214. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  24215. .Where(x => x.Diid == Dto.GroupId)
  24216. .SetColumns(x => new Grp_ConferenceAffairsCost
  24217. {
  24218. IsDel = 1,
  24219. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24220. DeleteUserId = Dto.UserId
  24221. })
  24222. .ExecuteCommand();
  24223. if (delCount > 0)
  24224. {
  24225. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24226. .Where(x => x.Diid == Dto.GroupId)
  24227. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24228. {
  24229. IsDel = 1,
  24230. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24231. DeleteUserId = Dto.UserId
  24232. })
  24233. .ExecuteCommand();
  24234. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24235. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24236. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24237. {
  24238. IsDel = 1,
  24239. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24240. DeleteUserId = Dto.UserId
  24241. })
  24242. .ExecuteCommand();
  24243. }
  24244. _sqlSugar.CommitTran();
  24245. }
  24246. catch (Exception ex)
  24247. {
  24248. _sqlSugar.RollbackTran();
  24249. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24250. }
  24251. return Ok(JsonView(true, "操作成功!"));
  24252. }
  24253. /// <summary>
  24254. /// 子项数据删除
  24255. /// </summary>
  24256. /// <param name="Dto"></param>
  24257. /// <returns></returns>
  24258. [HttpPost]
  24259. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  24260. {
  24261. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  24262. .Any(x => x.ReviewStatus == 1);
  24263. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  24264. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  24265. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  24266. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  24267. {
  24268. IsDel = 1,
  24269. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24270. DeleteUserId = Dto.UserId
  24271. })
  24272. .ExecuteCommand();
  24273. return Ok(JsonView(true, "SUCCESS!", count));
  24274. }
  24275. /// <summary>
  24276. /// 会务成本权限分配
  24277. /// </summary>
  24278. /// <param name="Dto"></param>
  24279. /// <returns></returns>
  24280. [HttpPost]
  24281. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  24282. {
  24283. _sqlSugar.BeginTran();
  24284. var count = 0;
  24285. try
  24286. {
  24287. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  24288. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  24289. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  24290. {
  24291. IsDel = 1,
  24292. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24293. DeleteUserId = Dto.CreateUserId
  24294. })
  24295. .ExecuteCommand();
  24296. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  24297. {
  24298. CreateTime = DateTime.Now,
  24299. CreateUserId = Dto.CreateUserId,
  24300. UserId = x,
  24301. Diid = Dto.GroupId,
  24302. }).ToList()).ExecuteCommand();
  24303. _sqlSugar.CommitTran();
  24304. }
  24305. catch (Exception ex)
  24306. {
  24307. _sqlSugar.RollbackTran();
  24308. return Ok(JsonView(false, "操作失败!" + ex.Message));
  24309. }
  24310. return Ok(JsonView(true, "操作成功!", count));
  24311. }
  24312. /// <summary>
  24313. /// 团组会务成本文件下载
  24314. /// </summary>
  24315. /// <returns></returns>
  24316. [HttpPost]
  24317. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  24318. {
  24319. var FileType = new[]
  24320. {
  24321. new { Id = 0 , Name = "成本下载" },
  24322. new { Id = 1 , Name = "报价下载" },
  24323. new { Id = 2 , Name = "总表下载" },
  24324. };
  24325. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  24326. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  24327. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  24328. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  24329. .Select<DelegationEasyView>()
  24330. .First();
  24331. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  24332. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  24333. if (main == null)
  24334. {
  24335. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  24336. }
  24337. JsonView jw = JsonView(false);
  24338. //总表下载
  24339. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  24340. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  24341. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24342. var field = string.Empty;
  24343. var fileTypeName = string.Empty;
  24344. field = @$"
  24345. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  24346. b.Name as PriceTypeStr ,
  24347. c.Name as CurrencyStr ,
  24348. d.Name as UnitStr ,
  24349. case a.ReviewStatus
  24350. WHEN 1 THEN '已通过'
  24351. WHEN 0 THEN '未审核'
  24352. WHEN -1 THEN '未通过'
  24353. ELSE '未审核'
  24354. END AS ReviewStatusStr
  24355. ";
  24356. if (Dto.FileTypeId == 0)
  24357. {
  24358. fileTypeName = "会务成本成本表";
  24359. loadPath += $"{fileTypeName}.xlsx";
  24360. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24361. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24362. }
  24363. else if (Dto.FileTypeId == 1)
  24364. {
  24365. fileTypeName = "会务成本报价表";
  24366. loadPath += $"{fileTypeName}.xlsx";
  24367. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24368. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24369. }
  24370. else if (Dto.FileTypeId == 2)
  24371. {
  24372. fileTypeName = "会务成本总表";
  24373. loadPath += $"{fileTypeName}.xlsx";
  24374. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24375. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  24376. }
  24377. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  24378. SELECT
  24379. {field}
  24380. FROM Grp_ConferenceAffairsCostChild a
  24381. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  24382. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  24383. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  24384. WHERE a.isdel = 0
  24385. AND a.Diid = {main.Diid}
  24386. AND a.ConferenceAffairsCostId = {main.Id}
  24387. ").ToList();
  24388. var currLists = chiExcelContent.Select(x => new CurrList
  24389. {
  24390. CurrName = x.CurrencyStr,
  24391. CurrRate = x.Rate
  24392. })
  24393. .Distinct()
  24394. .ToList();
  24395. var designer = new WorkbookDesigner
  24396. {
  24397. Workbook = new Workbook(loadPath)
  24398. };
  24399. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  24400. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  24401. designer.SetDataSource("TeamName", di.TeamName);
  24402. designer.SetDataSource("City", main.City);
  24403. designer.SetDataSource("AllCost", main.CostAll);
  24404. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  24405. designer.SetDataSource("Curr", MostCurr.Name);
  24406. designer.SetDataSource("Curr1", MostCurr.Name);
  24407. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  24408. dt.TableName = "TB";
  24409. designer.SetDataSource(dt);
  24410. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  24411. dt1.TableName = "currTb";
  24412. designer.SetDataSource(dt1);
  24413. designer.Process();
  24414. designer.Workbook.Save(outputPath);
  24415. jw = JsonView(true, "操作成功!", new
  24416. {
  24417. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  24418. FilePath = networkPath
  24419. });
  24420. return Ok(jw);
  24421. }
  24422. [HttpPost]
  24423. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  24424. {
  24425. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  24426. .Select(x => x.PriceName).ToList()));
  24427. }
  24428. #endregion
  24429. #region 会务流程
  24430. /// <summary>
  24431. /// 会务流程 - 数据初始化
  24432. /// </summary>
  24433. /// <param name="dto"></param>
  24434. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  24435. [HttpPost]
  24436. public async Task<IActionResult> ConferenceProceduresInit(ConferenceProceduresInitDto dto)
  24437. {
  24438. try
  24439. {
  24440. Grp_DelegationInfo targetGroup = null;
  24441. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24442. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  24443. .FirstAsync();
  24444. if (targetGroup == null)
  24445. {
  24446. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24447. .Where(x => x.IsDel == 0)
  24448. .OrderByDescending(x => x.CreateTime)
  24449. .FirstAsync();
  24450. }
  24451. if (targetGroup == null)
  24452. {
  24453. return Ok(JsonView(false, "未找到任何团组信息"));
  24454. }
  24455. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24456. .Where(x => x.IsDel == 0)
  24457. .OrderByDescending(x => x.CreateTime)
  24458. .Select(x => new { x.Id, x.TeamName })
  24459. .ToListAsync();
  24460. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24461. .Where(x => x.DiId == targetGroup.Id && x.IsDel == 0)
  24462. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  24463. .ToListAsync();
  24464. if (!conferenceProceduresList.Any())
  24465. {
  24466. conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24467. .Where(x => x.DiId == -1 && x.IsDel == 0)
  24468. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  24469. .ToListAsync();
  24470. }
  24471. var conferenceProceduresGroupByTitle = conferenceProceduresList
  24472. .GroupBy(x => x.Title)
  24473. .Select(x => new
  24474. {
  24475. title = x.Key,
  24476. itmes = x.Select(y => new
  24477. {
  24478. y.Id,
  24479. y.DataDetails,
  24480. y.Details,
  24481. y.Remark
  24482. }).ToList()
  24483. })
  24484. .ToList();
  24485. var response = new
  24486. {
  24487. GroupInfo = new
  24488. {
  24489. targetGroup.Id,
  24490. targetGroup.TeamName,
  24491. targetGroup.VisitDate,
  24492. targetGroup.VisitDays,
  24493. targetGroup.VisitPNumber,
  24494. targetGroup.VisitCountry,
  24495. targetGroup.VisitStartDate,
  24496. targetGroup.VisitEndDate,
  24497. targetGroup.ClientName,
  24498. targetGroup.ClientUnit
  24499. },
  24500. GroupList = groupList,
  24501. ConferenceProceduresList = conferenceProceduresList,
  24502. conferenceProceduresGroupByTitle = conferenceProceduresGroupByTitle
  24503. };
  24504. return Ok(JsonView(true, "SUCCESS", response));
  24505. }
  24506. catch (Exception ex)
  24507. {
  24508. _logger.LogError(ex, "数据初始化失败");
  24509. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  24510. }
  24511. }
  24512. /// <summary>
  24513. /// 会务流程 - 保存
  24514. /// </summary>
  24515. /// <param name="dto"></param>
  24516. /// <returns></returns>
  24517. [HttpPost]
  24518. public async Task<IActionResult> ConferenceProceduresSave(ConferenceProceduresSaveDto dto)
  24519. {
  24520. _sqlSugar.BeginTran();
  24521. try
  24522. {
  24523. //删除旧数据
  24524. _sqlSugar.Updateable<Grp_ConferenceProcedures>()
  24525. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  24526. .SetColumns(x => new Grp_ConferenceProcedures
  24527. {
  24528. IsDel = 1,
  24529. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  24530. DeleteUserId = dto.UserId
  24531. })
  24532. .ExecuteCommand();
  24533. //添加新数据
  24534. var newData = new List<Grp_ConferenceProcedures>();
  24535. foreach (var item in dto.ConferenceProceduresSaveItem)
  24536. {
  24537. foreach (var item2 in item.itmes)
  24538. {
  24539. newData.Add(new Grp_ConferenceProcedures
  24540. {
  24541. DiId = dto.GroupId,
  24542. Title = item.title,
  24543. DataDetails = item2.DataDetails,
  24544. Details = item2.details,
  24545. Remark = item2.Remark,
  24546. CreateTime = DateTime.Now,
  24547. CreateUserId = dto.UserId
  24548. });
  24549. }
  24550. }
  24551. _sqlSugar.Insertable(newData).ExecuteCommand();
  24552. _sqlSugar.CommitTran();
  24553. }
  24554. catch (Exception ex)
  24555. {
  24556. _sqlSugar.RollbackTran();
  24557. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  24558. }
  24559. return Ok(JsonView(true, "SUCCESS"));
  24560. }
  24561. [HttpPost]
  24562. public async Task<IActionResult> ConferenceProceduresFileDown(ConferenceProceduresFileDownDto dto)
  24563. {
  24564. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24565. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  24566. .FirstAsync();
  24567. if (groupInfo == null)
  24568. {
  24569. return Ok(JsonView(false, "团组信息不存在"));
  24570. }
  24571. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  24572. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  24573. .ToListAsync();
  24574. if (!conferenceProceduresList.Any())
  24575. {
  24576. return Ok(JsonView(false, "会务流程信息不存在"));
  24577. }
  24578. var filePath = $"{AppSettingsHelper.Get("ExcelBasePath")}Template/会务流程.xlsx";
  24579. if (!System.IO.File.Exists(filePath))
  24580. {
  24581. return Ok(JsonView(false, "模板文件不存在"));
  24582. }
  24583. var designer = new WorkbookDesigner();
  24584. designer.Workbook = new Workbook(filePath);
  24585. designer.SetDataSource("TB", conferenceProceduresList);
  24586. designer.Process();
  24587. var sheet = designer.Workbook.Worksheets[0];
  24588. var cells = sheet.Cells;
  24589. int col = 0; // 第一列
  24590. int startRow = 2; // 若第0行为表头,则从第1行开始;无表头请改为0
  24591. int endRow = cells.MaxDataRow;
  24592. if (endRow >= startRow)
  24593. {
  24594. int mergeStart = startRow;
  24595. string prev = cells[mergeStart, col].StringValue?.Trim() ?? string.Empty;
  24596. for (int r = startRow + 1; r <= endRow; r++)
  24597. {
  24598. string cur = cells[r, col].StringValue?.Trim() ?? string.Empty;
  24599. if (!string.Equals(cur, prev, StringComparison.Ordinal))
  24600. {
  24601. int count = r - mergeStart;
  24602. if (count > 1)
  24603. cells.Merge(mergeStart, col, count, 1);
  24604. mergeStart = r;
  24605. prev = cur;
  24606. }
  24607. }
  24608. int tailCount = endRow - mergeStart + 1;
  24609. if (tailCount > 1)
  24610. cells.Merge(mergeStart, col, tailCount, 1);
  24611. }
  24612. // byte[] bytes = null;
  24613. // using (MemoryStream stream = new MemoryStream())
  24614. // {
  24615. // designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  24616. // bytes = stream.ToArray();
  24617. // }
  24618. // return File(bytes, "application/excel", $"{groupInfo.TeamName}_会务流程.xlsx");
  24619. string savePath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceProcedures";
  24620. if (!System.IO.Directory.Exists(savePath))
  24621. {
  24622. System.IO.Directory.CreateDirectory(savePath);
  24623. }
  24624. designer.Workbook.Save($"{savePath}/{groupInfo.TeamName}_会务流程.xlsx");
  24625. string rst = savePath.replace(AppSettingsHelper.Get("ExcelBasePath"),
  24626. AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  24627. return Ok(JsonView(true, "SUCCESS", $"{rst}/{groupInfo.TeamName}_会务流程.xlsx"));
  24628. }
  24629. #endregion
  24630. #region 团组签证流程
  24631. /// <summary>
  24632. /// 团组签证流程 - 团组列表(分页)
  24633. /// </summary>
  24634. /// <returns></returns>
  24635. [HttpPost]
  24636. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  24637. {
  24638. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  24639. string groupName = dto.GroupName.Trim();
  24640. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  24641. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  24642. int portType = dto.PortType;
  24643. RefAsync<int> total = 0;
  24644. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  24645. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  24646. .InnerJoin<Grp_VisaProcessSteps>((x, y, z) => x.DIId == z.GroupId)
  24647. .Where((x, y, z) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId && z.IsDel == 0);
  24648. //构建单字模糊查询
  24649. if (!string.IsNullOrEmpty(groupName))
  24650. {
  24651. var characters = groupName.ToCharArray();
  24652. foreach (var character in characters)
  24653. {
  24654. var charString = character.ToString();
  24655. query = query.Where((x, y) =>
  24656. SqlFunc.Contains(y.TeamName, charString));
  24657. }
  24658. }
  24659. var groups = await query
  24660. .OrderByDescending((x, y) => y.VisitDate)
  24661. .Select((x, y) => new
  24662. {
  24663. y.Id,
  24664. GroupName = y.TeamName,
  24665. y.VisitDate,
  24666. // 加入子查询统计子表条数
  24667. CompletedCount = SqlFunc.Subqueryable<Grp_VisaProcessSteps>()
  24668. .Where(sub => sub.GroupId == y.Id && sub.IsCompleted && sub.IsDel == 0)
  24669. .Count()
  24670. })
  24671. .Distinct()
  24672. .ToPageListAsync(pageIndex, pageSize, total);
  24673. var msg = "SUCCESS";
  24674. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  24675. var groups1 = groups.Select(x => new {
  24676. x.Id,
  24677. x.GroupName,
  24678. x.CompletedCount
  24679. }).ToList();
  24680. return Ok(JsonView(true, msg, groups1, total));
  24681. }
  24682. /// <summary>
  24683. /// 团组签证流程 - 详情
  24684. /// </summary>
  24685. /// <returns></returns>
  24686. [HttpPost]
  24687. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  24688. {
  24689. var res = await _visaProcessRep.Info(dto);
  24690. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24691. return Ok(JsonView(true, res.Msg, res.Data));
  24692. }
  24693. /// <summary>
  24694. /// 团组签证流程 - 流程创建测试
  24695. /// </summary>
  24696. /// <returns></returns>
  24697. [HttpPost]
  24698. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  24699. {
  24700. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  24701. }
  24702. /// <summary>
  24703. /// 团组签证流程 - 流程Top4Init 测试
  24704. /// </summary>
  24705. /// <returns></returns>
  24706. [HttpPost]
  24707. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  24708. {
  24709. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  24710. }
  24711. /// <summary>
  24712. /// 团组签证流程 - 设置状态 完成/未完成
  24713. /// </summary>
  24714. /// <returns></returns>
  24715. [HttpPost]
  24716. public async Task<IActionResult> VisaProcessSetCompleted(VisaProcessSetCompletedDto dto)
  24717. {
  24718. //参数验证
  24719. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).AnyAsync();
  24720. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  24721. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24722. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24723. var res = await _visaProcessRep.SetCompleted(dto.StepId, dto.CurrUserId, dto.IsCompleted);
  24724. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24725. return Ok(JsonView(true, res.Msg));
  24726. }
  24727. /// <summary>
  24728. /// 团组签证流程 - 修改各步骤内容
  24729. /// </summary>
  24730. /// <returns></returns>
  24731. [HttpPost]
  24732. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  24733. {
  24734. //参数验证
  24735. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24736. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24737. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24738. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24739. if (dto.StepContents == null && dto.StepContents.Count < 1)
  24740. {
  24741. return Ok(JsonView(false, "步骤内容无效。"));
  24742. }
  24743. //各步骤值处理
  24744. object stepVal;
  24745. if (stepValid.Step == 7) stepVal = dto.StepContents;
  24746. else stepVal = dto.StepContents[0].ToString();
  24747. var stepInfo = new Grp_VisaProcessSteps
  24748. {
  24749. Id = dto.StepId,
  24750. DataType = stepValid.DataType,
  24751. TypedValue = stepVal,
  24752. LastUpdateUserId = dto.CurrUserId
  24753. };
  24754. var res = await _visaProcessRep.Update(stepInfo);
  24755. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  24756. return Ok(JsonView(true, res.Msg));
  24757. }
  24758. /// <summary>
  24759. /// 团组签证流程 - 上传文件
  24760. /// </summary>
  24761. /// <returns></returns>
  24762. [HttpPost]
  24763. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  24764. {
  24765. //参数验证
  24766. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  24767. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24768. var before = stepValid;
  24769. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  24770. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24771. //验证文件是否存在
  24772. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  24773. //验证该步骤是否可以上传文件
  24774. var uploadSteps = new List<int>() {
  24775. 5, //实际出签时间
  24776. 6, //是否需要开出境证明
  24777. 7, //是否需要办理电子入境卡手续
  24778. };
  24779. if (!uploadSteps.Contains(stepValid.Step))
  24780. {
  24781. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  24782. }
  24783. //验证根目录
  24784. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24785. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24786. if (!System.IO.Directory.Exists(rootPath))
  24787. {
  24788. System.IO.Directory.CreateDirectory(rootPath);
  24789. }
  24790. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24791. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24792. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  24793. .Select(x => $"{x.TeamName}({x.Id})")
  24794. .FirstAsync();
  24795. //创建团组文件夹
  24796. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  24797. if (!System.IO.Directory.Exists(groupPath))
  24798. {
  24799. System.IO.Directory.CreateDirectory(groupPath);
  24800. }
  24801. List<string> filePaths = new List<string>();
  24802. //保存文件
  24803. foreach (var file in dto.Files)
  24804. {
  24805. // 生成存储文件名
  24806. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  24807. var filePath = Path.Combine(groupPath, fileName);
  24808. // 保存文件到磁盘
  24809. using (var stream = new FileStream(filePath, FileMode.Create))
  24810. {
  24811. await file.CopyToAsync(stream);
  24812. }
  24813. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  24814. }
  24815. //数据库存储
  24816. stepValid.TypedFileNameValue = filePaths;
  24817. stepValid.LastUpdateUserId = dto.CurrUserId;
  24818. stepValid.LastUpdateTime = DateTime.Now;
  24819. var res = await _sqlSugar.Updateable(stepValid)
  24820. .UpdateColumns(it => new { it.TypedFileNameValue, it.LastUpdateUserId, it.LastUpdateTime })
  24821. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  24822. .ExecuteCommandAsync();
  24823. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  24824. //记录上传文件
  24825. await _visaProcessRep.LogOperationAsync(before, stepValid, "Upload", dto.CurrUserId);
  24826. return Ok(JsonView(true));
  24827. }
  24828. /// <summary>
  24829. /// 团组签证流程 - step 7 资料下载
  24830. /// </summary>
  24831. /// <returns></returns>
  24832. [HttpGet]
  24833. public async Task<IActionResult> VisaProcessDownload(int groupId,int currUserId)
  24834. {
  24835. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  24836. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  24837. //验证根目录
  24838. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  24839. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  24840. if (!System.IO.Directory.Exists(rootPath))
  24841. {
  24842. System.IO.Directory.CreateDirectory(rootPath);
  24843. }
  24844. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  24845. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  24846. .Where(x => x.IsDel == 0 && x.Id == groupId)
  24847. .Select(x => $"{x.TeamName}({x.Id})")
  24848. .FirstAsync();
  24849. //创建团组文件夹
  24850. var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
  24851. var randomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24852. var dirName = $"{groupName}_相关资料_{timestamp}";
  24853. var sourceDirectoryPath = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}";
  24854. var path = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}/{dirName}";
  24855. if (!System.IO.Directory.Exists(path))
  24856. {
  24857. System.IO.Directory.CreateDirectory(path);
  24858. }
  24859. //验证接团客户名单
  24860. string sql = string.Format(@"
  24861. SELECT
  24862. tcl.Id,
  24863. tcl.DiId,
  24864. tcl.IsAccompany,
  24865. temp.*,
  24866. u.CnName AS Operator,
  24867. tcl.CreateTime AS OperatingTime,
  24868. ssd.name AS ShippingSpaceType
  24869. FROM
  24870. Grp_TourClientList tcl
  24871. LEFT JOIN (
  24872. SELECT
  24873. dc.Id AS DcId,
  24874. dc.LastName,
  24875. dc.FirstName,
  24876. ccom.CompanyFullName,
  24877. dc.Job,
  24878. cc.CertNo AS IDCardNo,
  24879. dc.Sex,
  24880. dc.BirthDay
  24881. FROM
  24882. Crm_DeleClient dc
  24883. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  24884. AND ccom.IsDel = 0
  24885. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  24886. AND cc.SdId = 773
  24887. AND cc.IsDel = 0
  24888. WHERE
  24889. dc.IsDel = 0
  24890. ) temp ON temp.DcId = tcl.ClientId
  24891. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  24892. LEFT JOIN sys_setdata ssd ON ssd.isdel = 0 AND ssd.id = tcl.ShippingSpaceTypeid
  24893. WHERE
  24894. tcl.IsDel = 0
  24895. AND tcl.DiId = {0}", groupId);
  24896. var groupClientList = await _sqlSugar.SqlQueryable<TourClientInfosView>(sql).ToListAsync();
  24897. //解密
  24898. foreach (var item in groupClientList)
  24899. {
  24900. EncryptionProcessor.DecryptProperties(item);
  24901. }
  24902. if (groupClientList == null || groupClientList.Count < 1)
  24903. {
  24904. return Ok(JsonView(false, $"团组客户名单未录入客户信息,不可生成相关资料。"));
  24905. }
  24906. #region 生成文件
  24907. //酒店信息
  24908. var hotelInfos = await _sqlSugar.Queryable<Grp_HotelReservations>()
  24909. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  24910. .OrderBy(x => x.CheckInDate)
  24911. .ToListAsync();
  24912. //航班信息
  24913. var airInfos = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  24914. .Where(x => x.IsDel == 0 && x.DIId == groupId)
  24915. .OrderBy(x => x.FlightsDate)
  24916. .ToListAsync();
  24917. foreach (var clientInfo in groupClientList)
  24918. {
  24919. var clientId = clientInfo.DcId;
  24920. var guestName = $"{clientInfo.LastName}{clientInfo.FirstName}";
  24921. #region 个人信息资料
  24922. #endregion
  24923. #region 机票航班信息
  24924. var clientAirInfos = airInfos.Where(x => x.ClientName.Contains(clientId.ToString())).ToList();
  24925. if (clientAirInfos != null && clientAirInfos.Count > 0)
  24926. {
  24927. //创建表格
  24928. Document airDoc = new Document();
  24929. DocumentBuilder airBuilder = new DocumentBuilder(airDoc);
  24930. GeneralMethod.SetupDocumentStyles(airBuilder);
  24931. GeneralMethod.AddTitle(airBuilder, $"{guestName} - 机票信息");
  24932. GeneralMethod.AddAirInfoSections(airBuilder, clientAirInfos, "机票航班信息");
  24933. var airRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24934. var airFileName = $"{guestName}_机票信息_{airRandomStr}.docx";
  24935. airDoc.Save($"{path}/{airFileName}");
  24936. }
  24937. #endregion
  24938. #region 酒店信息
  24939. var clientHotelInfos = hotelInfos.Where(x => x.GuestName.Contains(clientId.ToString())).ToList();
  24940. if (clientHotelInfos != null && clientHotelInfos.Count > 0)
  24941. {
  24942. //创建表格
  24943. Document hotelDoc = new Document();
  24944. DocumentBuilder HotelBuilder = new DocumentBuilder(hotelDoc);
  24945. GeneralMethod.SetupDocumentStyles(HotelBuilder);
  24946. GeneralMethod.AddTitle(HotelBuilder, $"{guestName} - 酒店信息");
  24947. GeneralMethod.AddHotelInfoSections(HotelBuilder, clientHotelInfos, "酒店信息");
  24948. var hotelRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  24949. var hotelFileName = $"{guestName}_酒店信息_{hotelRandomStr}.docx";
  24950. hotelDoc.Save($"{path}/{hotelFileName}");
  24951. }
  24952. #endregion
  24953. }
  24954. #endregion
  24955. //打包文件夹
  24956. var sourceDirectory = $"{sourceDirectoryPath}/{dirName}";
  24957. var zipFilePath = $"{sourceDirectoryPath}/{dirName}.zip";
  24958. if (System.IO.File.Exists(zipFilePath))
  24959. {
  24960. System.IO.File.Delete(zipFilePath);
  24961. }
  24962. ZipFile.CreateFromDirectory(sourceDirectory, zipFilePath, CompressionLevel.Fastest, false);
  24963. // 等待并验证
  24964. await Task.Delay(100); // 给系统时间完成文件操作
  24965. if (System.IO.File.Exists(zipFilePath))
  24966. {
  24967. var fileInfo = new FileInfo(zipFilePath);
  24968. var url = $"{rootRrl}Office/GrpFile/VisaProcessFiles/{groupName}/{dirName}.zip";
  24969. //记录下载日志
  24970. await _visaProcessRep.LogOperationAsync(null, null, "Download", currUserId);
  24971. return Ok(JsonView(StatusCodes.Status200OK, "操作成功!", url));
  24972. }
  24973. return Ok(JsonView(false));
  24974. }
  24975. /// <summary>
  24976. /// 团组签证流程 - 根据步骤记录ID获取该步骤的所有操作日志
  24977. /// </summary>
  24978. /// <returns></returns>
  24979. [HttpGet]
  24980. public async Task<IActionResult> VisaProcessLogByStepId(int stepId)
  24981. {
  24982. //参数验证
  24983. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == stepId && x.IsDel == 0).FirstAsync();
  24984. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  24985. var logs = await _visaProcessRep.GetStepLogsAsync(stepId);
  24986. return Ok(JsonView(logs));
  24987. }
  24988. /// <summary>
  24989. /// 团组签证流程 - 根据团组ID获取该团组下所有步骤的操作日志
  24990. /// </summary>
  24991. /// <returns></returns>
  24992. [HttpGet]
  24993. public async Task<IActionResult> VisaProcessLogByGroupId(int groupId)
  24994. {
  24995. //参数验证
  24996. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.GroupId == groupId && x.IsDel == 0).FirstAsync();
  24997. if (stepValid == null) return Ok(JsonView(false, "团组ID无效。"));
  24998. var logs = await _visaProcessRep.GetGroupStepLogsAsync(groupId);
  24999. return Ok(JsonView(logs));
  25000. }
  25001. #endregion
  25002. #region 团组总览进程
  25003. /// <summary>
  25004. /// 团组总览进程 - 流程创建测试
  25005. /// </summary>
  25006. /// <returns></returns>
  25007. [HttpGet]
  25008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25009. public async Task<IActionResult> GroupProcessInitTest(int groupId,int currUserId)
  25010. {
  25011. return Ok(await _processOverviewRep.ProcessInitAsync(groupId, currUserId));
  25012. }
  25013. /// <summary>
  25014. /// 团组总览进程 - 团组名称集合
  25015. /// </summary>
  25016. /// <returns></returns>
  25017. [HttpGet]
  25018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25019. public async Task<IActionResult> GroupProcessGroupNames()
  25020. {
  25021. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  25022. .Where(x => x.IsDel == 0)
  25023. .OrderByDescending(x => x.VisitDate)
  25024. .Select(x => new
  25025. {
  25026. x.Id,
  25027. GroupName = x.TeamName,
  25028. HasProcess = SqlFunc.Subqueryable<Grp_ProcessOverview>()
  25029. .Where(po => po.GroupId == x.Id && po.IsDel == 0)
  25030. .Any()
  25031. })
  25032. .ToListAsync();
  25033. return Ok(JsonView(groupNames));
  25034. }
  25035. /// <summary>
  25036. /// 团组总览进程 - 流程详情
  25037. /// </summary>
  25038. /// <returns></returns>
  25039. [HttpGet]
  25040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25041. public async Task<IActionResult> GroupProcessDetails(int groupId)
  25042. {
  25043. var res = await _processOverviewRep.ProcessesDetailsAsync(groupId);
  25044. if (res.Code == StatusCodes.Status200OK)
  25045. {
  25046. return Ok(JsonView(res.Data));
  25047. }
  25048. return Ok(JsonView(false, res.Msg));
  25049. }
  25050. /// <summary>
  25051. /// 团组总览进程 - 更新节点状态
  25052. /// </summary>
  25053. /// <returns></returns>
  25054. [HttpPost]
  25055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25056. public async Task<IActionResult> GroupProcessUpdateNodeStatus(GroupProcessUpdateNodeStatusDto dto)
  25057. {
  25058. var res = await _processOverviewRep.UpdateNodeStatusAsync(dto.NodeId, dto.CurrUserId);
  25059. if (res.Code == StatusCodes.Status200OK)
  25060. {
  25061. return Ok(JsonView(res.Data));
  25062. }
  25063. return Ok(JsonView(false, res.Msg));
  25064. }
  25065. /// <summary>
  25066. /// 团组总览进程 - 更新签证节点信息
  25067. /// </summary>
  25068. /// <returns></returns>
  25069. [HttpPost]
  25070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25071. public async Task<IActionResult> GroupProcessUpdateVisaNodeDetails(GroupProcessUpdateVisaNodeDetailsDto dto)
  25072. {
  25073. //验证签证信息
  25074. if (dto.VisaSubNodes.Count < 1) return Ok(JsonView(false, "请传入有效的签证节点信息。"));
  25075. var res = await _processOverviewRep.UpdateVisaNodeDetailsAsync(dto);
  25076. if (res.Code == StatusCodes.Status200OK)
  25077. {
  25078. return Ok(JsonView(res.Data));
  25079. }
  25080. return Ok(JsonView(false, res.Msg));
  25081. }
  25082. #endregion
  25083. /// <summary>
  25084. /// 123132123
  25085. /// </summary>
  25086. /// <param name="_dto"></param>
  25087. /// <returns></returns>
  25088. [HttpPost]
  25089. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25090. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  25091. {
  25092. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  25093. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  25094. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  25095. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  25096. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  25097. dicDetail.Add(789, 1034);
  25098. dicDetail.Add(790, 1035);
  25099. dicDetail.Add(791, 1036);
  25100. dicDetail.Add(792, 1037);
  25101. dicDetail.Add(793, 1038);
  25102. dicDetail.Add(794, 1039);
  25103. dicDetail.Add(795, 1040);
  25104. dicDetail.Add(796, 1041);
  25105. dicDetail.Add(797, 1042);
  25106. dicDetail.Add(798, 1043);
  25107. dicDetail.Add(801, 1044);
  25108. dicDetail.Add(802, 1045);
  25109. dicDetail.Add(803, 1046);
  25110. Dictionary<int, int> dic = new Dictionary<int, int>();
  25111. dic.Add(806, 1027);
  25112. dic.Add(807, 1028);
  25113. dic.Add(808, 1029);
  25114. dic.Add(809, 1030);
  25115. dic.Add(810, 1031);
  25116. dic.Add(811, 1032);
  25117. dic.Add(812, 1033);
  25118. foreach (var item in list_visa)
  25119. {
  25120. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  25121. temp.Coefficient = item.coefficient;
  25122. DateTime dtCrt;
  25123. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  25124. if (b1)
  25125. {
  25126. temp.CreateTime = dtCrt;
  25127. }
  25128. else
  25129. {
  25130. temp.CreateTime = DateTime.Now;
  25131. }
  25132. temp.CreateUserId = item.Operators;
  25133. temp.DeleteTime = "";
  25134. temp.DeleteUserId = 0;
  25135. temp.DiId = int.Parse(item.DIID);
  25136. temp.FilePath = item.FilePath;
  25137. temp.IsDel = item.IsDel;
  25138. temp.Price = item.Price;
  25139. temp.PriceCount = 1;
  25140. temp.PriceCurrency = item.Currency;
  25141. int detailId = 0;
  25142. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  25143. {
  25144. detailId = dicDetail[item.PriceTypeDetail];
  25145. }
  25146. temp.PriceDetailType = detailId;
  25147. temp.PriceDt = DateTime.Now;
  25148. temp.PriceName = item.PriceName;
  25149. temp.PriceSum = item.Price;
  25150. int tid = 0;
  25151. if (dic.ContainsKey(item.PriceType))
  25152. {
  25153. tid = dic[item.PriceType];
  25154. }
  25155. temp.PriceType = tid;
  25156. temp.Remark = item.Remark;
  25157. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  25158. }
  25159. return Ok(JsonView(true, "操作成功!"));
  25160. }
  25161. [HttpPost]
  25162. public IActionResult TimeTest()
  25163. {
  25164. var jw = JsonView(false, "error");
  25165. _sqlSugar.BeginTran();
  25166. try
  25167. {
  25168. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  25169. .Select(x => new Crm_NewClientData
  25170. {
  25171. Id = x.Id,
  25172. Client = x.Client,
  25173. Contact = x.Contact,
  25174. Location = x.Location,
  25175. })
  25176. .ToList();
  25177. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  25178. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  25179. Stopwatch stopwatch = new Stopwatch();
  25180. // 开始计时
  25181. stopwatch.Start();
  25182. foreach (var item in clientList)
  25183. {
  25184. EncryptionProcessor.DecryptProperties(item);
  25185. }
  25186. stopwatch.Stop();
  25187. jw.Code = 200;
  25188. jw.Data = stopwatch.ElapsedMilliseconds;
  25189. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  25190. }
  25191. catch (Exception ex)
  25192. {
  25193. jw.Code = 400;
  25194. jw.Msg = ex.Message;
  25195. }
  25196. return Ok(jw);
  25197. }
  25198. [HttpPost]
  25199. public async Task<IActionResult> TimeTest1()
  25200. {
  25201. var infos = await _sqlSugar.Queryable<Crm_DeleClient>().ToListAsync();
  25202. return Ok(infos);
  25203. }
  25204. }
  25205. }