GroupsController.cs 1.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497
  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 iTextSharp.text.pdf;
  9. using k8s.KubeConfigModels;
  10. using Microsoft.AspNetCore.Routing.Template;
  11. using Microsoft.AspNetCore.SignalR;
  12. using NPOI.SS.Formula.Functions;
  13. using NPOI.SS.UserModel;
  14. using NPOI.SS.Util;
  15. using NPOI.Util;
  16. using NPOI.XSSF.UserModel;
  17. using OASystem.API.Middlewares;
  18. using OASystem.API.OAMethodLib;
  19. using OASystem.API.OAMethodLib.APNs;
  20. using OASystem.API.OAMethodLib.DeepSeekAPI;
  21. using OASystem.API.OAMethodLib.File;
  22. using OASystem.API.OAMethodLib.GenericSearch;
  23. using OASystem.API.OAMethodLib.Hub.HubClients;
  24. using OASystem.API.OAMethodLib.Hub.Hubs;
  25. using OASystem.API.OAMethodLib.JuHeAPI;
  26. using OASystem.API.OAMethodLib.KiMiApi;
  27. using OASystem.API.OAMethodLib.Logging;
  28. using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
  29. using OASystem.Domain.AesEncryption;
  30. using OASystem.Domain.Attributes;
  31. using OASystem.Domain.Dtos.CRM;
  32. using OASystem.Domain.Dtos.FileDto;
  33. using OASystem.Domain.Dtos.Financial;
  34. using OASystem.Domain.Dtos.Groups;
  35. using OASystem.Domain.Dtos.PersonnelModule;
  36. using OASystem.Domain.Dtos.System;
  37. using OASystem.Domain.Entities.Customer;
  38. using OASystem.Domain.Entities.Financial;
  39. using OASystem.Domain.Entities.Groups;
  40. using OASystem.Domain.ViewModels.CRM;
  41. using OASystem.Domain.ViewModels.Financial;
  42. using OASystem.Domain.ViewModels.Groups;
  43. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  44. using OASystem.Domain.ViewModels.OCR;
  45. using OASystem.Domain.ViewModels.SmallFun;
  46. using OASystem.Infrastructure.Repositories.CRM;
  47. using OASystem.Infrastructure.Repositories.Financial;
  48. using OASystem.Infrastructure.Repositories.Groups;
  49. using OASystem.Infrastructure.Tools;
  50. using OASystem.RedisRepository;
  51. using Quartz.Logging;
  52. using Quartz.Util;
  53. using SQLitePCL;
  54. using SqlSugar;
  55. using SqlSugar.Extensions;
  56. using System.Collections;
  57. using System.ComponentModel.DataAnnotations;
  58. using System.Data;
  59. using System.Diagnostics;
  60. using System.Globalization;
  61. using System.IO;
  62. using System.IO.Compression;
  63. using System.Linq.Expressions;
  64. using System.Security.Cryptography.Xml;
  65. using System.Text.Json;
  66. using System.Text.RegularExpressions;
  67. using System.Threading.Tasks;
  68. using System.Web;
  69. using static OASystem.API.OAMethodLib.JWTHelper;
  70. using static OASystem.Infrastructure.Repositories.Groups.AirTicketResRepository;
  71. using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
  72. using Bookmark = Aspose.Words.Bookmark;
  73. using Cell = Aspose.Words.Tables.Cell;
  74. using Table = Aspose.Words.Tables.Table;
  75. namespace OASystem.API.Controllers
  76. {
  77. /// <summary>
  78. /// 团组相关
  79. /// </summary>
  80. //[Authorize]
  81. [Route("api/[controller]/[action]")]
  82. public class GroupsController : ControllerBase
  83. {
  84. private readonly ILogger<GroupsController> _logger;
  85. private readonly ITextFileLogger _eec_textLogger;
  86. private readonly IGroupTextFileLogger _groupTextLogger;
  87. private readonly GrpScheduleRepository _grpScheduleRep;
  88. private readonly IMapper _mapper;
  89. private readonly DelegationInfoRepository _groupRepository;
  90. private readonly TaskAssignmentRepository _taskAssignmentRep;
  91. private readonly AirTicketResRepository _airTicketResRep;
  92. private readonly DecreasePaymentsRepository _decreasePaymentsRep;
  93. private readonly InvitationOfficialActivitiesRepository _InvitationOfficialActivitiesRep;
  94. private readonly DelegationEnDataRepository _delegationEnDataRep;
  95. private readonly DelegationVisaRepository _delegationVisaRep;
  96. private readonly VisaPriceRepository _visaPriceRep;
  97. private readonly CarTouristGuideGroundRepository _carTouristGuideGroundRep;
  98. private readonly HotelPriceRepository _hotelPriceRep;
  99. private readonly CustomersRepository _customersRep;
  100. private readonly MessageRepository _message;
  101. private readonly SqlSugarClient _sqlSugar;
  102. private readonly TourClientListRepository _tourClientListRep;
  103. private readonly TeamRateRepository _teamRateRep;
  104. #region 成本相关
  105. private readonly CheckBoxsRepository _checkBoxs;
  106. private readonly GroupCostRepository _GroupCostRepository;
  107. private readonly CostTypeHotelNumberRepository _CostTypeHotelNumberRepository;
  108. private readonly GroupCostParameterRepository _GroupCostParameterRepository;
  109. #endregion
  110. private readonly SetDataRepository _setDataRep;
  111. private string url;
  112. private string path;
  113. private readonly EnterExitCostRepository _enterExitCostRep;
  114. private readonly IHubContext<ChatHub, IChatClient> _hubContext;
  115. private readonly UsersRepository _usersRep;
  116. private readonly IJuHeApiService _juHeApi;
  117. private readonly InvertedListRepository _invertedListRep;
  118. private readonly VisaFeeInfoRepository _visaFeeInfoRep;
  119. private readonly TicketBlackCodeRepository _ticketBlackCodeRep;
  120. private readonly ThreeCodeRepository _threeCodeRepository;
  121. private readonly HotelInquiryRepository _hotelInquiryRep;
  122. private readonly FeeAuditRepository _feeAuditRep;
  123. private readonly VisaCommissionRepository _visaCommissionRep;
  124. private readonly ForeignReceivablesRepository _ffrRep; //对外收款账单仓库
  125. private readonly OpinionaireRepository _opinionaireRep; //对外收款账单仓库
  126. private readonly List<CurrencyInfo> _currencyInit;
  127. private readonly List<int> _portTypeData;
  128. private readonly TableOperationRecordRepository _tableorRep;
  129. private readonly EnterExitCostDraftRepository _enterExitCostDraftRep;
  130. private readonly RestaurantRepository _restaurantRep;
  131. private readonly EnterExitCostQuoteRepository _enterExitCostQuoteRep;
  132. private readonly GroupOrderPreInfoRepository _grpOrderPreInfoRep;
  133. private readonly VisaProcessRepository _visaProcessRep;
  134. private readonly ProcessOverviewRepository _processOverviewRep;
  135. private readonly IDeepSeekService _deepSeekService;
  136. private readonly DynamicSearchService<Grp_DelegationInfo> _groupSearchService;
  137. /// <summary>
  138. /// 初始化岗位对应负责的数据类型
  139. ///
  140. /// 岗位ID
  141. /// 24 机票、25 酒店、26 签证、27 商邀、28 OP
  142. ///
  143. /// 费用类型ID
  144. /// 76 酒店预订、79 车/导游地接、80 签证、81 邀请/公务活动、82 团组客户保险、85 机票预订、98 其他款项
  145. /// </summary>
  146. private readonly Dictionary<int, List<int>> _dataInit = new() {
  147. { 24, new List<int> { 85 } }, // 机票 -> 机票预订
  148. { 25, new List<int> { 76 } }, // 酒店 -> 酒店预订
  149. { 26, new List<int> { 80, 82 } }, // 签证 -> 签证, 团组客户保险
  150. { 27, new List<int> { 81 } }, // 地接 -> 邀请/公务活动
  151. { 28, new List<int> { 79 } } // 商邀 -> 车/导游地接
  152. };
  153. /// <summary>
  154. /// 构造函数
  155. /// </summary>
  156. /// <param name="logger"></param>
  157. /// <param name="eec_textLogger"></param>
  158. /// <param name="groupTextLogger"></param>
  159. /// <param name="mapper"></param>
  160. /// <param name="hubContext"></param>
  161. /// <param name="sqlSugar"></param>
  162. /// <param name="grpScheduleRep"></param>
  163. /// <param name="groupRepository"></param>
  164. /// <param name="taskAssignmentRep"></param>
  165. /// <param name="airTicketResRep"></param>
  166. /// <param name="decreasePaymentsRep"></param>
  167. /// <param name="InvitationOfficialActivitiesRep"></param>
  168. /// <param name="delegationEnDataRep"></param>
  169. /// <param name="enterExitCostRep"></param>
  170. /// <param name="delegationVisaRep"></param>
  171. /// <param name="message"></param>
  172. /// <param name="visaPriceRep"></param>
  173. /// <param name="carTouristGuideGroundRep"></param>
  174. /// <param name="checkBoxs"></param>
  175. /// <param name="GroupCostRepository"></param>
  176. /// <param name="CostTypeHotelNumberRepository"></param>
  177. /// <param name="GroupCostParameterRepository"></param>
  178. /// <param name="hotelPriceRep"></param>
  179. /// <param name="customersRep"></param>
  180. /// <param name="setDataRep"></param>
  181. /// <param name="tourClientListRep"></param>
  182. /// <param name="teamRateRep"></param>
  183. /// <param name="usersRep"></param>
  184. /// <param name="juHeApi"></param>
  185. /// <param name="invertedListRep"></param>
  186. /// <param name="visaFeeInfoRep"></param>
  187. /// <param name="ticketBlackCodeRep"></param>
  188. /// <param name="hotelInquiryRep"></param>
  189. /// <param name="threeCodeRepository"></param>
  190. /// <param name="feeAuditRep"></param>
  191. /// <param name="visaCommissionRep"></param>
  192. /// <param name="ffrRep"></param>
  193. /// <param name="opinionaireRep"></param>
  194. /// <param name="tableorRep"></param>
  195. /// <param name="enterExitCostDraftRep"></param>
  196. /// <param name="restaurantRep"></param>
  197. /// <param name="enterExitCostQuoteRep"></param>
  198. /// <param name="grpOrderPreInfoRep"></param>
  199. /// <param name="visaProcessRep"></param>
  200. /// <param name="processOverviewRep"></param>
  201. public GroupsController(
  202. ILogger<GroupsController> logger,
  203. ITextFileLogger eec_textLogger,
  204. IGroupTextFileLogger groupTextLogger,
  205. IMapper mapper,
  206. IHubContext<ChatHub, IChatClient> hubContext,
  207. SqlSugarClient sqlSugar,
  208. GrpScheduleRepository grpScheduleRep,
  209. DelegationInfoRepository groupRepository,
  210. TaskAssignmentRepository taskAssignmentRep,
  211. AirTicketResRepository airTicketResRep,
  212. DecreasePaymentsRepository decreasePaymentsRep,
  213. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  214. DelegationEnDataRepository delegationEnDataRep,
  215. EnterExitCostRepository enterExitCostRep,
  216. DelegationVisaRepository delegationVisaRep,
  217. MessageRepository message,
  218. VisaPriceRepository visaPriceRep,
  219. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  220. CheckBoxsRepository checkBoxs,
  221. GroupCostRepository GroupCostRepository,
  222. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  223. GroupCostParameterRepository GroupCostParameterRepository,
  224. HotelPriceRepository hotelPriceRep,
  225. CustomersRepository customersRep,
  226. SetDataRepository setDataRep,
  227. TourClientListRepository tourClientListRep,
  228. TeamRateRepository teamRateRep,
  229. UsersRepository usersRep,
  230. IJuHeApiService juHeApi,
  231. InvertedListRepository invertedListRep,
  232. VisaFeeInfoRepository visaFeeInfoRep,
  233. TicketBlackCodeRepository ticketBlackCodeRep,
  234. HotelInquiryRepository hotelInquiryRep,
  235. ThreeCodeRepository threeCodeRepository,
  236. FeeAuditRepository feeAuditRep,
  237. VisaCommissionRepository visaCommissionRep,
  238. ForeignReceivablesRepository ffrRep,
  239. OpinionaireRepository opinionaireRep,
  240. TableOperationRecordRepository tableorRep,
  241. EnterExitCostDraftRepository enterExitCostDraftRep,
  242. RestaurantRepository restaurantRep,
  243. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  244. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  245. VisaProcessRepository visaProcessRep,
  246. ProcessOverviewRepository processOverviewRep,
  247. DynamicSearchService<Grp_DelegationInfo> groupSearchService
  248. )
  249. {
  250. _logger = logger;
  251. _eec_textLogger = eec_textLogger;
  252. _groupTextLogger = groupTextLogger;
  253. _mapper = mapper;
  254. _grpScheduleRep = grpScheduleRep;
  255. _groupRepository = groupRepository;
  256. _taskAssignmentRep = taskAssignmentRep;
  257. _airTicketResRep = airTicketResRep;
  258. _sqlSugar = sqlSugar;
  259. url = AppSettingsHelper.Get("ExcelBaseUrl");
  260. path = AppSettingsHelper.Get("ExcelBasePath");
  261. if (!System.IO.Directory.Exists(path))
  262. {
  263. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  264. }
  265. _decreasePaymentsRep = decreasePaymentsRep;
  266. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  267. _delegationEnDataRep = delegationEnDataRep;
  268. _enterExitCostRep = enterExitCostRep;
  269. _delegationVisaRep = delegationVisaRep;
  270. _message = message;
  271. _visaPriceRep = visaPriceRep;
  272. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  273. _checkBoxs = checkBoxs;
  274. _GroupCostRepository = GroupCostRepository;
  275. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  276. _GroupCostParameterRepository = GroupCostParameterRepository;
  277. _hotelPriceRep = hotelPriceRep;
  278. _customersRep = customersRep;
  279. _setDataRep = setDataRep;
  280. _tourClientListRep = tourClientListRep;
  281. _teamRateRep = teamRateRep;
  282. _hubContext = hubContext;
  283. _usersRep = usersRep;
  284. _juHeApi = juHeApi;
  285. _invertedListRep = invertedListRep;
  286. _visaFeeInfoRep = visaFeeInfoRep;
  287. _ticketBlackCodeRep = ticketBlackCodeRep;
  288. _hotelInquiryRep = hotelInquiryRep;
  289. _threeCodeRepository = threeCodeRepository;
  290. _feeAuditRep = feeAuditRep;
  291. _visaCommissionRep = visaCommissionRep;
  292. _ffrRep = ffrRep;
  293. _opinionaireRep = opinionaireRep;
  294. _currencyInit = new List<CurrencyInfo>()
  295. {
  296. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  297. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  298. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  299. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  300. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  301. };
  302. _portTypeData = new List<int>() { 2, 3 };
  303. _tableorRep = tableorRep;
  304. _enterExitCostDraftRep = enterExitCostDraftRep;
  305. _restaurantRep = restaurantRep;
  306. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  307. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  308. _visaProcessRep = visaProcessRep;
  309. _processOverviewRep = processOverviewRep;
  310. _groupSearchService = groupSearchService;
  311. }
  312. #region 页面加载弹窗信息
  313. /// <summary>
  314. /// 提示用户录入团组费用信息
  315. /// 根据用户ID获取分配权限内团组名称
  316. /// </summary>
  317. /// <param name="currUserId">用户Id</param>
  318. /// <param name="daysAgo">往前推的天数</param>
  319. /// <returns></returns>
  320. [HttpGet]
  321. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  322. public async Task<IActionResult> GetGroupNamesByUserId(int currUserId, int daysAgo = 5)
  323. {
  324. var stopwatch = Stopwatch.StartNew();
  325. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  326. .Where(x => x.Id == currUserId && x.IsDel == 0)
  327. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  328. .FirstAsync();
  329. if (userInfo == null)
  330. {
  331. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  332. }
  333. var jobId = userInfo.JobPostId;
  334. var feeTypeIds = new List<int>() { };
  335. if (_dataInit.TryGetValue(jobId, out var values))
  336. {
  337. feeTypeIds = values;
  338. }
  339. /*
  340. * 获取今天时间往前推5天查询团组c表里有没有费用
  341. */
  342. var today_startDate = DateTime.Now.Date.AddDays(-daysAgo);
  343. //var today_endDate = DateTime.Now.Date.AddDays(-daysAgo).AddDays(1).AddSeconds(-1);
  344. var today_endDate = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  345. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  346. .Where(di => di.IsDel == 0)
  347. .Where(di => di.VisitDate >= today_startDate && di.VisitDate <= today_endDate)
  348. // 存在任务分配记录
  349. .Where(di => SqlFunc.Subqueryable<Grp_GroupsTaskAssignment>()
  350. .Where(gta => gta.DIId == di.Id && gta.IsDel == 0 && feeTypeIds.Contains(gta.CTId))
  351. .Any())
  352. // 不存在费用记录
  353. .Where(di => !SqlFunc.Subqueryable<Grp_CreditCardPayment>()
  354. .Where(ccp => ccp.DIId == di.Id && ccp.IsDel == 0 && feeTypeIds.Contains(ccp.CTable))
  355. .Any())
  356. // 新增条件:不在确认记录表中(排除已确认的团组)
  357. .Where(di => !SqlFunc.Subqueryable<Grp_FeeEntryAcknowledge>()
  358. .Where(ack => ack.GroupId == di.Id && ack.IsDel == 0 && ack.UserId == currUserId)
  359. .Where(ack => feeTypeIds.Contains(ack.FeeTypeId))
  360. .Where(ack => ack.IsAcknowledged == AcknowledgeStatusEnum.Acknowledged) // 只排除已确认的记录
  361. .Any())
  362. .Select(di => new
  363. {
  364. di.Id,
  365. di.TeamName,
  366. di.VisitDate
  367. })
  368. .OrderBy(di => di.VisitDate)
  369. .ToListAsync();
  370. stopwatch.Stop();
  371. return Ok(JsonView(true, $"操作成功!【耗时:{stopwatch.ElapsedMilliseconds}ms】", new
  372. {
  373. isTips = groupNames.Any(),
  374. groupNames = groupNames.Select(x => new { x.Id, GroupName = x.TeamName, x.VisitDate }).ToList()
  375. }));
  376. }
  377. /// <summary>
  378. /// 提示用户录入团组费用信息
  379. /// 已知晓确认操作记录(添加) 批量
  380. /// </summary>
  381. /// <param name="dto">请求体</param>
  382. /// <returns></returns>
  383. [HttpPost]
  384. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  385. public async Task<IActionResult> FeeEntryAcknowledgeCrate(FeeEntryAcknowledgeCrateDto dto)
  386. {
  387. // 1. 参数验证
  388. if (dto?.GroupIds == null || !dto.GroupIds.Any())
  389. return Ok(JsonView(false, "请选择需要确认的团组!"));
  390. if (dto.GroupIds.Count > 100)
  391. return Ok(JsonView(false, "一次性确认团组数量不能超过100个!"));
  392. if (dto.CurrUserId <= 0)
  393. return Ok(JsonView(false, "用户ID无效!"));
  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. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  401. // 3. 获取费用类型
  402. if (!_dataInit.TryGetValue(userInfo.JobPostId, out var feeTypeIds) || feeTypeIds?.Count == 0)
  403. return Ok(JsonView(false, "当前用户岗位无对应的费用类型配置!"));
  404. // 4. 验证团组存在性
  405. var validGroupIds = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  406. .Where(x => dto.GroupIds.Contains(x.Id) && x.IsDel == 0)
  407. .Select(x => x.Id)
  408. .ToListAsync();
  409. if (!validGroupIds.Any())
  410. return Ok(JsonView(false, "未找到有效的团组信息!"));
  411. // 5. 检查团组费用表中是否存在对应费用类型的数据
  412. var existingFeeRecords = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  413. .Where(x => validGroupIds.Contains(x.DIId) && x.IsDel == 0)
  414. .Where(x => feeTypeIds.Contains(x.CTable))
  415. .Select(x => new { GroupId = x.DIId, FeeTypeId = x.CTable })
  416. .ToListAsync();
  417. if (existingFeeRecords.Count > 0)
  418. {
  419. // 找出有问题的团组和费用类型
  420. var problematicGroups = existingFeeRecords
  421. .GroupBy(x => x.GroupId)
  422. .Select(g => new
  423. {
  424. GroupId = g.Key,
  425. FeeTypeIds = string.Join(",", g.Select(x => x.FeeTypeId).Distinct())
  426. })
  427. .ToList();
  428. var errorMessage = $"以下团组的费用表中已存在费用数据,不可添加确认记录:";
  429. foreach (var group in problematicGroups)
  430. {
  431. errorMessage += $"\n团组 {group.GroupId} - 费用类型ID: [{group.FeeTypeIds}]";
  432. }
  433. return Ok(JsonView(false, errorMessage));
  434. }
  435. // 6. 检查是否已存在确认记录(避免重复确认)
  436. var existingAcknowledgeRecords = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  437. .Where(x => x.UserId == dto.CurrUserId && x.IsDel == 0)
  438. .Where(x => validGroupIds.Contains(x.GroupId))
  439. .Where(x => feeTypeIds.Contains(x.FeeTypeId))
  440. .Select(x => new { x.GroupId, x.FeeTypeId })
  441. .ToListAsync();
  442. // 7. 准备插入数据(过滤已存在的记录)
  443. var recordsToInsert = new List<Grp_FeeEntryAcknowledge>();
  444. foreach (var groupId in validGroupIds)
  445. {
  446. foreach (var feeTypeId in feeTypeIds)
  447. {
  448. // 检查是否已存在相同记录
  449. var exists = existingAcknowledgeRecords.Any(x => x.GroupId == groupId && x.FeeTypeId == feeTypeId);
  450. if (!exists)
  451. {
  452. recordsToInsert.Add(new Grp_FeeEntryAcknowledge()
  453. {
  454. GroupId = groupId,
  455. UserId = dto.CurrUserId,
  456. JobPostId = userInfo.JobPostId,
  457. FeeTypeId = feeTypeId,
  458. IsAcknowledged = Domain.Enums.AcknowledgeStatusEnum.Acknowledged,
  459. AcknowledgeTime = DateTime.Now,
  460. AcknowledgeType = Domain.Enums.AcknowledgeTypeEnum.WebConfirm,
  461. CreateUserId = 4, // 系统创建
  462. CreateTime = DateTime.Now
  463. });
  464. }
  465. }
  466. }
  467. if (!recordsToInsert.Any())
  468. return Ok(JsonView(true, "所选团组已确认,无需重复操作!"));
  469. // 8. 批量插入数据
  470. var successCount = await _sqlSugar.Insertable(recordsToInsert).ExecuteCommandAsync();
  471. if (successCount <= 0)
  472. return Ok(JsonView(false, "操作失败,未能保存确认记录!"));
  473. // 9. 记录操作日志
  474. _logger.LogInformation("用户 {UserName}(ID:{UserId}) 批量确认了 {GroupCount} 个团组的费用类型,共添加 {RecordCount} 条确认记录",
  475. userInfo.CnName, dto.CurrUserId, validGroupIds.Count, successCount);
  476. // 10. 操作成功 返回成功视图
  477. var result = await GetGroupNamesByUserId(dto.CurrUserId, dto.DaysAgo);
  478. if (result is OkObjectResult okObjectResult)
  479. {
  480. return Ok(okObjectResult.Value);
  481. }
  482. //return Ok(result);
  483. return Ok(JsonView(true, $"操作成功!共为 {validGroupIds.Count} 个团组添加了 {successCount} 条确认记录"));
  484. }
  485. /// <summary>
  486. /// 提示用户录入团组费用信息
  487. /// 已知晓确认操作记录(添加) 单个
  488. /// </summary>
  489. /// <param name="dto">请求体</param>
  490. /// <returns></returns>
  491. [HttpPost]
  492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  493. public async Task<IActionResult> FeeEntryAcknowledgeSingleCreate(FeeEntryAcknowledgeSingleDto dto)
  494. {
  495. // 1. 参数验证
  496. if (dto.GroupId <= 0)
  497. return Ok(JsonView(false, "请选择有效的团组ID!"));
  498. if (dto.CurrUserId <= 0)
  499. return Ok(JsonView(false, "用户ID无效!"));
  500. // 2. 验证用户存在性
  501. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  502. .Where(x => x.Id == dto.CurrUserId && x.IsDel == 0)
  503. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  504. .FirstAsync();
  505. if (userInfo == null)
  506. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  507. // 3. 获取费用类型
  508. if (!_dataInit.TryGetValue(userInfo.JobPostId, out var feeTypeIds) || feeTypeIds?.Count == 0)
  509. return Ok(JsonView(false, "当前用户岗位无对应的费用类型配置!"));
  510. // 4. 验证团组存在性
  511. var groupExists = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  512. .AnyAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  513. if (!groupExists)
  514. return Ok(JsonView(false, "未找到有效的团组信息!"));
  515. // 5. 检查团组费用表中是否存在对应费用类型的数据
  516. var existingFeeRecords = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  517. .Where(x => x.DIId == dto.GroupId && x.IsDel == 0)
  518. .Where(x => feeTypeIds.Contains(x.CTable))
  519. .Select(x => new { x.CTable })
  520. .ToListAsync();
  521. if (existingFeeRecords.Count > 0)
  522. {
  523. var existingFeeTypeNames = existingFeeRecords.Select(x => x.CTable).Distinct().ToList();
  524. return Ok(JsonView(false, $"团组费用表中已存在费用类型ID [{string.Join(",", existingFeeTypeNames)}] 的数据,不可添加确认无费用记录!"));
  525. }
  526. // 6. 检查已存在的确认记录
  527. var existingAcknowledgeRecords = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  528. .Where(x => x.UserId == dto.CurrUserId && x.IsDel == 0)
  529. .Where(x => x.GroupId == dto.GroupId)
  530. .Where(x => feeTypeIds.Contains(x.FeeTypeId))
  531. .Select(x => new { x.FeeTypeId })
  532. .ToListAsync();
  533. var existingAcknowledgeFeeTypeIds = existingAcknowledgeRecords.Select(x => x.FeeTypeId).ToHashSet();
  534. // 7. 准备插入数据(过滤已存在的记录)
  535. var recordsToInsert = feeTypeIds
  536. .Where(feeTypeId => !existingAcknowledgeFeeTypeIds.Contains(feeTypeId))
  537. .Select(feeTypeId => new Grp_FeeEntryAcknowledge
  538. {
  539. GroupId = dto.GroupId,
  540. UserId = dto.CurrUserId,
  541. JobPostId = userInfo.JobPostId,
  542. FeeTypeId = feeTypeId,
  543. IsAcknowledged = Domain.Enums.AcknowledgeStatusEnum.Acknowledged,
  544. AcknowledgeTime = DateTime.Now,
  545. AcknowledgeType = Domain.Enums.AcknowledgeTypeEnum.WebConfirm,
  546. CreateUserId = 4, // 系统创建
  547. CreateTime = DateTime.Now
  548. })
  549. .ToList();
  550. if (recordsToInsert.Count == 0)
  551. return Ok(JsonView(true, "所选团组已确认,无需重复操作!"));
  552. // 8. 批量插入数据
  553. var successCount = await _sqlSugar.Insertable(recordsToInsert).ExecuteCommandAsync();
  554. if (successCount <= 0)
  555. return Ok(JsonView(false, "操作失败,未能保存确认记录!"));
  556. // 9. 记录操作日志(可选)
  557. _logger.LogInformation("用户 {UserName}(ID:{UserId}) 确认了团组 {GroupId} 的费用类型",
  558. userInfo.CnName, dto.CurrUserId, dto.GroupId);
  559. return Ok(JsonView(true, $"操作成功!"));
  560. }
  561. #endregion
  562. #region 流程管控
  563. /// <summary>
  564. /// 获取团组流程管控信息
  565. /// </summary>
  566. /// <param name="_jsonDto">查询参数</param>
  567. /// <returns></returns>
  568. [HttpPost]
  569. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  570. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  571. {
  572. if (string.IsNullOrEmpty(_jsonDto.Paras))
  573. {
  574. return Ok(JsonView(false, "参数为空"));
  575. }
  576. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  577. if (_ScheduleDto != null)
  578. {
  579. if (_ScheduleDto.SearchType == 2)//获取列表
  580. {
  581. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  582. return Ok(JsonView(_grpScheduleViewList));
  583. }
  584. else//获取对象
  585. {
  586. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  587. if (_grpScheduleView != null)
  588. {
  589. return Ok(JsonView(_grpScheduleView));
  590. }
  591. }
  592. }
  593. else
  594. {
  595. return Ok(JsonView(false, "参数反序列化失败"));
  596. }
  597. return Ok(JsonView(false, "暂无数据!"));
  598. }
  599. /// <summary>
  600. /// 修改团组流程管控详细表数据
  601. /// </summary>
  602. /// <param name="dto"></param>
  603. /// <returns></returns>
  604. [HttpPost]
  605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  606. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  607. {
  608. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  609. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  610. .SetColumns(it => it.Duty == _detail.Duty)
  611. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  612. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  613. .SetColumns(it => it.JobContent == _detail.JobContent)
  614. .SetColumns(it => it.Remark == _detail.Remark)
  615. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  616. .Where(s => s.Id == dto.Id)
  617. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  618. .ExecuteCommandAsync();
  619. if (result > 0)
  620. {
  621. return Ok(JsonView(true, "保存成功!"));
  622. }
  623. return Ok(JsonView(false, "保存失败!"));
  624. }
  625. /// <summary>
  626. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  627. /// </summary>
  628. /// <param name="dto"></param>
  629. /// <returns></returns>
  630. [HttpPost]
  631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  632. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  633. {
  634. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  635. _detail.IsDel = 1;
  636. _detail.DeleteUserId = dto.Duty;
  637. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  638. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  639. .SetColumns(it => it.IsDel == _detail.IsDel)
  640. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  641. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  642. .Where(it => it.Id == dto.Id)
  643. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  644. //.WhereColumns(s => s.Id == dto.Id)
  645. .ExecuteCommandAsync();
  646. if (result > 0)
  647. {
  648. return Ok(JsonView(true, "删除成功!"));
  649. }
  650. return Ok(JsonView(false, "删除失败!"));
  651. }
  652. /// <summary>
  653. /// 增加团组流程管控详细表数据
  654. /// </summary>
  655. /// <param name="dto"></param>
  656. /// <returns></returns>
  657. [HttpPost]
  658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  659. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  660. {
  661. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  662. if (DateTime.Now < _detail.ExpectBeginDt)
  663. {
  664. _detail.StepStatus = 0;
  665. }
  666. else
  667. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  668. _detail.StepStatus = 1;
  669. }
  670. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  671. if (result > 0)
  672. {
  673. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  674. return Ok(JsonView(true, "添加成功!", _result));
  675. }
  676. return Ok(JsonView(false, "添加失败!"));
  677. }
  678. #endregion
  679. #region 团组前期信息
  680. /// <summary>
  681. /// 团组前期信息H5-URL(员工对应地址)
  682. /// </summary>
  683. /// <param name="name">用户名称</param>
  684. /// <returns></returns>
  685. [HttpGet]
  686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  687. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  688. {
  689. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  690. .Where(x => x.IsDel == 0)
  691. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  692. .OrderBy(x => x.Id)
  693. .Select(x => new
  694. {
  695. name = x.CnName,
  696. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  697. })
  698. .ToListAsync();
  699. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  700. }
  701. /// <summary>
  702. /// 团组前期信息 List
  703. /// </summary>
  704. /// <returns></returns>
  705. [HttpPost]
  706. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  707. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  708. {
  709. var search = dto.Search;
  710. int[] nameTempIds = new int[] { 1, 12, 28 },
  711. countryTempIds = new int[] { 2, 13, 29 },
  712. daysTempIds = new int[] { 4, 15, 31 },
  713. ppNumTempIds = new int[] { 6 };
  714. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  715. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  716. .Where((opi, u) => opi.IsDel == 0)
  717. .OrderByDescending((opi, u) => opi.CreateTime)
  718. .Select((opi, u) => new GroupOrderPreInfoListView()
  719. {
  720. Id = opi.Id,
  721. Name = opi.Name,
  722. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  723. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  724. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  725. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  726. Operator = u.CnName,
  727. OperationTime = opi.CreateTime
  728. })
  729. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  730. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  731. .ToListAsync();
  732. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  733. int total = list.Count;
  734. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  735. var listPageData1 = listPageData
  736. .Skip((dto.PageIndex - 1) * dto.PageSize)
  737. .Take(dto.PageSize)
  738. .ToList();
  739. var infoIds = listPageData1.Select(x => x.Id).ToList();
  740. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  741. .Where(x => x.IsDel == 0 && x.STid == 109)
  742. .ToArrayAsync();
  743. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  744. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  745. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  746. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  747. .ToListAsync();
  748. foreach (var item in listPageData1)
  749. {
  750. var typeDatas1 = typeDatas.Select(x => new
  751. {
  752. x.Id,
  753. x.Name,
  754. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  755. }).ToArray();
  756. item.VersionDetails = typeDatas1;
  757. }
  758. return Ok(JsonView(listPageData1, listPageData1.Count));
  759. }
  760. /// <summary>
  761. /// 团组前期信息 Init
  762. /// </summary>
  763. /// <returns></returns>
  764. [HttpGet("{userId}")]
  765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  766. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  767. {
  768. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  769. }
  770. /// <summary>
  771. /// 国家数据源
  772. /// </summary>
  773. /// <param name="pageIndex">当前页码</param>
  774. /// <param name="pageSize">每页条数</param>
  775. /// <param name="search">查询条件</param>
  776. /// <returns></returns>
  777. [HttpGet]
  778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  779. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  780. {
  781. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  782. if (pageIndex == 0 && pageSize == 0)
  783. {
  784. //所有数据
  785. return Ok(JsonView(countrys, countrys.Count));
  786. }
  787. //分页
  788. int skip = (pageIndex - 1) * pageSize;
  789. int take = pageSize;
  790. if (!string.IsNullOrEmpty(search))
  791. {
  792. IEnumerable<char> charSequence = search.Select(c => c);
  793. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  794. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  795. return Ok(JsonView(pageData, pageResult1.Count));
  796. }
  797. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  798. return Ok(JsonView(pageResult2, countrys.Count));
  799. }
  800. /// <summary>
  801. /// 城市数据源
  802. /// </summary>
  803. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  804. /// <param name="pageIndex">当前页码</param>
  805. /// <param name="pageSize">每页条数</param>
  806. /// <param name="search">查询条件</param>
  807. /// <returns></returns>
  808. [HttpGet("{countryLabel}")]
  809. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  810. public async Task<IActionResult> CityByCountry(
  811. string countryLabel,
  812. [FromQuery] int pageIndex,
  813. [FromQuery] int pageSize,
  814. [FromQuery] string search)
  815. {
  816. countryLabel = HttpUtility.UrlDecode(countryLabel);
  817. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  818. var citys = Array.Empty<string?>();
  819. if (countryList.Any())
  820. {
  821. var cityDatas = await _sqlSugar
  822. .Queryable<Grp_NationalTravelFee>()
  823. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  824. .ToArrayAsync();
  825. foreach (var item in cityDatas)
  826. {
  827. if (item.City.Contains("城市"))
  828. {
  829. item.City = item.Country + "-所有城市";
  830. }
  831. }
  832. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  833. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  834. }
  835. if (pageIndex == 0 && pageSize == 0)
  836. {
  837. //所有数据
  838. return Ok(JsonView(citys, citys?.Length ?? 0));
  839. }
  840. //分页
  841. int skip = (pageIndex - 1) * pageSize;
  842. int take = pageSize;
  843. if (!string.IsNullOrEmpty(search))
  844. {
  845. IEnumerable<char> charSequence = search.Select(c => c);
  846. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  847. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  848. return Ok(JsonView(pageData, pageResult1.Count));
  849. }
  850. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  851. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  852. }
  853. /// <summary>
  854. /// 团组前期信息 Info
  855. /// </summary>
  856. /// <param name="dto">Id</param>
  857. /// <returns></returns>
  858. [HttpGet("{Id}/{TempId}")]
  859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  860. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  861. {
  862. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  863. }
  864. /// <summary>
  865. /// 团组前期信息 移动端 Info
  866. /// </summary>
  867. /// <param name="dto">Id</param>
  868. /// <returns></returns>
  869. [HttpGet("{Id}/{TempId}")]
  870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  871. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  872. {
  873. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  874. }
  875. /// <summary>
  876. /// 团组前期信息 Save
  877. /// </summary>
  878. /// <param name="dto">Id</param>
  879. /// <returns></returns>
  880. [HttpPost]
  881. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  882. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  883. {
  884. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  885. }
  886. /// <summary>
  887. /// 团组前期信息 Del
  888. /// </summary>
  889. /// <param name="dto">Id</param>
  890. /// <returns></returns>
  891. [HttpPost]
  892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  893. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  894. {
  895. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  896. }
  897. /// <summary>
  898. /// 团组前期信息 文件下载
  899. /// </summary>
  900. /// <param name="dto">Id</param>
  901. /// <returns></returns>
  902. [HttpGet("{Id}/{TempId}")]
  903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  904. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  905. {
  906. int id = dto.Id, tempId = dto.TempId;
  907. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  908. var data = view.Data as GrpOrderPreInfoView;
  909. #region Excel
  910. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  911. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  912. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  913. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  914. var fileNamePrefix = string.Empty;
  915. if (tempId == 1405)
  916. {
  917. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  918. fileNamePrefix = $"{data.Name}_无商邀版";
  919. }
  920. else if (tempId == 1406)
  921. {
  922. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  923. fileNamePrefix = $"{data.Name}_有商邀版";
  924. }
  925. else
  926. {
  927. //tempId == 1404 默认下载
  928. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  929. fileNamePrefix = $"{data.Name}_单接送机";
  930. }
  931. foreach (var item in data.Items)
  932. {
  933. var obj = item.NewValue;
  934. if (obj == null) item.OriginVal = "";
  935. else if (obj.Equals("有") || obj.Equals("无"))
  936. {
  937. item.OriginVal = obj.ToString();
  938. }
  939. else if (obj is object[] objArray)
  940. {
  941. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  942. item.OriginVal = string.Join("、", stringArray);
  943. }
  944. else if (obj is string[] stringArray)
  945. {
  946. item.OriginVal = string.Join("、", stringArray);
  947. }
  948. else if (obj.Equals("-"))
  949. {
  950. item.OriginVal = "";
  951. }
  952. }
  953. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  954. fileName = CommonFun.ValidFileName(fileName);
  955. //载入模板
  956. var designer = new WorkbookDesigner
  957. {
  958. Workbook = new Workbook(tempPath)
  959. };
  960. if (tempId == 1406)
  961. {
  962. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  963. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  964. for (int i = 1; i <= view2.Length; i++)
  965. {
  966. view2[i - 1].Index = i;
  967. }
  968. designer.SetDataSource("View1", view1);
  969. designer.SetDataSource("View2", view2);
  970. }
  971. else
  972. {
  973. designer.SetDataSource("View", data.Items);
  974. }
  975. designer.Process();
  976. if (!Directory.Exists(savePath))
  977. {
  978. Directory.CreateDirectory(savePath);
  979. }
  980. string serverPath = $"{savePath}{fileName}";
  981. designer.Workbook.Save(serverPath);
  982. string rst = $"{servicePath}{ftpPath}{fileName}";
  983. #endregion
  984. return Ok(JsonView(new { url = rst }));
  985. }
  986. #endregion
  987. #region 团组基本信息
  988. /// <summary>
  989. /// 接团信息列表
  990. /// </summary>
  991. /// <param name="dto">团组列表请求dto</param>
  992. /// <returns></returns>
  993. [HttpPost]
  994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  995. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  996. {
  997. var groupData = await _groupRepository.GetGroupList(dto);
  998. if (groupData.Code != 0)
  999. {
  1000. return Ok(JsonView(false, groupData.Msg));
  1001. }
  1002. return Ok(JsonView(groupData.Data));
  1003. }
  1004. /// <summary>
  1005. /// 分页查询团组列表
  1006. /// </summary>
  1007. /// <param name="dto"></param>
  1008. /// <returns></returns>
  1009. [HttpPost]
  1010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1011. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  1012. {
  1013. var watch = new Stopwatch();
  1014. watch.Start();
  1015. RefAsync<int> total = 0;
  1016. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1017. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  1018. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  1019. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  1020. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  1021. .Distinct()
  1022. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1023. watch.Stop();
  1024. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  1025. }
  1026. /// <summary>
  1027. /// 接团信息列表 Page Init
  1028. /// </summary>
  1029. /// <returns></returns>
  1030. [HttpPost]
  1031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1032. public async Task<IActionResult> PostGroupPageListInit()
  1033. {
  1034. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  1035. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  1036. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  1037. var _view = new
  1038. {
  1039. depData = depDatas,
  1040. rankData = rankDatas
  1041. };
  1042. return Ok(JsonView(true, "查询成功!", _view));
  1043. }
  1044. /// <summary>
  1045. /// 接团信息列表 关键字输入提示
  1046. /// </summary>
  1047. /// <param name="keyword">关键字</param>
  1048. /// <returns></returns>
  1049. [HttpGet]
  1050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1051. public async Task<IActionResult> GroupItemNativeKeywordSearch (string keyword)
  1052. {
  1053. var jw = JsonView(true, "暂无数据");
  1054. if (string.IsNullOrEmpty(keyword)) return Ok(jw);
  1055. var expression = Expressionable
  1056. .Create<Grp_DelegationInfo>()
  1057. .And(x => x.IsDel == 0);
  1058. string field = "TeamName,ClientUnit,ClientName";
  1059. var groupData = _sqlSugar.Queryable<Grp_DelegationInfo>()
  1060. .Where(expression.ToExpression())
  1061. .Select(field)
  1062. .ToList();
  1063. var keywordArray = keyword.ToCharArray();
  1064. var matches = groupData
  1065. .Where(fullString => !string.IsNullOrWhiteSpace(fullString.TeamName) &&
  1066. keywordArray.All(keyword => fullString.TeamName.Contains(keyword)))
  1067. .Select(x => new
  1068. {
  1069. x.TeamName,
  1070. x.ClientUnit,
  1071. x.ClientName
  1072. })
  1073. .DistinctBy(x => x.TeamName)
  1074. .ToList();
  1075. if (matches.Any())
  1076. {
  1077. jw.Code = StatusCodes.Status200OK;
  1078. jw.Msg = "搜索成功";
  1079. jw.Data = matches;
  1080. jw.Count = matches.Count;
  1081. }
  1082. return Ok(jw);
  1083. }
  1084. /// <summary>
  1085. /// 接团信息列表 关键字输入提示(智能版)
  1086. /// </summary>
  1087. /// <param name="keyword">关键字</param>
  1088. /// <returns></returns>
  1089. [HttpGet]
  1090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1091. public async Task<IActionResult> GroupItemKeywordSearch(string keyword)
  1092. {
  1093. try
  1094. {
  1095. // 验证请求参数
  1096. if (string.IsNullOrEmpty(keyword))
  1097. {
  1098. return Ok(JsonView(true, $"暂无数据!"));
  1099. }
  1100. var searchRequest = new DynamicSearchRequest
  1101. {
  1102. Keyword = keyword,
  1103. RequireAllSingleChars = true,
  1104. PageIndex = 1,
  1105. PageSize = 999999,
  1106. FieldWeights = new Dictionary<string, int>
  1107. {
  1108. { "TeamName", 10 },
  1109. //{ "ClientUnit", 8 },
  1110. //{ "ClientName", 6 }
  1111. },
  1112. Filters = new List<SearchFilter>()
  1113. {
  1114. new(){Field = "IsDel",Operator="eq",Value="0" }
  1115. },
  1116. OrderBy = "TeamName",
  1117. ReturnFields = new List<string>() { "TeamName", "ClientUnit", "ClientName" }
  1118. };
  1119. // 验证字段配置
  1120. var validation = _groupSearchService.ValidateFieldConfig(
  1121. searchRequest.FieldWeights,
  1122. searchRequest.ReturnFields);
  1123. if (!validation.IsValid)
  1124. {
  1125. return Ok(JsonView(true, $"暂无数据!{validation.Message}"));
  1126. }
  1127. var result = await _groupSearchService.SearchAsync(searchRequest);
  1128. if (result.Success)
  1129. {
  1130. var data = new List<dynamic>();
  1131. foreach (var item in result.Items)
  1132. {
  1133. data.Add(new
  1134. {
  1135. item.Data.TeamName,
  1136. item.Data.ClientUnit,
  1137. item.Data.ClientName
  1138. });
  1139. }
  1140. return Ok(JsonView(true, result.Message, data, data.Count));
  1141. }
  1142. return Ok(JsonView(true, result.Message));
  1143. }
  1144. catch (Exception ex)
  1145. {
  1146. return Ok(JsonView(true, $"搜索服务暂时不可用!"));
  1147. }
  1148. }
  1149. /// <summary>
  1150. /// 接团信息列表 Page
  1151. /// </summary>
  1152. /// <param name="dto">团组列表请求dto</param>
  1153. /// <returns></returns>
  1154. [HttpPost]
  1155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1156. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  1157. {
  1158. #region 参数验证
  1159. if (dto.UserId < 1)
  1160. return Ok(JsonView(false, "员工Id为空"));
  1161. if (dto.PageId < 1)
  1162. return Ok(JsonView(false, "页面Id为空"));
  1163. #region 页面操作权限验证
  1164. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1165. if (pageFunAuthView.CheckAuth == 0)
  1166. return Ok(JsonView(false, "您没有查看权限"));
  1167. #endregion
  1168. #endregion
  1169. //if (dto.PortType != 1 && dto.PortType != 2) // web/Android
  1170. // return Ok(JsonView(false, "不支持的端口类型"));
  1171. // 构建查询条件
  1172. var sqlWhereBuilder = new StringBuilder(" WHERE gdi.IsDel = 0");
  1173. var parameters = new List<SugarParameter>();
  1174. // 完成状态筛选
  1175. if (dto.IsSure == 0 || dto.IsSure == 1)
  1176. {
  1177. sqlWhereBuilder.Append(" AND gdi.IsSure = @IsSure");
  1178. parameters.Add(new SugarParameter("@IsSure", dto.IsSure));
  1179. }
  1180. // 搜索条件
  1181. if (!string.IsNullOrWhiteSpace(dto.SearchCriteria))
  1182. {
  1183. var searchParam = $"%{dto.SearchCriteria.Trim()}%";
  1184. sqlWhereBuilder.Append(@"
  1185. AND (ssd.Name LIKE @SearchCriteria
  1186. OR gdi.TeamName LIKE @SearchCriteria
  1187. OR gdi.ClientName LIKE @SearchCriteria
  1188. OR su.CnName LIKE @SearchCriteria)");
  1189. parameters.Add(new SugarParameter("@SearchCriteria", searchParam));
  1190. }
  1191. // 等级筛选
  1192. if (int.TryParse(dto.Rank, out int rankId) && rankId > 0)
  1193. {
  1194. sqlWhereBuilder.Append(" AND gdi.TeamLevSId = @RankId");
  1195. parameters.Add(new SugarParameter("@RankId", rankId));
  1196. }
  1197. // 部门筛选
  1198. var departmentWhere = string.Empty;
  1199. if (!string.IsNullOrWhiteSpace(dto.Department) && !dto.Department.Equals("全部"))
  1200. {
  1201. departmentWhere = " WHERE Department = @Department";
  1202. parameters.Add(new SugarParameter("@Department", dto.Department));
  1203. }
  1204. // 构建SQL查询
  1205. string sql = $@"
  1206. SELECT Row_Number, Id, SalesQuoteNo, TourCode, TeamTypeId, TeamType, Department,
  1207. TeamLevId, TeamLev, TeamName, ClientName, ClientUnit,
  1208. VisitDate, VisitDays, VisitPNumber, JietuanOperatorId,
  1209. JietuanOperator, IsSure, CreateTime, IsBid, Step
  1210. FROM (
  1211. SELECT ROW_NUMBER() OVER(ORDER BY gdi.VisitStartDate DESC) AS Row_Number,
  1212. CASE
  1213. WHEN gdi.JietuanOperator IN (4, 21) THEN '国交部'
  1214. ELSE (SELECT DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId)
  1215. END AS 'Department',
  1216. gdi.Id, SalesQuoteNo, TourCode, ssd.Id AS TeamTypeId, ssd.Name AS TeamType, gdi.Step,
  1217. ssd1.Id AS TeamLevId, ssd1.Name AS TeamLev, TeamName, ClientName, ClientUnit,
  1218. VisitDate, VisitDays, VisitPNumber, JietuanOperator AS JietuanOperatorId,
  1219. su.CnName AS JietuanOperator, IsSure, gdi.CreateTime, gdi.IsBid
  1220. FROM Grp_DelegationInfo gdi
  1221. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1222. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1223. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1224. {sqlWhereBuilder}
  1225. ) temp {departmentWhere}";
  1226. // 执行分页查询
  1227. RefAsync<int> total = 0;
  1228. var delegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql)
  1229. .AddParameters(parameters)
  1230. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1231. if (!delegationList.Any())
  1232. {
  1233. var emptyView = new
  1234. {
  1235. PageFuncAuth = pageFunAuthView,
  1236. Data = delegationList
  1237. };
  1238. return Ok(JsonView(true, "查询成功,暂无数据", emptyView, total));
  1239. }
  1240. // 批量处理团组模块实际操作人和背景颜色设置
  1241. await ProcessDelegationListData(delegationList);
  1242. var resultView = new
  1243. {
  1244. PageFuncAuth = pageFunAuthView,
  1245. Data = delegationList
  1246. };
  1247. return Ok(JsonView(true, "查询成功!", resultView, total));
  1248. }
  1249. /// <summary>
  1250. /// 批量处理团组数据
  1251. /// </summary>
  1252. private async Task ProcessDelegationListData(List<DelegationListView> delegationList)
  1253. {
  1254. var groupIds = delegationList.Select(x => x.Id).ToList();
  1255. // 批量查询信用卡支付记录
  1256. var creditCardPayments = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  1257. .Where(y => groupIds.Contains(y.DIId) && y.IsDel == 0)
  1258. .Select(y => y.DIId)
  1259. .Distinct()
  1260. .ToListAsync();
  1261. // 批量查询费用确认记录
  1262. var feeAcknowledgements = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  1263. .Where(y => groupIds.Contains(y.GroupId) && y.IsDel == 0)
  1264. .Where(y => y.IsAcknowledged == AcknowledgeStatusEnum.Acknowledged)
  1265. .Select(y => y.GroupId)
  1266. .Distinct()
  1267. .ToListAsync();
  1268. var creditCardPaymentSet = creditCardPayments.ToHashSet();
  1269. var feeAcknowledgementSet = feeAcknowledgements.ToHashSet();
  1270. // 并行处理每个团组
  1271. var tasks = delegationList.Select(async x =>
  1272. {
  1273. // 处理团组模块实际操作人
  1274. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  1275. var operatorNames = new StringBuilder();
  1276. if (operators.Any())
  1277. {
  1278. foreach (var operatorInfo in operators)
  1279. {
  1280. string label = operatorInfo.OperationUsers.Any()
  1281. ? string.Join('、', operatorInfo.OperationUsers.Select(u => u.UserName))
  1282. : "暂未指定";
  1283. operatorNames.AppendLine($"{operatorInfo.CTableName}:{label}");
  1284. operatorNames.AppendLine();
  1285. }
  1286. }
  1287. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  1288. // 设置背景颜色为红色
  1289. // C表没数据并且没点提醒确认按钮(无成本费用按钮)的团组该行显示红色
  1290. bool hasCreditCardPayment = creditCardPaymentSet.Contains(x.Id);
  1291. bool hasFeeAcknowledgement = feeAcknowledgementSet.Contains(x.Id);
  1292. x.UseRedBackground = !hasCreditCardPayment && !hasFeeAcknowledgement;
  1293. });
  1294. await Task.WhenAll(tasks);
  1295. }
  1296. /// <summary>
  1297. /// 团组列表
  1298. /// </summary>
  1299. /// <returns></returns>
  1300. [HttpPost]
  1301. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  1302. {
  1303. #region 参数验证
  1304. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1305. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1306. #region 页面操作权限验证
  1307. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1308. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1309. #endregion
  1310. #endregion
  1311. if (dto.PortType != 1 && dto.PortType != 2)
  1312. {
  1313. return Ok(JsonView(false, "查询失败!"));
  1314. }
  1315. string orderbyStr = "order by gdi.CreateTime Desc";
  1316. string sqlWhere = string.Empty;
  1317. if (dto.IsSure == 0) //未完成
  1318. {
  1319. sqlWhere += string.Format(@" And IsSure = 0");
  1320. }
  1321. else if (dto.IsSure == 1) //已完成
  1322. {
  1323. sqlWhere += string.Format(@" And IsSure = 1");
  1324. }
  1325. //团组类型
  1326. if (dto.TeamDid > 0)
  1327. {
  1328. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  1329. }
  1330. //团组名称
  1331. if (!string.IsNullOrEmpty(dto.TeamName))
  1332. {
  1333. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  1334. }
  1335. //客户名称
  1336. if (!string.IsNullOrEmpty(dto.ClientName))
  1337. {
  1338. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  1339. }
  1340. //客户单位
  1341. if (!string.IsNullOrEmpty(dto.ClientUnit))
  1342. {
  1343. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  1344. }
  1345. //出访时间
  1346. if (!string.IsNullOrEmpty(dto.visitDataTime))
  1347. {
  1348. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  1349. orderbyStr = "order by gdi.VisitDate";
  1350. }
  1351. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1352. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  1353. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  1354. JietuanOperator,IsSure,CreateTime
  1355. From (
  1356. Select row_number() over({0}) as Row_Number,
  1357. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  1358. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  1359. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  1360. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1361. From Grp_DelegationInfo gdi
  1362. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1363. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1364. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1365. Where gdi.IsDel = 0 {1}
  1366. ) temp ", orderbyStr, sqlWhere);
  1367. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1368. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  1369. #region 处理所属部门
  1370. /*
  1371. * 1.sq 和 gyy 等显示 市场部
  1372. * 2.王鸽和主管及张总还有管理员号统一国交部
  1373. * 2-1. 4 管理员 ,21 张海麟
  1374. */
  1375. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  1376. var userIds1 = new List<int>() { 4, 21 };
  1377. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  1378. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1379. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1380. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1381. .ToList();
  1382. foreach (var item in _DelegationList)
  1383. {
  1384. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1385. }
  1386. #endregion
  1387. var _view = new
  1388. {
  1389. PageFuncAuth = pageFunAuthView,
  1390. Data = _DelegationList
  1391. };
  1392. return Ok(JsonView(true, "查询成功!", _view, total));
  1393. }
  1394. /// <summary>
  1395. /// 接团信息详情
  1396. /// </summary>
  1397. /// <param name="dto">团组info请求dto</param>
  1398. /// <returns></returns>
  1399. [HttpPost]
  1400. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1401. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  1402. {
  1403. var groupData = await _groupRepository.GetGroupInfo(dto);
  1404. if (groupData.Code != 0)
  1405. {
  1406. return Ok(JsonView(false, groupData.Msg));
  1407. }
  1408. return Ok(JsonView(groupData.Data));
  1409. }
  1410. /// <summary>
  1411. /// 接团信息 编辑添加
  1412. /// 基础信息数据源
  1413. /// </summary>
  1414. /// <param name="dto"></param>
  1415. /// <returns></returns>
  1416. [HttpPost]
  1417. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1418. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  1419. {
  1420. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  1421. if (groupData.Code != 0)
  1422. {
  1423. return Ok(JsonView(false, groupData.Msg));
  1424. }
  1425. return Ok(JsonView(groupData.Data));
  1426. }
  1427. /// <summary>
  1428. /// 成本修改团组信息
  1429. /// </summary>
  1430. /// <param name="dto"></param>
  1431. /// <returns></returns>
  1432. [HttpPost]
  1433. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1434. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  1435. {
  1436. var jw = JsonView(false, "操作失败");
  1437. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  1438. if (di == null)
  1439. {
  1440. jw.Msg = "参数有误!";
  1441. return Ok(jw);
  1442. }
  1443. #region 添加出访起止时间
  1444. var startTime = new DateTime();
  1445. var endTime = new DateTime();
  1446. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1447. {
  1448. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1449. }
  1450. else
  1451. {
  1452. jw.Msg = "参数有误!";
  1453. return Ok(jw);
  1454. }
  1455. #endregion
  1456. di.VisitDate = startTime;
  1457. di.VisitPNumber = dto.VisitPNumber;
  1458. di.VisitDays = dto.VisitDays;
  1459. di.VisitStartDate = startTime;
  1460. di.VisitEndDate = endTime;
  1461. var count = _sqlSugar.Updateable(di)
  1462. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1463. .ExecuteCommand();
  1464. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1465. }
  1466. /// <summary>
  1467. /// 接团信息 编辑添加
  1468. /// 省份-城市 基础信息数据源
  1469. /// </summary>
  1470. /// <param name="dto"></param>
  1471. /// <returns></returns>
  1472. [HttpPost]
  1473. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1474. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1475. {
  1476. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1477. string search = dto.Search;
  1478. var data = await _groupRepository.CityBasicSource();
  1479. int total = data.Length;
  1480. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1481. .Skip((pageIndex - 1) * pageSize)
  1482. .Take(pageSize)
  1483. .ToArray();
  1484. return Ok(JsonView(data, total));
  1485. }
  1486. /// <summary>
  1487. /// 接团信息 操作(增改)
  1488. /// </summary>
  1489. /// <param name="dto"></param>
  1490. /// <returns></returns>
  1491. [HttpPost]
  1492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1493. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1494. {
  1495. // 创建 Stopwatch 实例
  1496. Stopwatch stopwatch = Stopwatch.StartNew();
  1497. decimal ffrPrice = 0.00M;
  1498. DateTime? visitDt = null;
  1499. if (dto.Status == 2)
  1500. {
  1501. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1502. if (groupInfo != null)
  1503. {
  1504. ffrPrice = groupInfo.PaymentMoney;
  1505. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1506. }
  1507. }
  1508. var groupData = await _groupRepository.GroupOperation(dto);
  1509. if (groupData.Code != 0)
  1510. {
  1511. return Ok(JsonView(false, groupData.Msg));
  1512. }
  1513. int diId = 0;
  1514. try
  1515. {
  1516. //添加时 默认加入团组汇率
  1517. if (dto.Status == 1) //添加
  1518. {
  1519. diId = groupData.Data;
  1520. //添加默认币种
  1521. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1522. //默认分配权限
  1523. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1524. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1525. var _managerIds = new List<int>() { 22, 32, 21 };
  1526. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1527. if (userIds.Count > 0)
  1528. {
  1529. userIds.Add(208);
  1530. //创建团组管控
  1531. GroupStepForDelegation.CreateWorkStep(diId);
  1532. //发送消息
  1533. string groupName = dto.TeamName;
  1534. string createGroupUser = string.Empty;
  1535. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1536. if (userInfo != null) createGroupUser = userInfo.CnName;
  1537. string title = $"系统通知";
  1538. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1539. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1540. }
  1541. //默认创建倒推表
  1542. await _invertedListRep._Create(dto.UserId, diId);
  1543. //默认创建签证流程
  1544. await _visaProcessRep.Create(dto.UserId, diId);
  1545. //默认创建团组流程总览信息
  1546. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1547. }
  1548. else if (dto.Status == 2)
  1549. {
  1550. diId = dto.Id;
  1551. }
  1552. #region 签证人员团组时间通知
  1553. #region 计算出访起止时间
  1554. var startTime = new DateTime();
  1555. var endTime = new DateTime();
  1556. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1557. {
  1558. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1559. }
  1560. #endregion
  1561. #endregion
  1562. #region 团组操作默认添加/修改收款账单
  1563. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1564. {
  1565. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1566. .Where(x => x.IsDel == 0 &&
  1567. x.Diid == diId &&
  1568. x.Remark.Equals("预付款")
  1569. )
  1570. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1571. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1572. .FirstAsync();
  1573. ffrInfo = new Fin_ForeignReceivables()
  1574. {
  1575. Diid = diId,
  1576. PriceName = dto.ClientUnit,
  1577. Price = dto.PaymentMoney,
  1578. Count = 1,
  1579. Unit = $"元",
  1580. ItemSumPrice = dto.PaymentMoney,
  1581. Rate = 1.0000M,
  1582. Currency = 836,
  1583. AddingWay = 0,
  1584. CreateUserId = dto.UserId,
  1585. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1586. Remark = $"预付款"
  1587. };
  1588. if (ffrInfo == null) //Add
  1589. {
  1590. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1591. }
  1592. else //修改
  1593. {
  1594. await _sqlSugar.Updateable(ffrInfo)
  1595. .UpdateColumns(x => new
  1596. {
  1597. x.PriceName,
  1598. x.Price,
  1599. x.ItemSumPrice,
  1600. x.CreateTime,
  1601. x.CreateUserId
  1602. })
  1603. .WhereColumns(x => x.Id)
  1604. .ExecuteCommandAsync();
  1605. }
  1606. }
  1607. #endregion
  1608. if (diId > 0)
  1609. {
  1610. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1611. }
  1612. // 停止计时
  1613. stopwatch.Stop();
  1614. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1615. }
  1616. catch (Exception ex)
  1617. {
  1618. // 停止计时
  1619. stopwatch.Stop();
  1620. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1621. Logs(ex.Message);
  1622. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1623. }
  1624. // 停止计时
  1625. stopwatch.Stop();
  1626. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1627. }
  1628. /// <summary>
  1629. /// 接团流程操作(增改)
  1630. /// 安卓端使用 建团时添加客户名单
  1631. /// </summary>
  1632. /// <param name="dto"></param>
  1633. /// <returns></returns>
  1634. [HttpPost]
  1635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1636. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1637. {
  1638. #region 参数验证
  1639. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1640. #region 页面操作权限验证
  1641. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1642. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1643. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1644. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1645. #endregion
  1646. #endregion
  1647. try
  1648. {
  1649. //_sqlSugar.BeginTran();
  1650. decimal ffrPrice = 0.00M;
  1651. DateTime? visitDt = null;
  1652. if (dto.Status == 2)
  1653. {
  1654. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1655. if (groupInfo != null)
  1656. {
  1657. ffrPrice = groupInfo.PaymentMoney;
  1658. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1659. }
  1660. }
  1661. var _dto = new GroupOperationDto();
  1662. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1663. var groupData = await _groupRepository.GroupOperation(_dto);
  1664. if (groupData.Code != 0)
  1665. {
  1666. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1667. }
  1668. int diId = 0;
  1669. //添加时 默认加入团组汇率
  1670. if (dto.Status == 1) //添加
  1671. {
  1672. diId = groupData.Data;
  1673. //添加默认币种
  1674. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1675. //默认分配权限
  1676. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1677. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1678. var _managerIds = new List<int>() { 21, 22, 32 };
  1679. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1680. if (userIds.Count > 0)
  1681. {
  1682. userIds.Add(208);
  1683. //创建团组管控
  1684. GroupStepForDelegation.CreateWorkStep(diId);
  1685. //发送消息
  1686. string groupName = dto.TeamName;
  1687. string createGroupUser = string.Empty;
  1688. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1689. if (userInfo != null) createGroupUser = userInfo.CnName;
  1690. string title = $"系统通知";
  1691. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1692. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1693. }
  1694. #region 应用推送
  1695. try
  1696. {
  1697. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1698. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1699. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1700. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1701. {
  1702. var userList = new List<string>() { users.QiyeChatUserId };
  1703. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1704. }
  1705. }
  1706. catch (Exception ex)
  1707. {
  1708. }
  1709. #endregion
  1710. //默认创建倒推表
  1711. await _invertedListRep._Create(dto.UserId, diId);
  1712. //默认创建签证流程
  1713. await _visaProcessRep.Create(dto.UserId, diId);
  1714. //默认创建团组流程总览信息
  1715. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1716. }
  1717. if (dto.Status == 2)
  1718. {
  1719. diId = dto.Id;
  1720. if (diId == 0)
  1721. {
  1722. //_sqlSugar.RollbackTran();
  1723. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1724. }
  1725. }
  1726. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1727. if (viewData.Code != 0)
  1728. {
  1729. //_sqlSugar.RollbackTran();
  1730. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1731. }
  1732. #region 团组操作默认添加/修改收款账单
  1733. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1734. {
  1735. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1736. .Where(x => x.IsDel == 0 &&
  1737. x.Diid == diId &&
  1738. x.Remark.Equals("预付款")
  1739. )
  1740. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1741. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1742. .FirstAsync();
  1743. ffrInfo = new Fin_ForeignReceivables()
  1744. {
  1745. Diid = diId,
  1746. PriceName = dto.ClientUnit,
  1747. Price = dto.PaymentMoney,
  1748. Count = 1,
  1749. Unit = $"元",
  1750. ItemSumPrice = dto.PaymentMoney,
  1751. Rate = 1.0000M,
  1752. Currency = 836,
  1753. AddingWay = 0,
  1754. CreateUserId = dto.UserId,
  1755. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1756. Remark = $"预付款"
  1757. };
  1758. if (ffrInfo == null) //Add
  1759. {
  1760. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1761. }
  1762. else //修改
  1763. {
  1764. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1765. .UpdateColumns(x => new
  1766. {
  1767. x.PriceName,
  1768. x.Price,
  1769. x.ItemSumPrice,
  1770. x.CreateTime,
  1771. x.CreateUserId
  1772. })
  1773. .WhereColumns(x => x.Id)
  1774. .ExecuteCommandAsync();
  1775. }
  1776. }
  1777. #endregion
  1778. #region 签证人员团组时间通知
  1779. #region 计算出访起止时间
  1780. var startTime = new DateTime();
  1781. var endTime = new DateTime();
  1782. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1783. {
  1784. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1785. }
  1786. #endregion
  1787. if (diId > 0)
  1788. {
  1789. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1790. }
  1791. #endregion
  1792. //_sqlSugar.CommitTran();
  1793. return Ok(JsonView(true, "添加成功"));
  1794. }
  1795. catch (Exception ex)
  1796. {
  1797. _sqlSugar.RollbackTran();
  1798. return Ok(JsonView(false, ex.Message));
  1799. }
  1800. }
  1801. /// <summary>
  1802. /// 接团流程操作(增改)
  1803. /// 安卓端使用 建团时添加客户名单
  1804. /// </summary>
  1805. /// <param name="dto"></param>
  1806. /// <returns></returns>
  1807. [HttpPost]
  1808. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1809. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1810. {
  1811. #region 参数验证
  1812. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1813. #region 页面操作权限验证
  1814. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1815. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1816. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1817. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1818. #endregion
  1819. #endregion
  1820. _sqlSugar.BeginTran();
  1821. decimal ffrPrice = 0.00M;
  1822. DateTime? visitDt = null;
  1823. if (dto.Status == 2)
  1824. {
  1825. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1826. if (groupInfo != null)
  1827. {
  1828. ffrPrice = groupInfo.PaymentMoney;
  1829. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1830. }
  1831. }
  1832. var _dto = new GroupOperationDto();
  1833. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1834. var groupData = await _groupRepository.GroupOperation(_dto);
  1835. if (groupData.Code != 0)
  1836. {
  1837. _sqlSugar.RollbackTran();
  1838. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1839. }
  1840. try
  1841. {
  1842. int diId = 0;
  1843. //添加时 默认加入团组汇率
  1844. if (dto.Status == 1) //添加
  1845. {
  1846. diId = groupData.Data;
  1847. //添加默认币种
  1848. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1849. //默认分配权限
  1850. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1851. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1852. var _managerIds = new List<int>() { 21, 22, 32 };
  1853. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1854. if (userIds.Count > 0)
  1855. {
  1856. userIds.Add(208);
  1857. //创建团组管控
  1858. GroupStepForDelegation.CreateWorkStep(diId);
  1859. //发送消息
  1860. string groupName = dto.TeamName;
  1861. string createGroupUser = string.Empty;
  1862. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1863. if (userInfo != null) createGroupUser = userInfo.CnName;
  1864. string title = $"系统通知";
  1865. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1866. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1867. }
  1868. #region 应用推送
  1869. try
  1870. {
  1871. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1872. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1873. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1874. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1875. {
  1876. var userList = new List<string>() { users.QiyeChatUserId };
  1877. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1878. }
  1879. }
  1880. catch (Exception ex)
  1881. {
  1882. _sqlSugar.CommitTran();
  1883. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1884. }
  1885. #endregion
  1886. //默认创建倒推表
  1887. await _invertedListRep._Create(dto.UserId, diId);
  1888. }
  1889. else if (dto.Status == 2)
  1890. {
  1891. diId = dto.Id;
  1892. if (diId == 0)
  1893. {
  1894. _sqlSugar.RollbackTran();
  1895. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1896. }
  1897. }
  1898. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1899. if (viewData.Code != 0)
  1900. {
  1901. _sqlSugar.RollbackTran();
  1902. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1903. }
  1904. #region 团组操作默认添加/修改收款账单
  1905. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1906. {
  1907. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1908. .Where(x => x.IsDel == 0 &&
  1909. x.Diid == diId &&
  1910. x.Remark.Equals("预付款")
  1911. )
  1912. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1913. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1914. .FirstAsync();
  1915. ffrInfo = new Fin_ForeignReceivables()
  1916. {
  1917. Diid = diId,
  1918. PriceName = dto.ClientUnit,
  1919. Price = dto.PaymentMoney,
  1920. Count = 1,
  1921. Unit = $"元",
  1922. ItemSumPrice = dto.PaymentMoney,
  1923. Rate = 1.0000M,
  1924. Currency = 836,
  1925. AddingWay = 0,
  1926. CreateUserId = dto.UserId,
  1927. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1928. Remark = $"预付款"
  1929. };
  1930. if (ffrInfo == null) //Add
  1931. {
  1932. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1933. }
  1934. else //修改
  1935. {
  1936. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1937. .UpdateColumns(x => new
  1938. {
  1939. x.PriceName,
  1940. x.Price,
  1941. x.ItemSumPrice,
  1942. x.CreateTime,
  1943. x.CreateUserId
  1944. })
  1945. .WhereColumns(x => x.Id)
  1946. .ExecuteCommandAsync();
  1947. }
  1948. }
  1949. #endregion
  1950. #region 签证人员团组时间通知
  1951. #region 计算出访起止时间
  1952. var startTime = new DateTime();
  1953. var endTime = new DateTime();
  1954. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1955. {
  1956. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1957. }
  1958. #endregion
  1959. if (diId > 0)
  1960. {
  1961. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1962. }
  1963. #endregion
  1964. _sqlSugar.CommitTran();
  1965. return Ok(JsonView(true));
  1966. }
  1967. catch (Exception ex)
  1968. {
  1969. _sqlSugar.RollbackTran();
  1970. return Ok(JsonView(false, ex.Message));
  1971. }
  1972. }
  1973. /// <summary>
  1974. /// 接团信息 操作(删除)
  1975. /// </summary>
  1976. /// <param name="dto"></param>
  1977. /// <returns></returns>
  1978. [HttpPost]
  1979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1980. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1981. {
  1982. var diId = dto.Id;
  1983. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1984. #region 删除 验证
  1985. /*
  1986. * 1、收款账单数据:0 条
  1987. * 2、收款退还数据:0 条
  1988. * 3、机票费用数据:0 条
  1989. * 4、签证费用数据:0 条
  1990. * 5、保险费用数据:0 条
  1991. * 6、酒店费用数据:0 条
  1992. * 7、公务出访数据:1 条
  1993. * 8、邀请公务活动费用数据:1 条
  1994. * 9、OP费用数据:5 条
  1995. * 10、其他费用数据:0 条
  1996. * 11、团组日付报销费用数据:0 条
  1997. *
  1998. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  1999. */
  2000. //收款账单
  2001. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  2002. //收款退还
  2003. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2004. //机票费用
  2005. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  2006. //签证费用
  2007. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  2008. //保险费用
  2009. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2010. //酒店费用
  2011. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2012. //公务出访
  2013. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2014. //邀请公务活动费用
  2015. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2016. //OP费用
  2017. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2018. //其他费用
  2019. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2020. //团组日付报销费用
  2021. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  2022. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  2023. if (feeCount > 0)
  2024. {
  2025. var delMsgTips = new StringBuilder();
  2026. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  2027. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  2028. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  2029. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  2030. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  2031. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  2032. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  2033. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  2034. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  2035. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  2036. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  2037. delMsgTips.AppendLine($"");
  2038. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  2039. return Ok(JsonView(false, delMsgTips.ToString()));
  2040. }
  2041. #endregion
  2042. var groupData = await _groupRepository.GroupDel(dto);
  2043. if (groupData.Code != 0)
  2044. {
  2045. return Ok(JsonView(false, groupData.Msg));
  2046. }
  2047. return Ok(JsonView(true));
  2048. }
  2049. /// <summary>
  2050. /// 获取团组销售报价号
  2051. /// 团组添加时 使用
  2052. /// </summary>
  2053. /// <returns></returns>
  2054. [HttpPost]
  2055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2056. public async Task<IActionResult> GetGroupSalesQuoteNo()
  2057. {
  2058. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  2059. if (groupData.Code != 0)
  2060. {
  2061. return Ok(JsonView(false, groupData.Msg));
  2062. }
  2063. object salesQuoteNo = new
  2064. {
  2065. SalesQuoteNo = groupData.Data
  2066. };
  2067. return Ok(JsonView(salesQuoteNo));
  2068. }
  2069. /// <summary>
  2070. /// 设置确认出团
  2071. /// </summary>
  2072. /// <param name="dto"></param>
  2073. /// <returns></returns>
  2074. [HttpPost]
  2075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2076. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  2077. {
  2078. var groupData = await _groupRepository.ConfirmationGroup(dto);
  2079. if (groupData.Code != 0)
  2080. {
  2081. return Ok(JsonView(false, groupData.Msg));
  2082. }
  2083. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  2084. #region OA消息推送
  2085. try
  2086. {
  2087. string groupName = groupInfo.TeamName;
  2088. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  2089. string title = $"系统通知";
  2090. string content = $"团组[{groupName}]已确认出团!";
  2091. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  2092. }
  2093. catch (Exception ex)
  2094. {
  2095. }
  2096. #endregion
  2097. #region 应用推送
  2098. try
  2099. {
  2100. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  2101. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  2102. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  2103. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  2104. {
  2105. var userList = new List<string>() { users.QiyeChatUserId };
  2106. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  2107. }
  2108. }
  2109. catch (Exception ex)
  2110. {
  2111. }
  2112. #endregion
  2113. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  2114. return Ok(JsonView(true, "操作成功!", groupData.Data));
  2115. }
  2116. /// <summary>
  2117. /// 获取团组名称data And 签证国别Data
  2118. /// </summary>
  2119. /// <param name="dto"></param>
  2120. /// <returns></returns>
  2121. [HttpPost]
  2122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2123. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  2124. {
  2125. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  2126. if (groupData.Code != 0)
  2127. {
  2128. return Ok(JsonView(false, groupData.Msg));
  2129. }
  2130. return Ok(JsonView(groupData.Data));
  2131. }
  2132. /// <summary>
  2133. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  2134. /// </summary>
  2135. /// <returns></returns>
  2136. [HttpPost]
  2137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2138. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  2139. {
  2140. try
  2141. {
  2142. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  2143. if (groupData.Code != 0)
  2144. {
  2145. return Ok(JsonView(false, groupData.Msg));
  2146. }
  2147. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2148. }
  2149. catch (Exception ex)
  2150. {
  2151. return Ok(JsonView(false, ex.Message));
  2152. throw;
  2153. }
  2154. }
  2155. /// <summary>
  2156. /// 团组清单 Excel
  2157. /// </summary>
  2158. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  2159. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  2160. /// <returns></returns>
  2161. [HttpGet]
  2162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2163. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  2164. {
  2165. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  2166. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  2167. if (!beginBool && !endBool)
  2168. {
  2169. return Ok(JsonView(false, "开始或结束时间不正确!"));
  2170. }
  2171. string sql = string.Format(@"
  2172. SELECT
  2173. ROW_NUMBER,
  2174. Id,
  2175. SalesQuoteNo,
  2176. TourCode,
  2177. TeamTypeId,
  2178. TeamType,
  2179. TeamLevId,
  2180. TeamLev,
  2181. TeamName,
  2182. ClientName,
  2183. ClientUnit,
  2184. VisitDate,
  2185. VisitDays,
  2186. VisitPNumber,
  2187. JietuanOperatorId,
  2188. JietuanOperator,
  2189. IsSure,
  2190. CreateUserName,
  2191. IsBid
  2192. FROM
  2193. (
  2194. SELECT
  2195. ROW_NUMBER() OVER(
  2196. ORDER BY
  2197. gdi.VisitDate Desc
  2198. ) AS ROW_NUMBER,
  2199. gdi.Id,
  2200. SalesQuoteNo,
  2201. TourCode,
  2202. ssd.Id TeamTypeId,
  2203. ssd.Name TeamType,
  2204. ssd1.Id TeamLevId,
  2205. ssd1.Name TeamLev,
  2206. TeamName,
  2207. ClientName,
  2208. ClientUnit,
  2209. VisitDate,
  2210. VisitDays,
  2211. VisitPNumber,
  2212. JietuanOperator JietuanOperatorId,
  2213. su.CnName JietuanOperator,
  2214. IsSure,
  2215. gdi.CreateTime,
  2216. su1.CnName As CreateUserName,
  2217. gdi.IsBid
  2218. FROM
  2219. Grp_DelegationInfo gdi
  2220. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  2221. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  2222. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  2223. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  2224. WHERE
  2225. gdi.IsDel = 0
  2226. AND gdi.IsBid = 0
  2227. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  2228. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  2229. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  2230. #region 处理所属部门
  2231. /*
  2232. * 1.sq 和 gyy 等显示 市场部
  2233. * 2.王鸽和主管及张总还有管理员号统一国交部
  2234. * 2-1. 4 管理员 ,21 张海麟
  2235. */
  2236. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  2237. var userIds1 = new List<int>() { 4, 21 };
  2238. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  2239. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  2240. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  2241. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  2242. .ToListAsync();
  2243. var droupIds = groupList.Select(it => it.Id).ToList();
  2244. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  2245. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  2246. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  2247. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  2248. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  2249. {
  2250. DiId = tcl.DiId,
  2251. LastName = dc.LastName,
  2252. FirstName = dc.FirstName,
  2253. Sex = dc.Sex,
  2254. Birthday = dc.BirthDay,
  2255. Company = cc.CompanyFullName,
  2256. Job = dc.Job,
  2257. CreateTime = tcl.CreateTime,
  2258. })
  2259. .ToList();
  2260. foreach (var item in groupList)
  2261. {
  2262. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  2263. string groupFirstName = "";
  2264. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  2265. if (currDatas.Any())
  2266. {
  2267. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  2268. }
  2269. item.GroupFirst = groupFirstName;
  2270. }
  2271. #endregion
  2272. #region Excel
  2273. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  2274. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  2275. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  2276. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  2277. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  2278. //载入模板
  2279. var designer = new WorkbookDesigner
  2280. {
  2281. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  2282. };
  2283. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  2284. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  2285. dt.TableName = "GroupList";
  2286. designer.SetDataSource(dt);
  2287. designer.Process();
  2288. if (!Directory.Exists(savePath))
  2289. {
  2290. Directory.CreateDirectory(savePath);
  2291. }
  2292. string serverPath = $"{savePath}{fileName}";
  2293. designer.Workbook.Save(serverPath);
  2294. string rst = $"{servicePath}{ftpPath}{fileName}";
  2295. #endregion
  2296. return Ok(JsonView(true, "操作成功!", rst));
  2297. }
  2298. /// <summary>
  2299. /// 团组合同下载(1.付款80% 2.付全款)
  2300. /// </summary>
  2301. /// <param name="dto"></param>
  2302. /// <returns></returns>
  2303. /// <exception cref="Exception"></exception>
  2304. [HttpPost]
  2305. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  2306. {
  2307. var jw = JsonView(false);
  2308. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  2309. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  2310. if (di == null)
  2311. {
  2312. jw.Msg = "团组Id有误!";
  2313. return Ok(jw);
  2314. }
  2315. #region 权限校验
  2316. var allDownFile = new List<int>() { 21 };
  2317. try
  2318. {
  2319. var setting = _sqlSugar.Queryable<Sys_SetData>()
  2320. .First(x => x.Id == 1418 && x.IsDel == 0);
  2321. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  2322. }
  2323. catch (Exception)
  2324. { }
  2325. var guojiaoDownFile = new List<int>() { 330, 383 };
  2326. var shichangDownFile = new List<int>() { 95 };
  2327. if (allDownFile.Contains(dto.UserId))
  2328. {
  2329. }
  2330. else if (guojiaoDownFile.Contains(dto.UserId))
  2331. {
  2332. var guojiaobuDi = new List<int>() { 4, 21 };
  2333. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  2334. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  2335. .Where((d, u) => u.Id == di.JietuanOperator)
  2336. .Select((d, u) => d.DepName)
  2337. .First();
  2338. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  2339. {
  2340. jw.Msg = "暂无下载权限!";
  2341. return Ok(jw);
  2342. }
  2343. }
  2344. else if (shichangDownFile.Contains(dto.UserId))
  2345. {
  2346. var dic = new Dictionary<int, int[]>()
  2347. {
  2348. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  2349. };
  2350. try
  2351. {
  2352. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  2353. if (sqSetting != null)
  2354. {
  2355. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  2356. foreach (var item in result.Keys)
  2357. {
  2358. if (dic.ContainsKey(item))
  2359. {
  2360. int[] dilatation = new int[dic[item].Length + result[item].Length];
  2361. Array.Copy(dic[item], dilatation, dic[item].Length);
  2362. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  2363. dic[item] = dilatation;
  2364. }
  2365. else
  2366. {
  2367. dic.Add(item, result[item]);
  2368. }
  2369. }
  2370. }
  2371. if (!dic[95].Contains(di.CreateUserId))
  2372. {
  2373. jw.Msg = "暂无下载权限!";
  2374. return Ok(jw);
  2375. }
  2376. }
  2377. catch (Exception)
  2378. { }
  2379. }
  2380. else if (dto.UserId == di.CreateUserId)
  2381. {
  2382. }
  2383. else
  2384. {
  2385. jw.Msg = "暂无下载权限!";
  2386. return Ok(jw);
  2387. }
  2388. #endregion
  2389. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  2390. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  2391. .ToListAsync();
  2392. if (!blackCodeList.Any())
  2393. {
  2394. jw.Msg = "该团无机票行程代码!";
  2395. return Ok(jw);
  2396. }
  2397. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  2398. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  2399. if (groupEnterExitCost == null)
  2400. {
  2401. jw.Msg = "暂无三公费用信息!";
  2402. return Ok(jw);
  2403. }
  2404. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  2405. rateList ??= new List<CurrencyInfo>();
  2406. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  2407. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  2408. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  2409. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  2410. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  2411. .Select((x, a, b) => new
  2412. {
  2413. x.Index,
  2414. itemName = a.Name,
  2415. CurrencyStr = b.Name,
  2416. x.Cost,
  2417. x.SubTotal,
  2418. x.Remark
  2419. })
  2420. .OrderBy((x) => x.Index)
  2421. .ToList();
  2422. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  2423. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  2424. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  2425. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  2426. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  2427. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  2428. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  2429. decimal subJJC = 0.00M,
  2430. subGWC = 0.00M,
  2431. subTDC = 0.00M;
  2432. //经济舱
  2433. if (groupEnterExitCost.SumJJC == 1)
  2434. {
  2435. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  2436. }
  2437. //公务舱
  2438. if (groupEnterExitCost.SumGWC == 1)
  2439. {
  2440. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  2441. }
  2442. //头等舱
  2443. if (groupEnterExitCost.SumTDC == 1)
  2444. {
  2445. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  2446. }
  2447. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  2448. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  2449. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  2450. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2451. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2452. .Select((x, s, dc, cc) => new GroupClints
  2453. {
  2454. Id = x.Id,
  2455. Name = s.Name,
  2456. IsAccompany = x.IsAccompany,
  2457. CompanyFullName = cc.CompanyFullName
  2458. })
  2459. .ToListAsync();
  2460. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2461. //获取舱位人数
  2462. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2463. .GroupBy(x => x.Name)
  2464. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2465. .ToList();
  2466. string cityPath = string.Empty;
  2467. string startCity = string.Empty;
  2468. string endCity = string.Empty;
  2469. foreach (var item in blackCodeList)
  2470. {
  2471. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2472. cityPath += city + "\r\n";
  2473. if (item.Equals(blackCodeList.First()))
  2474. {
  2475. var sp = city.Split('-');
  2476. startCity = sp[0];
  2477. endCity = sp[^1];
  2478. }
  2479. }
  2480. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2481. var bookMarkDic = new Dictionary<string, string>
  2482. {
  2483. { "ClientUnit", di.ClientUnit },
  2484. { "VisitCountry", di.VisitCountry },
  2485. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2486. { "VisitPNumber", di.VisitPNumber.ToString() },
  2487. { "CityPath", cityPath },
  2488. { "StartCity", startCity },
  2489. { "EndCity", endCity },
  2490. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2491. };
  2492. Document doc = null;
  2493. var percentage = 0.8M;
  2494. var fileNameadd = "预付";
  2495. if (dto.FileType == 1)
  2496. {
  2497. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2498. }
  2499. else if (dto.FileType == 2)
  2500. {
  2501. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2502. percentage = 1;
  2503. fileNameadd = "全款";
  2504. }
  2505. else
  2506. {
  2507. throw new Exception("FileType有误!");
  2508. }
  2509. var builder = new DocumentBuilder(doc);
  2510. decimal totalPrice = 0.00M;
  2511. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2512. if (firstTable != null)
  2513. {
  2514. // 遍历表格的行和单元格
  2515. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2516. {
  2517. for (int i = 0; i < row.Cells.Count; i++)
  2518. {
  2519. var cell = row.Cells[i];
  2520. // 读取单元格内容
  2521. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2522. if (cellTextFirst.Contains("舱位"))
  2523. {
  2524. break;
  2525. }
  2526. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2527. {
  2528. if (i == 2)
  2529. {
  2530. if (cellTextFirst == "经济舱")
  2531. {
  2532. // 设置单元格内容
  2533. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2534. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2535. }
  2536. else
  2537. {
  2538. // 设置单元格内容
  2539. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2540. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2541. }
  2542. }
  2543. if (i == 3)
  2544. {
  2545. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2546. if (count != null)
  2547. {
  2548. // 设置单元格内容
  2549. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2550. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2551. }
  2552. }
  2553. if (i == 4)
  2554. {
  2555. var rowPrice = 0.00M;
  2556. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2557. count ??= 0;
  2558. if (cellTextFirst == "经济舱")
  2559. {
  2560. rowPrice = subJJC * (int)count;
  2561. }
  2562. else
  2563. {
  2564. rowPrice = subGWC * (int)count;
  2565. }
  2566. totalPrice += rowPrice;
  2567. // 设置单元格内容
  2568. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2569. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2570. }
  2571. }
  2572. }
  2573. }
  2574. }
  2575. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2576. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2577. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2578. //--合同表格部分
  2579. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2580. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2581. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2582. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2583. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2584. bookMarkDic.Add("CityPath1", cityPath);
  2585. bookMarkDic.Add("CityPath2", cityPath);
  2586. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2587. if (contractTable != null)
  2588. {
  2589. //数据源
  2590. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2591. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2592. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2593. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2594. .Select((it, y, s) => new
  2595. {
  2596. it.Cost,
  2597. it.SubTotal,
  2598. it.Type,
  2599. y.Id,
  2600. y.City,
  2601. s.Name,
  2602. CurrencyCodeCn = s.Remark
  2603. })
  2604. .ToList()
  2605. .Select(x => new
  2606. {
  2607. CurrencyCode = x.Name,
  2608. CityId = x.Id,
  2609. x.City,
  2610. di.VisitPNumber,
  2611. x.Type,
  2612. x.Cost,
  2613. x.SubTotal,
  2614. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2615. x.CurrencyCodeCn,
  2616. });
  2617. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2618. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2619. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2620. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2621. var tableSettings = new List<tableSetting>()
  2622. {
  2623. new(){ Index = 1 , Property = "City"},
  2624. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2625. new(){ Index = 3 , Property = "Cost"},
  2626. new(){ Index = 4 , Property = "VisitPNumber"},
  2627. //new tableSetting{ Index = 5 , Property = ""},
  2628. //new tableSetting{ Index = 6 , Property = ""},
  2629. new(){ Index = 7 , Property = "Rate"},
  2630. //new tableSetting{ Index = 8 , Property = ""},
  2631. };
  2632. //1.住宿费
  2633. int cloneRow = 8;
  2634. int startDayPrice = 8; //写入index
  2635. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2636. foreach (var dac in dac1)
  2637. {
  2638. var first = dac.First();
  2639. var dayCount = dac.Count();
  2640. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2641. for (int i = 1; i < row.Cells.Count; i++)
  2642. {
  2643. var cell = row.Cells[i];
  2644. var findProperty = tableSettings.Find(x => x.Index == i);
  2645. if (findProperty != null)
  2646. {
  2647. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2648. // 设置单元格内容
  2649. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2650. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2651. }
  2652. else
  2653. {
  2654. switch (i)
  2655. {
  2656. case 5:
  2657. cell.FirstParagraph.Runs.Clear();
  2658. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2659. break;
  2660. case 6:
  2661. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2662. cell.FirstParagraph.Runs.Clear();
  2663. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2664. break;
  2665. case 8:
  2666. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2667. cell.FirstParagraph.Runs.Clear();
  2668. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2669. ZSPriceSum += xiaojiRMB;
  2670. break;
  2671. default:
  2672. break;
  2673. }
  2674. }
  2675. }
  2676. startDayPrice++;
  2677. if (!dac1.Last().Equals(dac))
  2678. {
  2679. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2680. // 将克隆的行追加到原行后面
  2681. contractTable.Rows.Insert(startDayPrice, newRow);
  2682. }
  2683. else
  2684. {
  2685. cloneRow += dac1.Count + 1;
  2686. startDayPrice = cloneRow;
  2687. }
  2688. }
  2689. //2.伙食费
  2690. foreach (var dac in dac2)
  2691. {
  2692. var first = dac.First();
  2693. var dayCount = dac.Count();
  2694. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2695. for (int i = 1; i < row.Cells.Count; i++)
  2696. {
  2697. var cell = row.Cells[i];
  2698. var findProperty = tableSettings.Find(x => x.Index == i);
  2699. if (findProperty != null)
  2700. {
  2701. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2702. // 设置单元格内容
  2703. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2704. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2705. }
  2706. else
  2707. {
  2708. switch (i)
  2709. {
  2710. case 5:
  2711. cell.FirstParagraph.Runs.Clear();
  2712. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2713. break;
  2714. case 6:
  2715. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2716. cell.FirstParagraph.Runs.Clear();
  2717. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2718. break;
  2719. case 8:
  2720. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2721. cell.FirstParagraph.Runs.Clear();
  2722. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2723. HSPriceSum += xiaojiRMB;
  2724. break;
  2725. default:
  2726. break;
  2727. }
  2728. }
  2729. }
  2730. startDayPrice++;
  2731. if (!dac2.Last().Equals(dac))
  2732. {
  2733. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2734. // 将克隆的行追加到原行后面
  2735. contractTable.Rows.Insert(startDayPrice, newRow);
  2736. }
  2737. else
  2738. {
  2739. cloneRow += dac2.Count + 1;
  2740. startDayPrice = cloneRow;
  2741. }
  2742. }
  2743. //3.公杂费
  2744. foreach (var dac in dac3)
  2745. {
  2746. var first = dac.First();
  2747. var dayCount = dac.Count();
  2748. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2749. for (int i = 1; i < row.Cells.Count; i++)
  2750. {
  2751. var cell = row.Cells[i];
  2752. var findProperty = tableSettings.Find(x => x.Index == i);
  2753. if (findProperty != null)
  2754. {
  2755. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2756. // 设置单元格内容
  2757. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2758. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2759. }
  2760. else
  2761. {
  2762. switch (i)
  2763. {
  2764. case 5:
  2765. cell.FirstParagraph.Runs.Clear();
  2766. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2767. break;
  2768. case 6:
  2769. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2770. cell.FirstParagraph.Runs.Clear();
  2771. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2772. break;
  2773. case 8:
  2774. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2775. cell.FirstParagraph.Runs.Clear();
  2776. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2777. GZPriceSum += xiaojiRMB;
  2778. break;
  2779. default:
  2780. break;
  2781. }
  2782. }
  2783. }
  2784. startDayPrice++;
  2785. if (!dac3.Last().Equals(dac))
  2786. {
  2787. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2788. // 将克隆的行追加到原行后面
  2789. contractTable.Rows.Insert(startDayPrice, newRow);
  2790. }
  2791. else
  2792. {
  2793. cloneRow += dac3.Count + 1;
  2794. startDayPrice = cloneRow;
  2795. }
  2796. }
  2797. //合并单元格
  2798. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2799. {
  2800. var currentRow = contractTable.Rows[i];
  2801. var nextRow = contractTable.Rows[i + 1];
  2802. // 获取当前行和下一行的第一个单元格
  2803. Cell currentCell = currentRow.Cells[0];
  2804. Cell nextCell = nextRow.Cells[0];
  2805. // 检查单元格内容是否一致(去除尾部的换行符)
  2806. string currentText = currentCell.GetText().Trim();
  2807. string nextText = nextCell.GetText().Trim();
  2808. if (currentText == nextText)
  2809. {
  2810. // 如果当前单元格已经被合并,找到合并的起始单元格
  2811. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2812. {
  2813. // 找到合并的起始单元格
  2814. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2815. // 将下一行的单元格设置为合并的后续单元格
  2816. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2817. }
  2818. else
  2819. {
  2820. // 如果当前单元格是合并的起始单元格
  2821. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2822. // 将下一行的单元格设置为合并的后续单元格
  2823. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2824. }
  2825. }
  2826. else
  2827. {
  2828. // 如果内容不一致,重置当前单元格的合并属性
  2829. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2830. {
  2831. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2832. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2833. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2834. }
  2835. else
  2836. {
  2837. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2838. }
  2839. }
  2840. }
  2841. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2842. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2843. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2844. }
  2845. foreach (var bookmarkName in bookMarkDic.Keys)
  2846. {
  2847. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2848. if (bookmark != null)
  2849. {
  2850. if (bookmarkName == "ClientUnit")
  2851. {
  2852. // 移动到书签位置
  2853. builder.MoveTo(bookmark.BookmarkStart);
  2854. // 设置字体样式为下划线
  2855. builder.Font.Underline = Aspose.Words.Underline.Single;
  2856. // 插入书签值
  2857. builder.Write(bookMarkDic[bookmarkName]);
  2858. // 清除字体格式,避免影响后续文本
  2859. builder.Font.ClearFormatting();
  2860. }
  2861. else
  2862. {
  2863. builder.MoveToBookmark(bookmarkName);
  2864. builder.Write(bookMarkDic[bookmarkName]);
  2865. }
  2866. }
  2867. }
  2868. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2869. doc.Save(savePaht);
  2870. jw.Msg = "生成成功!";
  2871. jw.Code = 200;
  2872. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2873. return Ok(jw);
  2874. }
  2875. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2876. {
  2877. int index = rowIndex;
  2878. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2879. {
  2880. index--;
  2881. }
  2882. return index;
  2883. }
  2884. /// <summary>
  2885. /// 报批完成企微通知
  2886. /// </summary>
  2887. /// <param name="dto"></param>
  2888. /// <returns></returns>
  2889. [HttpPost]
  2890. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2891. {
  2892. int currUserId = dto.currUserId;
  2893. int diid = dto.diid;
  2894. var jw = JsonView(true);
  2895. var users = new List<string>();
  2896. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2897. .First(x => x.Id == 1460);
  2898. try
  2899. {
  2900. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2901. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2902. //添加分配人员
  2903. // 79 车/导游地接
  2904. // 80 签证
  2905. // 81 邀请/公务活动
  2906. var setdataids = new List<int>() { 79, 81 };
  2907. foreach (var groupModule in groupModuleOperators)
  2908. {
  2909. if (setdataids.Contains(groupModule.CTableId))
  2910. {
  2911. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2912. }
  2913. }
  2914. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2915. //消息通知成功 更改团组step、记录日志
  2916. if (res)
  2917. {
  2918. var groupStep = 0; //0-新建 1-企微消息通知
  2919. //更改团组step
  2920. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2921. .SetColumns(x => new Grp_DelegationInfo()
  2922. {
  2923. Step = 2,
  2924. StepOperationTime = DateTime.Now
  2925. })
  2926. .Where(x => x.Id == diid && x.IsDel == 0)
  2927. .ExecuteCommandAsync();
  2928. if (updStatus > 0) groupStep = 2;
  2929. string groupStepLabel = groupStep switch
  2930. {
  2931. 1 => "新建",
  2932. 2 => "企微消息通知(报批)",
  2933. _ => "未设置"
  2934. };
  2935. //记录日志
  2936. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2937. .Where(x => x.Id == diid && x.IsDel == 0)
  2938. .Select(x => x.TeamName)
  2939. .First() ?? "-";
  2940. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2941. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2942. .Select(x => x.CnName)
  2943. .First() ?? "-";
  2944. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2945. //设置 签证流程初始值
  2946. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2947. }
  2948. }
  2949. catch (Exception ex)
  2950. {
  2951. return Ok(JsonView(false, ex.Message));
  2952. }
  2953. return Ok(jw);
  2954. }
  2955. #endregion
  2956. #region 团组&签证
  2957. #region 团组&签证 New
  2958. /// <summary>
  2959. /// 团组&签证 New
  2960. /// DeepSeek API:测试API连通性
  2961. /// </summary>
  2962. /// <param name="file">请求dto</param>
  2963. /// <returns></returns>
  2964. [HttpPost]
  2965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2966. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2967. {
  2968. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2969. }
  2970. /// <summary>
  2971. /// 团组&签证 New
  2972. /// DeepSeek API:检查可用端点
  2973. /// </summary>
  2974. /// <param name="file">请求dto</param>
  2975. /// <returns></returns>
  2976. [HttpPost]
  2977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2978. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2979. {
  2980. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2981. }
  2982. /// <summary>
  2983. /// 团组&签证 New
  2984. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2985. /// </summary>
  2986. /// <param name="visaFile">文件</param>
  2987. /// <param name="fileTypeId">
  2988. /// 1. 澳新签证个人申请表
  2989. /// 2. 出国个人申请表
  2990. /// 3. 美国签证个人申请表格
  2991. /// 4. 沙特个人信息表格
  2992. /// 5. 申根签证个人资料表
  2993. /// 6. 中文个人简历模板
  2994. /// </param>
  2995. /// <returns></returns>
  2996. [HttpPost]
  2997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2998. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  2999. {
  3000. //文件验证
  3001. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3002. //var visaFiles = new VisaUploadFileTypeView();
  3003. //var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  3004. //if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  3005. //服务器存储文件
  3006. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  3007. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  3008. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  3009. using (var stream = new FileStream(filePath, FileMode.Create))
  3010. {
  3011. await visaFile.CopyToAsync(stream);
  3012. }
  3013. //日志记录-上传文件
  3014. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  3015. #region 上传文件到DeepSeekAPI
  3016. //IFormFile localFile = null;
  3017. ////获取项目中的cs文件
  3018. //try
  3019. //{
  3020. // _logger.LogInformation("读取并上传项目文件请求");
  3021. // // 1. 读取项目文件
  3022. // var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  3023. // if (readResponse.SuccessCount == 0)
  3024. // {
  3025. // return Ok(JsonView(false, "读取项目文件失败"));
  3026. // }
  3027. // localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  3028. //}
  3029. //catch (Exception ex)
  3030. //{
  3031. // _logger.LogError(ex, "读取项目文件失败");
  3032. // return Ok(JsonView(false, "读取项目文件失败"));
  3033. //}
  3034. //if (localFile == null)
  3035. //{
  3036. // return Ok(JsonView(false, "读取项目文件失败"));
  3037. //}
  3038. //var fileReq = new DeepSeekFileUploadRequest()
  3039. //{
  3040. // Files = new List<IFormFile> { localFile, visaFile },
  3041. //};
  3042. //var filesResult = new List<FileUploadResult>();
  3043. //try
  3044. //{
  3045. // _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  3046. // filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  3047. // // 需要等待处理完成
  3048. // if (fileReq.WaitForProcessing)
  3049. // {
  3050. // foreach (var result in filesResult)
  3051. // {
  3052. // if (result.Success)
  3053. // {
  3054. // try
  3055. // {
  3056. // var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  3057. // result.Status = processedFile.Status;
  3058. // }
  3059. // catch (Exception ex)
  3060. // {
  3061. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  3062. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  3063. // }
  3064. // }
  3065. // }
  3066. // }
  3067. //}
  3068. //catch (Exception ex)
  3069. //{
  3070. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  3071. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  3072. //}
  3073. //#endregion
  3074. //if (filesResult == null || filesResult.Count < 1)
  3075. //{
  3076. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  3077. //}
  3078. ////
  3079. //try
  3080. //{
  3081. // var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  3082. // _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  3083. // string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  3084. // var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  3085. // return Ok(response);
  3086. //}
  3087. //catch (Exception ex)
  3088. //{
  3089. // _logger.LogError(ex, "使用文件聊天失败");
  3090. // return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  3091. //}
  3092. #endregion
  3093. #region kimi API
  3094. //加载文件OpCarTouristGuideGroundContent
  3095. //kimi AI 识别文档返回json结果
  3096. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  3097. var KiMiApi = new KiMiApiClient();
  3098. var files = new List<IFormFile>() { visaFile };
  3099. var seedConter = await KiMiApi.UploadFilesAsync(files);
  3100. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  3101. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  3102. var seedMessage = string.Format(@"你是领事馆电子材料审核员,只关注 Word 里的表格,正文、页眉页脚、水印、批注全部忽略。
  3103. 任务:把表格里的每个可填字段转换成“标题:值”的键值对,标题用原文,值用原文,不翻译。
  3104. 规则如下:
  3105. 1. 行列对齐:先按视觉补齐所有合并单元格——纵向合并则重复上方单元格内容,横向合并则留空字符串;无线表按对齐虚拟列线。
  3106. 2. 单格内出现多个“□”时,把被勾选(☑、√、×、■)的选项原文输出;若没有任何勾选,该字段输出 null。
  3107. 3. 所有日期统一转 yyyy-mm-dd,原格式“1990年1月1日”→1990-01-01;若缺日/月,用-01补位。
  3108. 4. 电话、传真、手机号:输出连续数字,遇到“(0 )”或“-”一律删除,只保留 7~15 位数字;若缺区号,原样保留。
  3109. 5. 金额:保留原数字,如“3000”。
  3110. 6. 地址:省、市、区、街道、门牌、邮编用空格分隔,不省略。
  3111. 7. 若同一张表出现“现住址”“家庭地址”“单位地址”等多列,依次编号 address_home / address_unit / address_legal。
  3112. 8. 输出顺序:按表格从左到右、从上到下逐行扫描,字段名重复时加序号,如 child_name_1、child_name_2。
  3113. 9. 结果格式:每行一个键值对,字段名与值之间用英文冒号+空格分隔,不要表格 Markdown,不要多余说明。
  3114. 10. 文件命名空间:每份表的最前面加一行 filename 作为起始标记(例:出国个人申请表.doc)。
  3115. 11. 内容为空的字段,显示标题,记空值。
  3116. 12. 只返回json结果,不需要其他内容;json内容去掉换行。");
  3117. var messages = new List<SeedMessages>
  3118. {
  3119. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  3120. new() { Role = KimiRole.user, Content = seedMessage }
  3121. };
  3122. messages.InsertRange(1, seedConter);
  3123. string jsonString = string.Empty;
  3124. object jsonData = null;
  3125. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  3126. while (!isJson)
  3127. {
  3128. kimiAI_API_Index++;
  3129. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  3130. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3131. jsonString += kimiApiResult_JObject["content"].ToString();
  3132. string startStr = "```json", endStr = "```";
  3133. // 判断并清除开头部分
  3134. if (jsonString.StartsWith(startStr))
  3135. {
  3136. jsonString = jsonString.Replace(startStr, "");
  3137. }
  3138. // 判断并清除结尾部分
  3139. if (jsonString.EndsWith(endStr))
  3140. {
  3141. jsonString = jsonString.Replace(endStr, "");
  3142. }
  3143. //验证json格式是否正确
  3144. try
  3145. {
  3146. jsonData = JsonDocument.Parse(jsonString);
  3147. isJson = true; // 如果解析成功,则是json格式
  3148. }
  3149. catch (Exception)
  3150. {
  3151. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  3152. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  3153. }
  3154. }
  3155. if (jsonData == null)
  3156. {
  3157. return Ok(JsonView(false, "kimi识别json转换失败。"));
  3158. }
  3159. var visaDetails = new VisaDetailsView();
  3160. //按照表格类型分别进行参数处理
  3161. // 1. 澳新签证个人申请表
  3162. // 2. 出国个人申请表
  3163. // 3. 美国签证个人申请表格
  3164. // 4. 沙特个人信息表格
  3165. // 5. 申根签证个人资料表
  3166. // 6. 中文个人简历模板
  3167. switch (fileTypeId)
  3168. {
  3169. //澳新签证个人申请表
  3170. case 1:
  3171. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3172. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  3173. break;
  3174. //美国签证个人申请表格
  3175. case 3:
  3176. _logger.LogInformation("【签证上传文件操作信息】【美国签证个人申请表格】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3177. string name = (string)jsonData.GetType().GetProperty("姓名")!.GetValue(jsonData)!;
  3178. string passportNo = (string)jsonData.GetType().GetProperty("护照号码")!.GetValue(jsonData)!;
  3179. string passportPlace = (string)jsonData.GetType().GetProperty("护照签发地")!.GetValue(jsonData)!;
  3180. string idNo = (string)jsonData.GetType().GetProperty("身份证号码")!.GetValue(jsonData)!;
  3181. string maritalStatusText = (string)jsonData.GetType().GetProperty("婚姻状况")!.GetValue(jsonData)!;
  3182. int maritalStatus = maritalStatusText switch
  3183. {
  3184. "未设置" => 0,
  3185. "未婚" => 1,
  3186. "已婚" => 2,
  3187. "离异" => 3,
  3188. "丧偶" => 4,
  3189. _ => -1
  3190. };
  3191. string birthDay = (string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!;
  3192. DateTime.TryParse(birthDay, out DateTime birthDayDt);
  3193. string birthPlace = (string)jsonData.GetType().GetProperty("出生地点")!.GetValue(jsonData)!;
  3194. var birthDay1 = CommonFun.SplitProvinceCity(birthPlace);
  3195. string birthDay_mate = (string)jsonData.GetType().GetProperty("配偶出生日期")!.GetValue(jsonData)!;
  3196. DateTime.TryParse(birthDay_mate, out DateTime birthDayDt_mate);
  3197. string birthPlace_mate = (string)jsonData.GetType().GetProperty("配偶出生地")!.GetValue(jsonData)!;
  3198. var birthDay1_mate = CommonFun.SplitProvinceCity(birthPlace_mate);
  3199. var addressText = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3200. var address = SplitAddressZip(addressText);
  3201. //美国驾照信息
  3202. string driveText = (string)jsonData.GetType().GetProperty("是否有美国驾照")!.GetValue(jsonData)!;
  3203. var driveInfo = LicenseParser(driveText);
  3204. //美国社会安全号或者纳税ID号
  3205. string ssnText = (string)jsonData.GetType().GetProperty("是否有美国社会安全号或者纳税ID号")!.GetValue(jsonData)!;
  3206. //单位信息
  3207. string clientName = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校")!.GetValue(jsonData)!;
  3208. string clientAddr = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校地址")!.GetValue(jsonData)!;//
  3209. var (hasSsnItin, number) = SsnItinParser(ssnText);
  3210. //婚姻相关
  3211. var WeddingText = (string)jsonData.GetType().GetProperty("若离婚,婚姻起止时间")!.GetValue(jsonData)!;
  3212. var (f, t) = WeddingParser(WeddingText);
  3213. //美国联系人电话和邮箱
  3214. var peText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  3215. var usa_phone = Regex.Match(peText ?? "", @"[\d-]+").Value; // 数字和中横线
  3216. var usa_email = Regex.Match(peText ?? "", @"[^@\s]+@[^@\s]+\.[^@\s]+").Value;
  3217. //赴美时间、停留时间处理
  3218. var usa_dateText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  3219. var (usa_d, usa_days) = TravelParser(usa_dateText);
  3220. //赴美同行人
  3221. string usaCmpNameText = (string)jsonData.GetType().GetProperty("赴美同行人")!.GetValue(jsonData)!;
  3222. string usaCmpName = string.Empty;
  3223. if (usaCmpNameText.Contains("是"))
  3224. {
  3225. var usaCmpNameTextSplit = usaCmpNameText.Replace(":", "-").Replace("", "-").Split("-");
  3226. if (usaCmpNameTextSplit.Length > 1)
  3227. {
  3228. usaCmpName = usaCmpNameTextSplit[1];
  3229. }
  3230. }
  3231. //是否丢失过护照
  3232. string loseCodeText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  3233. string loseCode = string.Empty;
  3234. if (loseCodeText.Contains("是"))
  3235. {
  3236. var loseCodeTextSplit = loseCodeText.Replace(":", "-").Replace("", "-").Split("-");
  3237. if (loseCodeTextSplit.Length > 1)
  3238. {
  3239. usaCmpName = loseCodeTextSplit[1];
  3240. }
  3241. }
  3242. //是否获得过美国签证
  3243. string usaVisaText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  3244. string usaVisaDateText = (string)jsonData.GetType().GetProperty("获得日期")!.GetValue(jsonData)!;
  3245. //DateTime usaVisaDate;
  3246. if (!string.IsNullOrEmpty(usaVisaDateText))
  3247. {
  3248. if (DateTime.TryParse(usaVisaDateText, out DateTime usaVisaDate))
  3249. {
  3250. visaDetails.ClientInfo.GetUSAVisaDate = usaVisaDate;
  3251. }
  3252. }
  3253. string usaFingerText = (string)jsonData.GetType().GetProperty("是否留过十指指纹")!.GetValue(jsonData)!;
  3254. int usaFinger = 0;
  3255. if (usaFingerText.Contains('是')) usaFinger = 1;
  3256. string usaLoseText = (string)jsonData.GetType().GetProperty("签证是否曾遗失")!.GetValue(jsonData)!;
  3257. int usaLose = 0;
  3258. if (usaLoseText.Contains("是")) usaLose = 1;
  3259. //是否曾抵达过美国
  3260. string usaHadArrival‌Text = (string)jsonData.GetType().GetProperty("是否曾抵达过美国")!.GetValue(jsonData)!;
  3261. var (usaHadArrivalf, usaHadArrivalD, usaHadArrivalDays) = TravelHadFlagParser(usaHadArrival‌Text);
  3262. //是否有被美国拒发签证的经历
  3263. string usaRejecteVisaTest = (string)jsonData.GetType().GetProperty("是否有被美国拒发签证的经历")!.GetValue(jsonData)!;
  3264. var (denied, rejectedDate, rejectedPlace, rejectedType) = VisaDenialParser(usaRejecteVisaTest);
  3265. if (denied)
  3266. {
  3267. visaDetails.ClientInfo.RejectedDate = rejectedDate;
  3268. visaDetails.ClientInfo.RejectedPlace = rejectedPlace;
  3269. visaDetails.ClientInfo.RejectedVisa = rejectedType;
  3270. }
  3271. //是否在申请或曾经申请过美国移民签证
  3272. string usaImmVisaText‌ = (string)jsonData.GetType().GetProperty("是否在申请或曾经申请过美国移民签证")!.GetValue(jsonData)!;
  3273. var (immDenied, immDate, immPlace, immType) = VisaDenialParser(usaImmVisaText‌);
  3274. if (immDenied)
  3275. {
  3276. visaDetails.ClientInfo.USAImmVisa‌Date = immDate;
  3277. visaDetails.ClientInfo.USAImmVisa‌Place = immPlace;
  3278. visaDetails.ClientInfo.USAImmVisa‌ = immType;
  3279. }
  3280. //在美直系
  3281. string usaImmedText‌ = (string)jsonData.GetType().GetProperty("是否有直系亲属在美国")!.GetValue(jsonData)!;
  3282. var (immedDenied, immedName, immedRel, immedStat) = FourFieldParser(usaImmedText‌);
  3283. if (immedDenied)
  3284. {
  3285. visaDetails.ClientInfo.USAImmedFamName = immedName;
  3286. visaDetails.ClientInfo.USAImmedFamRel = immedRel;
  3287. visaDetails.ClientInfo.USAImmedFamStat = immedStat;
  3288. }
  3289. //在美旁系
  3290. string usaUncleText‌ = (string)jsonData.GetType().GetProperty("是否有旁系亲属在美国")!.GetValue(jsonData)!;
  3291. var (uncleDenied, uncleName, uncleRel, uncleStat) = FourFieldParser(usaUncleText‌);
  3292. if (immedDenied)
  3293. {
  3294. visaDetails.ClientInfo.USAUncleFamName = uncleName;
  3295. visaDetails.ClientInfo.USAUncleFamRel = uncleName;
  3296. visaDetails.ClientInfo.USAUncleFamStat = uncleStat;
  3297. }
  3298. //服役时间 MilitaryParser
  3299. string militaryText‌ = (string)jsonData.GetType().GetProperty("是否曾参过军")!.GetValue(jsonData)!;
  3300. var (militaryH, militaryB, militaryR, militaryS, (militaryStart, militaryEnd)) = MilitaryParser(militaryText‌);
  3301. var militarys = new List<MilitaryInfo>();
  3302. if (militaryH)
  3303. {
  3304. militarys.Add(new()
  3305. {
  3306. MilBranch = militaryB,
  3307. MilRank = militaryR,
  3308. MilSkill = militaryS,
  3309. ServeTimeBegin = militaryStart,
  3310. ServeTimeEnd = militaryEnd,
  3311. });
  3312. }
  3313. //申请人父母信息 ParentParser
  3314. string fthMthText‌ = (string)jsonData.GetType().GetProperty("申请人父母信息")!.GetValue(jsonData)!;
  3315. if (!string.IsNullOrEmpty(fthMthText‌))
  3316. {
  3317. var (fName, fDob, mName, mDob) = ParentParser(fthMthText‌);
  3318. visaDetails.ClientInfo.FthName = fName;
  3319. visaDetails.ClientInfo.FthBirth = fDob;
  3320. visaDetails.ClientInfo.MthName = mName;
  3321. visaDetails.ClientInfo.MthBirth = mDob;
  3322. }
  3323. visaDetails.ClientInfo = new()
  3324. {
  3325. LastName = name.GetLastName(),
  3326. FirstName = name.GetFirstName(),
  3327. Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1,
  3328. OldName = (string)jsonData.GetType().GetProperty("曾用名")!.GetValue(jsonData)!,
  3329. BirthDay = birthDayDt,
  3330. BirthProvince = birthDay1.province,
  3331. BirthCity = birthDay1.city,
  3332. Address = address.address,
  3333. PostCodes = address.zipCode,
  3334. Marriage = maritalStatus,
  3335. MateName = (string)jsonData.GetType().GetProperty("配偶姓名")!.GetValue(jsonData)!,
  3336. MateBirthDay = birthDayDt_mate,
  3337. MateBirthCountry = birthDay1_mate.province,
  3338. MateBirthCity = birthDay1_mate.city,
  3339. USA_DLNo = driveInfo.number,
  3340. USA_DLPlace = driveInfo.place,
  3341. USA_SSNOrITIN = number,
  3342. Resident = CleanPrefix((string)jsonData.GetType().GetProperty("是否是其他国家的永久居民")!.GetValue(jsonData)!),
  3343. HasSocialAcc‌ = CleanPrefix((string)jsonData.GetType().GetProperty("近五年内是否使用过任何社交账号")!.GetValue(jsonData)!),
  3344. WeddingDate = f,
  3345. DivorceDate = t,
  3346. DivorceRsn = (string)jsonData.GetType().GetProperty("离婚原因")!.GetValue(jsonData)!,
  3347. Job = (string)jsonData.GetType().GetProperty("职务")!.GetValue(jsonData)!,
  3348. Wage = (string)jsonData.GetType().GetProperty("月薪")!.GetValue(jsonData)!,
  3349. WorkState = (string)jsonData.GetType().GetProperty("工作职责")!.GetValue(jsonData)!,
  3350. WorkDate = (string)jsonData.GetType().GetProperty("入职/入学时间(详细到月)")!.GetValue(jsonData)!,
  3351. USAAddress = (string)jsonData.GetType().GetProperty("请提供美国详细住址")!.GetValue(jsonData)!,
  3352. USAPurpose = (string)jsonData.GetType().GetProperty("赴美目的")!.GetValue(jsonData)!,
  3353. CostBearers = (string)jsonData.GetType().GetProperty("费用谁付")!.GetValue(jsonData)!,
  3354. USAContact = (string)jsonData.GetType().GetProperty("美国联系人或组织")!.GetValue(jsonData)!,
  3355. USAContactTel = usa_phone,
  3356. USAContactEmail = usa_email,
  3357. USADate = usa_d,
  3358. USADays = usa_days,
  3359. USAArrivalCity‌ = (string)jsonData.GetType().GetProperty("赴美的到达城市")!.GetValue(jsonData)!,
  3360. USADepartCity‌ = (string)jsonData.GetType().GetProperty("赴美的离开城市")!.GetValue(jsonData)!,
  3361. USAVisitSites‌ = (string)jsonData.GetType().GetProperty("计划在美国访问的景点")!.GetValue(jsonData)!,
  3362. USACmpName = usaCmpName,
  3363. USACmpRelation = (string)jsonData.GetType().GetProperty("同行人关系")!.GetValue(jsonData)!,
  3364. Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!,
  3365. ClientPhone = (string)jsonData.GetType().GetProperty("单位电话")!.GetValue(jsonData)!,
  3366. Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!,
  3367. Cntry5Y‌ = (string)jsonData.GetType().GetProperty("过去5年内到过的国家")!.GetValue(jsonData)!,
  3368. LangSkill‌ = (string)jsonData.GetType().GetProperty("面签时能流利交流的语言")!.GetValue(jsonData)!,
  3369. LoseCode = loseCode,
  3370. DenyNationRsn = (string)jsonData.GetType().GetProperty("曾被哪些国家拒签/拒签原因")!.GetValue(jsonData)!,
  3371. USAVisaCode = (string)jsonData.GetType().GetProperty("签证号码")!.GetValue(jsonData)!,
  3372. USAVisaCate = (string)jsonData.GetType().GetProperty("获签类型")!.GetValue(jsonData)!,
  3373. //GetUSAVisaDate = usaVisaDate,
  3374. USAFinger = usaFinger,
  3375. IsLose = usaLose,
  3376. USAHadArrival = usaHadArrivalD,
  3377. USAHadDays = usaHadArrivalDays,
  3378. ArmyState = JsonConvert.SerializeObject(militarys)
  3379. };
  3380. visaDetails.ClientCerts = new() {
  3381. new(){ SdId = 74,CertNo = passportNo,IDCardAddress = passportPlace },
  3382. new(){ SdId = 73,CertNo = idNo},
  3383. };
  3384. visaDetails.ClientCompany = new() { CompanyFullName = clientName, Address = clientAddr };
  3385. break;
  3386. //中文个人简历模板
  3387. case 6:
  3388. _logger.LogInformation("【签证上传文件操作信息】【中文个人简历模板】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3389. visaDetails.ClientInfo.LastName = (string)jsonData.GetType().GetProperty("姓名(中英文拼音)")!.GetValue(jsonData)!;
  3390. visaDetails.ClientInfo.Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1;
  3391. DateTime.TryParse((string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!, out DateTime birthDay11);
  3392. visaDetails.ClientInfo.BirthDay = birthDay11;
  3393. visaDetails.ClientInfo.BirthProvince = (string)jsonData.GetType().GetProperty("出生地")!.GetValue(jsonData)!;
  3394. visaDetails.ClientInfo.Address = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3395. visaDetails.ClientInfo.Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!;
  3396. visaDetails.ClientInfo.TableOpTel = (string)jsonData.GetType().GetProperty("工作电话")!.GetValue(jsonData)!;
  3397. visaDetails.ClientInfo.Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!;
  3398. visaDetails.ClientInfo.Email = (string)jsonData.GetType().GetProperty("电子邮件")!.GetValue(jsonData)!;
  3399. //学校信息
  3400. visaDetails.ClientSchools.Add(new()
  3401. {
  3402. School = (string)jsonData.GetType().GetProperty("教育学校名称")!.GetValue(jsonData)!,
  3403. Education = (string)jsonData.GetType().GetProperty("教育学位")!.GetValue(jsonData)!,
  3404. Subject = (string)jsonData.GetType().GetProperty("教育专业")!.GetValue(jsonData)!,
  3405. Remark = (string)jsonData.GetType().GetProperty("教育论文题目/研究重点(硕士、博士)")!.GetValue(jsonData)!,
  3406. });
  3407. //工作信息
  3408. visaDetails.ClientCompany = new()
  3409. {
  3410. CompanyFullName = (string)jsonData.GetType().GetProperty("工作经历雇主")!.GetValue(jsonData)!,
  3411. };
  3412. visaDetails.ClientInfo.Job = (string)jsonData.GetType().GetProperty("工作经历职位或头衔职责")!.GetValue(jsonData)!;
  3413. break;
  3414. default:
  3415. break;
  3416. }
  3417. //数据提交
  3418. #region 数据提交
  3419. _sqlSugar.BeginTran();
  3420. // 客户公司表
  3421. var compId = UpsertReturnId<Crm_CustomerCompany>(visaDetails.ClientCompany, o => o.CompanyFullName);
  3422. if (compId < 1)
  3423. {
  3424. _sqlSugar.RollbackTran();
  3425. return Ok(JsonView(false, "公司信息更新失败!"));
  3426. }
  3427. visaDetails.ClientInfo.CrmCompanyId = compId;
  3428. // 客户资料表
  3429. var clientId = UpsertReturnId<Crm_DeleClient>(visaDetails.ClientInfo, o => new { o.LastName, o.FirstName });
  3430. if (clientId < 1)
  3431. {
  3432. _sqlSugar.RollbackTran();
  3433. return Ok(JsonView(false, "客户信息更新失败!"));
  3434. }
  3435. for (int i = 0; i < visaDetails.ClientFamilys.Count(); i++)
  3436. {
  3437. visaDetails.ClientFamilys[i].DcId = clientId;
  3438. }
  3439. for (int i = 0; i < visaDetails.ClientCerts.Count(); i++)
  3440. {
  3441. visaDetails.ClientCerts[i].DcId = clientId;
  3442. }
  3443. for (int i = 0; i < visaDetails.ClientSchools.Count(); i++)
  3444. {
  3445. visaDetails.ClientSchools[i].DcId = clientId;
  3446. }
  3447. // 客户家庭表
  3448. foreach (var item in visaDetails.ClientFamilys)
  3449. {
  3450. var famId = UpsertReturnId<Crm_VisaCustomerFamily>(item, o => o.Name);
  3451. if (famId < 1)
  3452. {
  3453. _sqlSugar.RollbackTran();
  3454. return Ok(JsonView(false, "客户家庭信息更新失败!"));
  3455. }
  3456. }
  3457. // 客户证件表
  3458. foreach (var item in visaDetails.ClientCerts)
  3459. {
  3460. var certId = UpsertReturnId<Crm_CustomerCert>(item, o => o.CertNo);
  3461. if (certId < 1)
  3462. {
  3463. _sqlSugar.RollbackTran();
  3464. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3465. }
  3466. }
  3467. // 客户学历表
  3468. foreach (var item in visaDetails.ClientSchools)
  3469. {
  3470. var schoolId = UpsertReturnId<Crm_VisaCustomerSchool>(item, o => o.School);
  3471. if (schoolId < 1)
  3472. {
  3473. _sqlSugar.RollbackTran();
  3474. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3475. }
  3476. }
  3477. _sqlSugar.CommitTran();
  3478. #endregion
  3479. #endregion
  3480. return Ok(JsonView(true, jsonString));
  3481. }
  3482. #region 扩展处理
  3483. // 从 Expression<Func<T,object>> 里取出属性名
  3484. static string GetPropName<T>(Expression<Func<T, object>> expr)
  3485. {
  3486. if (expr.Body is UnaryExpression ue) expr = Expression.Lambda<Func<T, object>>(ue.Operand, expr.Parameters);
  3487. return ((MemberExpression)expr.Body).Member.Name;
  3488. }
  3489. /// <summary>
  3490. /// 5.1.4.193 可用:存在更新(非NULL非空串),不存在插入,返回主键ID
  3491. /// </summary>
  3492. public int UpsertReturnId<T>(T entity, Expression<Func<T, object>> whereExpr) where T : class, new()
  3493. {
  3494. // 1. 空字符串→NULL,让后续忽略
  3495. foreach (var pi in typeof(T).GetProperties())
  3496. if (pi.PropertyType == typeof(string) &&
  3497. pi.GetValue(entity) is string s &&
  3498. string.IsNullOrWhiteSpace(s))
  3499. pi.SetValue(entity, null);
  3500. // 2. 从表达式里拿属性名
  3501. string propName = GetPropName(whereExpr);
  3502. var propValue = typeof(T).GetProperty(propName)?.GetValue(entity);
  3503. // 3. 判断存在
  3504. bool exists = _sqlSugar.Queryable<T>().Where(propName, propValue).Any();
  3505. // 4. 执行 Upsert
  3506. if (exists)
  3507. {
  3508. _sqlSugar.Updateable(entity)
  3509. .WhereColumns(propName) // 指定条件列
  3510. .IgnoreColumns(ignoreAllNullColumns: true) // 忽略 NULL
  3511. .ExecuteCommand();
  3512. }
  3513. else
  3514. {
  3515. _sqlSugar.Insertable(entity).ExecuteReturnIdentity();
  3516. }
  3517. // 5. 返回主键值(自增/雪花已回填)
  3518. var idProp = typeof(T).GetProperties()
  3519. .First(p => p.GetCustomAttributes<SugarColumn>()
  3520. .Any(a => a.IsPrimaryKey));
  3521. return (int)idProp.GetValue(entity)!;
  3522. }
  3523. /// <summary>
  3524. /// 地址喊邮编 相关处理
  3525. /// </summary>
  3526. public static (string address, string zipCode) SplitAddressZip(string? s)
  3527. {
  3528. if (string.IsNullOrWhiteSpace(s))
  3529. return ("", "");
  3530. ReadOnlySpan<char> src = s.AsSpan();
  3531. int i = src.IndexOf("邮编".AsSpan());
  3532. if (i < 0) // 没有“邮编”字样
  3533. return (src.Trim().ToString(), "");
  3534. ReadOnlySpan<char> addr = src[..i].TrimEnd();
  3535. ReadOnlySpan<char> zip = src[(i + 3)..].Trim(); // 跳过“邮编:”
  3536. // 可能只有“邮编:”而没有数字
  3537. return (addr.IsEmpty ? "" : addr.ToString(),
  3538. zip.IsEmpty ? "" : zip.ToString());
  3539. }
  3540. /// <summary>
  3541. /// 驾照相 关处理
  3542. /// </summary>
  3543. /// <param name="raw"></param>
  3544. /// <returns></returns>
  3545. public static (bool hasLicense, string number, string place) LicenseParser(string? raw)
  3546. {
  3547. if (string.IsNullOrWhiteSpace(raw))
  3548. return (false, "", "");
  3549. // 1. 是否持有
  3550. bool has = raw.StartsWith("是", System.StringComparison.OrdinalIgnoreCase) ||
  3551. raw.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3552. // 2. 去掉前缀,按空格切
  3553. ReadOnlySpan<char> s = raw.AsSpan();
  3554. int colon = s.IndexOf(':');
  3555. ReadOnlySpan<char> after = colon < 0 ? s : s[(colon + 1)..];
  3556. after = after.Trim();
  3557. int space = after.IndexOf(' ');
  3558. ReadOnlySpan<char> num = space < 0 ? after : after[..space];
  3559. ReadOnlySpan<char> st = space < 0 ? ReadOnlySpan<char>.Empty : after[(space + 1)..];
  3560. return (has, num.ToString().Trim(), st.ToString().Trim());
  3561. }
  3562. /// <summary>
  3563. /// 美国社会安全号或者纳税ID号 相关处理
  3564. /// </summary>
  3565. /// <param name="raw"></param>
  3566. /// <returns></returns>
  3567. public static (bool hasSsnItin, string number) SsnItinParser(string? raw)
  3568. {
  3569. if (string.IsNullOrWhiteSpace(raw))
  3570. return (false, "");
  3571. ReadOnlySpan<char> s = raw.AsSpan();
  3572. // 1. 是否持有
  3573. bool has = s.StartsWith("是", System.StringComparison.Ordinal) ||
  3574. s.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3575. // 2. 取号码(去掉前缀和空格)
  3576. int colon = s.IndexOf(':');
  3577. ReadOnlySpan<char> num = colon < 0
  3578. ? ReadOnlySpan<char>.Empty
  3579. : s[(colon + 1)..].Trim();
  3580. return (has, num.ToString());
  3581. }
  3582. /// <summary>
  3583. /// 取消开始的“是:”或者“是”或者“ :”
  3584. /// </summary>
  3585. /// <param name="raw"></param>
  3586. /// <returns></returns>
  3587. public static string CleanPrefix(string? raw)
  3588. {
  3589. if (string.IsNullOrWhiteSpace(raw)) return "";
  3590. // 跳过第一个“是”或“Y”
  3591. ReadOnlySpan<char> s = raw.AsSpan();
  3592. int start = 0;
  3593. if (s.StartsWith("是") || s.StartsWith("Y", StringComparison.OrdinalIgnoreCase))
  3594. start = 1;
  3595. // 跳过连续 : 或空格
  3596. while (start < s.Length && (s[start] == ':' || s[start] == ' '))
  3597. start++;
  3598. return s[start..].Trim().ToString();
  3599. }
  3600. /// <summary>
  3601. /// 婚姻起止时间处理
  3602. /// </summary>
  3603. /// <param name="raw"></param>
  3604. /// <returns></returns>
  3605. public static (DateTime? fromDate, DateTime? toDate) WeddingParser(string? raw)
  3606. {
  3607. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3608. Regex _clean = new(@"[\s~至]+", RegexOptions.Compiled);
  3609. // 1. 把所有“空格~至”统一成 '-'
  3610. string normalized = _clean.Replace(raw, "-");
  3611. // 2. 切两段
  3612. string[] parts = normalized.Split('-', StringSplitOptions.RemoveEmptyEntries);
  3613. if (parts.Length != 2) return (null, null);
  3614. // 3. 解析
  3615. bool ff = DateTime.TryParse(parts[0].Trim(), out var from);
  3616. bool tf = DateTime.TryParse(parts[1].Trim(), out var to);
  3617. return (tf ? from : null, tf ? to : null);
  3618. }
  3619. /// <summary>
  3620. /// 出行日期和天数处理
  3621. /// </summary>
  3622. /// <param name="raw"></param>
  3623. /// <returns></returns>
  3624. public static (DateTime? travelDate, int? days) TravelParser(string? raw)
  3625. {
  3626. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3627. // 切成两段:第一段日期,第二段天数
  3628. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3629. string[] parts = sep.Split(raw.Trim());
  3630. if (parts.Length < 2) return (null, null);
  3631. bool okDate = DateTime.TryParse(parts[0], out DateTime date);
  3632. bool okDays = int.TryParse(parts[1], out int days) && days > 0;
  3633. return (okDate ? date : null, okDays ? days : null);
  3634. }
  3635. /// <summary>
  3636. /// 是否曾抵达过美国
  3637. /// </summary>
  3638. /// <param name="raw"></param>
  3639. /// <returns></returns>
  3640. public static (bool hasTravel, string date, string days) TravelHadFlagParser(string? raw)
  3641. {
  3642. if (string.IsNullOrWhiteSpace(raw)) return (false, string.Empty, string.Empty);
  3643. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3644. // 1. 是否持有
  3645. bool has = raw.AsSpan().TrimStart().StartsWith("是") ||
  3646. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3647. // 2. 用非数字分隔符切成三段:第一段空,第二段日期,第三段天数
  3648. string[] parts = sep.Split(raw.Trim());
  3649. if (parts.Length < 3) return (has, string.Empty, string.Empty);
  3650. return (has, parts[1], parts[2]);
  3651. }
  3652. /// <summary>
  3653. /// 是否有被美国拒发签证的经历
  3654. /// </summary>
  3655. /// <param name="raw"></param>
  3656. /// <returns></returns>
  3657. public static (bool wasDenied, DateTime? date, string place, string visaType) VisaDenialParser(string? raw)
  3658. {
  3659. if (string.IsNullOrWhiteSpace(raw)) return (false, null, "", "");
  3660. bool denied = raw.AsSpan().TrimStart().StartsWith("有") ||
  3661. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3662. var parts = Regex.Split(raw.Trim(), @"[^0-9A-Za-z-]+");
  3663. if (parts.Length < 4) return (denied, null, "", "");
  3664. DateTime.TryParse(parts[1], out var dt); // ← 这里改为 DateTime
  3665. return (denied, dt, parts[2], parts[3]);
  3666. }
  3667. /// <summary>
  3668. /// 在美直系、旁系 处理
  3669. /// </summary>
  3670. /// <param name="raw"></param>
  3671. /// <returns></returns>
  3672. public static (bool flag, string name, string rel, string stat) FourFieldParser(string? raw)
  3673. {
  3674. if (string.IsNullOrWhiteSpace(raw)) return (false, "", "", "");
  3675. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3676. if (parts.Length < 4) return (false, "", "", "");
  3677. bool flag = parts[0] is "有" or "是" or "Y" or "Yes";
  3678. string name = parts[1];
  3679. string rel = parts[2];
  3680. string stat = parts[3];
  3681. return (flag, name, rel, stat);
  3682. }
  3683. /// <summary>
  3684. /// 服役时间处理
  3685. /// </summary>
  3686. /// <param name="raw"></param>
  3687. /// <returns></returns>
  3688. public static (bool hasService, string branch, string rank, string specialty, (DateTime? start, DateTime? end) period) MilitaryParser(string? raw)
  3689. {
  3690. const string fmt = "yyyy年MM月dd日";
  3691. if (string.IsNullOrWhiteSpace(raw))
  3692. return (false, "", "", "", (null, null));
  3693. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3694. if (parts.Length < 5) return (false, "", "", "", (null, null));
  3695. bool has = parts[0] is "是" or "Y" or "Yes";
  3696. string branch = parts[1];
  3697. string rank = parts[2];
  3698. string specialty = parts[3];
  3699. // 拼回时间字符串
  3700. string periodRaw = string.Join(" ", parts[4..]);
  3701. var span = periodRaw.AsSpan();
  3702. int zhi = span.IndexOf("至");
  3703. if (zhi < 0) return (has, branch, rank, specialty, (null, null));
  3704. var startStr = span.Slice(0, zhi).Trim();
  3705. var endStr = span.Slice(zhi + 1).Trim();
  3706. bool okStart = DateTime.TryParseExact(startStr.ToString(), fmt, null, DateTimeStyles.None, out var start);
  3707. bool okEnd = DateTime.TryParseExact(endStr.ToString(), fmt, null, DateTimeStyles.None, out var end);
  3708. return (has, branch, rank, specialty, (okStart ? start : null, okEnd ? end : null));
  3709. }
  3710. /// <summary>
  3711. /// 申请人父母信息
  3712. /// </summary>
  3713. /// <param name="raw"></param>
  3714. /// <returns></returns>
  3715. public static (string fatherName, DateTime? fatherDob, string motherName, DateTime? motherDob) ParentParser(string? raw)
  3716. {
  3717. const string fmt = "yyyy年MM月dd日";
  3718. if (string.IsNullOrWhiteSpace(raw)) return ("", null, "", null);
  3719. // 按空格切,去掉空元素
  3720. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3721. if (parts.Length < 4) return ("", null, "", null);
  3722. // 父亲
  3723. string fName = parts[0];
  3724. DateTime.TryParseExact(parts[1], fmt, null, DateTimeStyles.None, out var fDob);
  3725. // 母亲
  3726. string mName = parts[2];
  3727. DateTime.TryParseExact(parts[3], fmt, null, DateTimeStyles.None, out var mDob);
  3728. return (fName, fDob, mName, mDob);
  3729. }
  3730. public class VisaDetailsView
  3731. {
  3732. /// <summary>
  3733. /// 客户资料表
  3734. /// </summary>
  3735. public Crm_DeleClient ClientInfo { get; set; }
  3736. /// <summary>
  3737. /// 客户家庭表
  3738. /// </summary>
  3739. public List<Crm_VisaCustomerFamily> ClientFamilys { get; set; }
  3740. /// <summary>
  3741. /// 客户公司表
  3742. /// </summary>
  3743. public Crm_CustomerCompany ClientCompany { get; set; }
  3744. /// <summary>
  3745. /// 客户证件表
  3746. /// </summary>
  3747. public List<Crm_CustomerCert> ClientCerts { get; set; }
  3748. /// <summary>
  3749. /// 客户学历表
  3750. /// </summary>
  3751. public List<Crm_VisaCustomerSchool> ClientSchools { get; set; }
  3752. }
  3753. private int GetSuccessCount(List<FileUploadResult> results)
  3754. {
  3755. var count = 0;
  3756. foreach (var result in results)
  3757. {
  3758. if (result.Success) count++;
  3759. }
  3760. return count;
  3761. }
  3762. #endregion
  3763. #region 文件下载
  3764. /// <summary>
  3765. /// 签证下载类型初始化
  3766. /// </summary>
  3767. private readonly static Dictionary<int, string> _visaTypeInit = new()
  3768. {
  3769. { 1, "美国" },
  3770. { 2, "日本" },
  3771. { 3, "韩国" },
  3772. { 4, "瑞典" },
  3773. { 5, "波兰" },
  3774. };
  3775. //申根国
  3776. private readonly static string[] _shenGenGuos = new string[] { "奥地利", "比利时", "丹麦", "芬兰", "法国", "德国", "冰岛", "意大利", "希腊", "卢森堡", "荷兰", "挪威", "葡萄牙", "西班牙",
  3777. "瑞典", "匈牙利", "捷克", "斯洛伐克", "斯洛文尼亚","波兰","爱沙尼亚","拉脱维亚","立陶宛","马耳他","瑞士","列支敦士登" };
  3778. //欧盟国家
  3779. private readonly static string[] _eucountries = new string[] { "奥地利", "比利时", "丹麦", "芬兰", "法国", "德国", "意大利", "希腊", "卢森堡", "荷兰", "葡萄牙", "西班牙","爱尔兰","罗马尼亚",
  3780. "保加利亚","匈牙利", "捷克", "斯洛伐克", "斯洛文尼亚","波兰","爱沙尼亚","拉脱维亚","立陶宛","马耳他","瑞士","列支敦士登" };
  3781. //欧洲国家
  3782. private readonly static string[] _aBC = new string[] { "英国", "爱尔兰" };
  3783. /// <summary>
  3784. /// 团组&签证 New
  3785. /// 签证文申请表下载
  3786. /// </summary>
  3787. /// <param name="groupId">
  3788. /// <param name="fileTypeId">
  3789. /// </param>
  3790. /// <returns></returns>
  3791. [HttpGet]
  3792. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3793. public async Task<IActionResult> VisaFileDownload(int groupId, int fileTypeId)
  3794. {
  3795. if (!_visaTypeInit.TryGetValue(fileTypeId, out _))
  3796. {
  3797. return Ok(JsonView(false, "请选择正确的文件类型!"));
  3798. }
  3799. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == groupId).First();
  3800. if (groupInfo == null)
  3801. {
  3802. return Ok(JsonView(false, "团组信息不存在!"));
  3803. }
  3804. //访问路径
  3805. var serverPath = $"http://132.232.92.186:24/Word/VisaClientData/Downloads/{groupInfo.TeamName}/";
  3806. //模板存储位置
  3807. var tempPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Template/";
  3808. //服务器存储文件位置
  3809. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Downloads/{groupInfo.TeamName}/";
  3810. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  3811. //文件生成路径
  3812. string url = string.Empty;
  3813. //基础数据
  3814. //团组客户名单
  3815. var groupClients = await _sqlSugar.Queryable<Grp_TourClientList>()
  3816. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  3817. .Select(x => x.ClientId)
  3818. .ToListAsync();
  3819. if (groupClients.Count < 1)
  3820. {
  3821. return Ok(JsonView(false, "该团组下暂无团组名单!"));
  3822. }
  3823. //团组客户详细信息
  3824. var groupCustInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.IsDel == 0 && groupClients.Contains(x.Id)).ToList();
  3825. //家庭成员资料
  3826. var familyInfos = _sqlSugar.Queryable<Crm_VisaCustomerFamily>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3827. //公司资料
  3828. var companyInfo‌‌s = _sqlSugar.Queryable<Crm_VisaCustomerCompany>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3829. //学校资料
  3830. var schoolInfos = _sqlSugar.Queryable<Crm_VisaCustomerSchool>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3831. /* 证件类型
  3832. *
  3833. * 773 身份证
  3834. * 774 护照
  3835. * 775 学生证
  3836. * 776 军人证
  3837. * 777 回乡证
  3838. * 778 台胞证
  3839. * 779 港澳通行证
  3840. * 780 国际海员证
  3841. * 781 外国人永久居留证
  3842. * 782 旅行证
  3843. * 783 台湾通行证
  3844. * 784 港澳台居住证
  3845. * 785 其他
  3846. */
  3847. //证件资料
  3848. var certInfos = _sqlSugar.Queryable<Crm_CustomerCert>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3849. //利用字典创建书签与书签的值的键值对,第一个string为键,第二个string为值
  3850. var applyDate = DateTime.Now.ToString("yyyy-MM-dd");
  3851. var filePaths = new List<string>();
  3852. var visaTypeName = string.Empty;
  3853. var currTempPath = string.Empty;
  3854. switch (fileTypeId)
  3855. {
  3856. case 1: // 美国
  3857. visaTypeName = $"美国签证申请表";
  3858. currTempPath = $"{tempPath}{visaTypeName}.doc";
  3859. var usaSavePath = $"{fileServerPath}{visaTypeName}/";
  3860. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(usaSavePath);
  3861. foreach (var custInfo in groupCustInfos)
  3862. {
  3863. //解密
  3864. EncryptionProcessor.DecryptProperties(custInfo);
  3865. Dictionary<string, string> dics = new();
  3866. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  3867. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  3868. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  3869. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  3870. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  3871. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  3872. #region 美国签证模板书签值处理
  3873. dics.Add("LastNameEn", custInfo?.LastName ?? "");//名拼音
  3874. dics.Add("FirstNameEn", custInfo?.FirstName ?? "");//姓拼音
  3875. dics.Add("LastName", custInfo?.LastName ?? "");//名
  3876. dics.Add("FirstName", custInfo?.FirstName ?? "");//姓
  3877. dics.Add("OldNameEn", custInfo?.OldName ?? "");//曾用姓名拼音
  3878. dics.Add("OldName", custInfo?.FirstName ?? "");//曾用姓名
  3879. //未设置、未婚、已婚、离异、丧偶
  3880. var marriage = custInfo.Marriage switch
  3881. {
  3882. 0 => "未设置",
  3883. 1 => "未婚",
  3884. 2 => "已婚",
  3885. 3 => "离异",
  3886. 4 => "丧偶",
  3887. _ => "未知"
  3888. };
  3889. dics.Add("Marriage", marriage);//婚姻状况
  3890. dics.Add("Phone", custInfo?.Phone ?? "");//家庭电话
  3891. dics.Add("BirthCity", custInfo?.BirthCity ?? "");//出生城市
  3892. dics.Add("BirthProvince", custInfo?.BirthProvince ?? "");//出生省份
  3893. string m_idCard = idInfo?.CertNo ?? "";
  3894. string m_birthday = string.Empty;
  3895. if (!string.IsNullOrEmpty(m_idCard))
  3896. {
  3897. string m_year = m_idCard.Substring(6, 4);
  3898. string m_month = m_idCard.Substring(10, 2);
  3899. string m_day = m_idCard.Substring(12, 2);
  3900. m_birthday = m_year + "." + m_month + "." + m_day;
  3901. }
  3902. dics.Add("BirthDay", m_birthday);//出生日期
  3903. dics.Add("Tel", custInfo?.Tel ?? "");//移动电话
  3904. dics.Add("Email", custInfo?.Email ?? "");//电子信箱
  3905. dics.Add("IdCard", m_idCard);//身份证号码
  3906. dics.Add("Address", custInfo?.Address ?? "");//现居家庭地址
  3907. dics.Add("PostCodes", custInfo?.PostCodes ?? "");//邮编
  3908. dics.Add("Client", clinetInfo?.Company ?? "");//单位名称
  3909. dics.Add("ClientAddress", clinetInfo?.CompanyAddress ?? "");//单位地址
  3910. dics.Add("ClientPostCodes", custInfo?.PostCodes ?? "");//单位邮编
  3911. dics.Add("Job", custInfo?.Job ?? "");//职务
  3912. dics.Add("WorkDate", custInfo?.WorkDate ?? "");//入职时间
  3913. dics.Add("Wage", custInfo?.Wage ?? "");//月薪
  3914. dics.Add("ClientPhone", custInfo?.ClientPhone ?? "");//单位电话
  3915. dics.Add("ClientFax", custInfo?.ClientFax ?? "");//单位传真
  3916. dics.Add("ClientEmail", custInfo?.ClientEmail ?? "");//单位邮箱
  3917. dics.Add("ClientLeader", custInfo?.ClientLeader ?? "");//单位主管姓名
  3918. dics.Add("ClientLeaderJob", custInfo?.ClientLeaderJob ?? "");//单位主管职务
  3919. dics.Add("WorkState", custInfo?.WorkState ?? "");//工作内容简单介绍
  3920. dics.Add("IsGetSchengen", custInfo?.IsGetSchengen == 0 ? "否" : "是");//是否有获批的申根签证
  3921. dics.Add("StartTime", custInfo?.StartTime.ToString("yyyy-MM-dd") ?? "");//申根签证有效期开始
  3922. dics.Add("EndTime", custInfo?.EndTime.ToString("yyyy-MM-dd") ?? "");//申根签证有效期结束
  3923. dics.Add("IsFinger", custInfo.IsFinger == 0 ? "否" : "是");//申根签证是否有指纹记录
  3924. dics.Add("FingerDate", custInfo?.FingerDate.ToString("yyyy-MM-dd") ?? "");//申根签指纹采集时间
  3925. dics.Add("TableOpName", custInfo?.TableOpName ?? "");//填表经办人
  3926. dics.Add("TableOpTel", custInfo?.TableOpTel ?? "");//填表经办人联系电话
  3927. dics.Add("TableDate", custInfo?.TableDate.ToString("yyyy-MM-dd") ?? "");//填表日期
  3928. dics.Add("Party", custInfo?.Party ?? "");//所属党派或宗教
  3929. dics.Add("Nationality", custInfo?.Nationality ?? "");//国籍
  3930. var sex = custInfo.Sex switch
  3931. {
  3932. 0 => "男",
  3933. 1 => "女",
  3934. _ => "未知"
  3935. };
  3936. dics.Add("Sex", sex);//性别
  3937. dics.Add("WeddingDate", custInfo?.WeddingDate?.ToString("yyyy-MM-dd") ?? "");//结婚日期
  3938. dics.Add("DivorceDate", custInfo?.DivorceDate?.ToString("yyyy-MM-dd") ?? "");//离婚日期
  3939. dics.Add("MateName", custInfo?.MateName ?? "");//配偶姓名
  3940. dics.Add("MateBirthDay", custInfo?.MateBirthDay.ToString("yyyy-MM-dd") ?? "");//配偶出生日期
  3941. dics.Add("MateBirthCity", custInfo?.MateBirthCity ?? "");//配偶出生城市
  3942. dics.Add("MateBirthCountry", custInfo?.MateBirthCountry ?? "");//配偶出生省份
  3943. dics.Add("MateAddress", custInfo?.MateAddress ?? "");//配偶住址
  3944. dics.Add("MateClient", custInfo?.MateClient ?? "");//配偶工作单位名称
  3945. dics.Add("MateClientAddress", custInfo?.MateClientAddress ?? "");//配偶工作单位地址
  3946. dics.Add("MateJob", custInfo?.MateJob ?? "");//配偶职务
  3947. dics.Add("VisitCountry", custInfo?.VisitCountry ?? "");//因公出访的国家
  3948. dics.Add("Paper", custInfo?.Paper ?? "");//发表的期刊、论文
  3949. dics.Add("Papent", custInfo?.Papent ?? "");//专利
  3950. dics.Add("PhD", custInfo?.PhD ?? "");//博士论文
  3951. dics.Add("IsVisitUC", custInfo?.IsVisitUC == 0 ? "否" : "是" ?? "");//是否因公去过美国/加拿大
  3952. dics.Add("USADate", custInfo?.USADate?.ToString("yyyy-MM-dd") ?? "");//美国抵达日期
  3953. dics.Add("USADays", custInfo?.USADays.ToString() ?? "");//美国停留天数
  3954. dics.Add("CanDate", custInfo?.CanDate.ToString("yyyy-MM-dd") ?? "");//加拿大抵达日期
  3955. dics.Add("CanDays", custInfo?.CanDays.ToString() ?? "");//加拿大停留天数
  3956. dics.Add("IsUSAVia", custInfo?.IsUSAVia == 0 ? "否" : "是" ?? "");//是否获得过因公美国签证
  3957. dics.Add("GetUSAVisaDate", custInfo?.GetUSAVisaDate.ToString("yyyy-MM-dd") ?? "");//因公美国签证时间
  3958. dics.Add("GetUPPlace", custInfo?.GetUPPlace ?? "");//因公美国签证地点
  3959. dics.Add("USAVisaCate", custInfo?.USAVisaCate ?? "");//因公美国签证种类
  3960. dics.Add("USAVisaCode", custInfo?.USAVisaCode ?? "");//因公美国签证编码
  3961. dics.Add("USAFinger", custInfo?.USAFinger == 0 ? "否" : "是" ?? "");//是否在使馆留过十指的指纹
  3962. dics.Add("IsRejected", custInfo?.IsRejected == 0 ? "否" : "是" ?? "");//是否被拒
  3963. dics.Add("RejectedDate", custInfo?.RejectedDate?.ToString("yyyy-MM-dd") ?? "");//被拒时间
  3964. dics.Add("RejectedPlace", custInfo?.RejectedPlace ?? "");//被拒地点
  3965. dics.Add("RejectedVisa", custInfo?.RejectedVisa ?? "");//被拒签证种类
  3966. dics.Add("IsRevoke", custInfo?.IsRevoke == 0 ? "否" : "是" ?? "");//美国签证是否被吊销
  3967. dics.Add("IsLose", custInfo?.IsLose == 0 ? "否" : "是" ?? "");//护照是否丢失
  3968. dics.Add("LoseDate", custInfo?.LoseDate.ToString("yyyy-MM-dd") ?? "");//丢失的护照时间
  3969. dics.Add("LoseCode", custInfo?.LoseCode ?? "");//丢失的护照号码
  3970. dics.Add("IsUSAVisa", custInfo?.IsUSAVisa == 0 ? "否" : "是" ?? "");//丢失的护照是否有美国签证
  3971. dics.Add("MateUSA", custInfo?.MateUSA == 0 ? "否" : "是" ?? "");//夫/妻是否已在美国
  3972. dics.Add("MateIden", custInfo?.MateIden ?? "");//夫/妻身份
  3973. dics.Add("WHUSA", custInfo?.WHUSA == 0 ? "否" : "是" ?? "");//未婚夫/妻是否已在美国
  3974. dics.Add("WHIden", custInfo?.WHIden ?? "");//未婚夫/妻身份
  3975. dics.Add("ParentUSA", custInfo?.ParentUSA == 0 ? "否" : "是" ?? "");//父/母是否已在美国
  3976. dics.Add("ParentIden", custInfo?.ParentIden ?? "");//父/母身份
  3977. dics.Add("ChildUSA", custInfo?.ChildUSA == 0 ? "否" : "是" ?? "");//儿子/女儿是否已在美国
  3978. dics.Add("ChildIden", custInfo?.ChildIden ?? "");//儿子/女儿身份
  3979. dics.Add("BroUSA", custInfo?.BroUSA == 0 ? "否" : "是" ?? "");//兄弟/姐妹是否已在美国
  3980. dics.Add("BroIden", custInfo?.BroIden ?? "");//兄弟/姐妹身份
  3981. dics.Add("Social", custInfo?.Social ?? "");//所属/捐助/工作过的职业协会、社会团体和慈善机构
  3982. dics.Add("IsArmy", custInfo?.IsArmy == 0 ? "否" : "是" ?? "");//是否参军
  3983. dics.Add("ArmyState", custInfo?.ArmyState ?? "");//参军详情
  3984. dics.Add("ApplyDate", applyDate);//申请日期
  3985. //公司信息书签
  3986. if (currCompanyInfos.Count > 0)
  3987. {
  3988. for (int i = 0; i < currCompanyInfos.Count; i++)
  3989. {
  3990. var compnayInfo = currCompanyInfos[i];
  3991. if (!string.IsNullOrEmpty(compnayInfo.Company))
  3992. {
  3993. dics.Add("Company", compnayInfo?.Company ?? "");//公司名称
  3994. dics.Add("CompanyAddress", compnayInfo?.CompanyAddress ?? "");//公司地址
  3995. dics.Add("CompanyPhone", compnayInfo?.Phone ?? "");//公司电话
  3996. dics.Add("CompanyJob", compnayInfo?.Job ?? "");//职务
  3997. dics.Add("CompanyLeaderName", compnayInfo?.LeaderName ?? "");//主管名字
  3998. dics.Add("CompanyWorkStart", compnayInfo?.WorkStart.ToString("yyyy-MM-dd") ?? "");//雇佣起始年月日
  3999. dics.Add("CompanyWorkEnd", compnayInfo?.WorkEnd.ToString("yyyy-MM-dd") ?? "");//雇佣结束年月日
  4000. dics.Add("CompanyWorkState", compnayInfo?.WorkState ?? "");//工作职责及内容简述
  4001. }
  4002. else break;
  4003. }
  4004. }
  4005. //学校信息书签
  4006. if (currSchoolInfos.Count > 0)
  4007. {
  4008. for (int i = 0; i < currSchoolInfos.Count; i++)
  4009. {
  4010. var schoolInfo = currSchoolInfos[i];
  4011. if (!string.IsNullOrEmpty(schoolInfo.School))
  4012. {
  4013. dics.Add("School", schoolInfo?.School ?? "");//学校名称和学历
  4014. dics.Add("SchoolAddress", schoolInfo?.Address ?? "");//学校地址
  4015. dics.Add("SchoolTeacher", schoolInfo?.Teacher ?? "");//指导老师
  4016. dics.Add("SchoolSubject", schoolInfo?.Subject ?? "");//所学课程或专业名称
  4017. dics.Add("SchoolStudyStart", schoolInfo?.StudyStart.ToString("yyyy-MM-dd") ?? "");//就读起始日
  4018. dics.Add("SchoolStudyEnd", schoolInfo?.StudyEnd.ToString("yyyy-MM-dd") ?? "");//就读结束日
  4019. }
  4020. else break;
  4021. }
  4022. }
  4023. //家人信息书签
  4024. if (currFamilyInfos.Count > 0)
  4025. {
  4026. for (int i = 0; i < currFamilyInfos.Count; i++)
  4027. {
  4028. var familyInfo = currFamilyInfos[i];
  4029. if (!string.IsNullOrEmpty(familyInfo.Appellation))
  4030. {
  4031. dics.Add("FamilyAppellation", familyInfo?.Appellation ?? "");//家庭成员称谓
  4032. dics.Add("FamilyName", familyInfo?.Name ?? "");//家庭成员姓名
  4033. dics.Add("FamilyBirthDay", familyInfo?.BirthDay.ToString("yyyy-MM-dd") ?? "");//家庭成员出生日期
  4034. dics.Add("FamilyBirthPlace", familyInfo?.BirthPlace ?? "");// 家庭成员出生地
  4035. dics.Add("FamilyPolitics", familyInfo?.Politics ?? "");//家庭成员政治面貌
  4036. dics.Add("FamilyClient", familyInfo?.Client ?? "");//家庭成员工作单位
  4037. dics.Add("FamilyAddress", familyInfo?.Address ?? "");// 家庭地址
  4038. dics.Add("IsEu", familyInfo?.IsEu == 0 ? "No" : "Yes" ?? "");// 欧盟公民
  4039. dics.Add("FamilyNameSnd", familyInfo?.NameSnd ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员姓名
  4040. dics.Add("FamilyBirthDaySnd", familyInfo?.BirthDaySnd.ToString("yyyy-MM-dd") ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员生日
  4041. dics.Add("FamilyNationality", familyInfo?.Nationality ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员国籍
  4042. dics.Add("FamilyIDCard", familyInfo?.IDCard ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员旅行证件编号或身份证号码
  4043. dics.Add("FamilyReletionship", familyInfo?.Reletionship ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员与申请人的关系
  4044. dics.Add("IsUSA", familyInfo?.IsUSA == 1 ? "是" : "否" ?? "");// 家庭成员是否在美国
  4045. }
  4046. else break;
  4047. }
  4048. }
  4049. #endregion
  4050. #region 生成文件
  4051. try
  4052. {
  4053. _logger.LogInformation("模板位置:{currTempPath}", currTempPath);
  4054. Document doc = new(currTempPath);
  4055. Aspose.Words.DocumentBuilder builder = new(doc);
  4056. string strTemp = "";
  4057. //循环键值对
  4058. foreach (var key in dics.Keys)
  4059. {
  4060. //将光标移入书签的位置
  4061. builder.MoveToBookmark(key);
  4062. //判断书签值是否为空
  4063. if (!string.IsNullOrEmpty(dics[key]))
  4064. {
  4065. strTemp = dics[key];
  4066. }
  4067. else strTemp = "";
  4068. //填充书签
  4069. builder.Write(strTemp.Replace("\\N", "\n"));
  4070. }
  4071. var custName = custInfo.LastName + custInfo.FirstName;
  4072. string fileName = $"{custName}_{visaTypeName}.doc";
  4073. var currFilePath = $"{usaSavePath}{fileName}";
  4074. doc.Save(currFilePath);
  4075. filePaths.Add(currFilePath);
  4076. }
  4077. catch (Exception ex)
  4078. {
  4079. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4080. }
  4081. #endregion
  4082. }
  4083. break;
  4084. case 2: // 日本
  4085. visaTypeName = $"日本签证申请表";
  4086. currTempPath = $"{tempPath}/{visaTypeName}.doc";
  4087. var jpnSavePath = $"{fileServerPath}/{visaTypeName}/";
  4088. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(jpnSavePath);
  4089. foreach (var custInfo in groupCustInfos)
  4090. {
  4091. EncryptionProcessor.DecryptProperties(custInfo);
  4092. Dictionary<string, string> dics = new();
  4093. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  4094. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  4095. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  4096. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4097. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4098. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4099. #region 日本签证模板书签
  4100. dics.Add("LastNameEn", CommonFun.ConvertToPinyin(custInfo?.LastName?.Trim() ?? "")?.ToLower() ?? "");//姓
  4101. dics.Add("FirstNameEn", CommonFun.ConvertToPinyin(custInfo?.FirstName?.Trim() ?? "")?.ToLower() ?? "");//名
  4102. if (!string.IsNullOrEmpty(custInfo.OldName)) dics.Add("OldNameEn", custInfo?.OldName ?? "");//名
  4103. else dics.Add("OldNameEn", "无");//名
  4104. dics.Add("LastName", custInfo?.LastName ?? "");//姓
  4105. dics.Add("FirstName", custInfo?.FirstName ?? "");//名
  4106. if (!string.IsNullOrEmpty(custInfo.OldName)) dics.Add("OldName", custInfo?.OldName ?? "");//名
  4107. else dics.Add("OldName", "无");//名
  4108. string idCard = idInfo?.CertNo?.Trim() ?? "";
  4109. string birthday = string.Empty;
  4110. if (!string.IsNullOrEmpty(idCard))
  4111. {
  4112. string year = idCard.Substring(6, 4);
  4113. string month = idCard.Substring(10, 2);
  4114. string day = idCard.Substring(12, 2);
  4115. birthday = year + "/" + month + "/" + day;
  4116. }
  4117. dics.Add("BirthDay", birthday); //出生日期
  4118. dics.Add("BirthProvince", custInfo?.BirthProvince ?? "");//出生省
  4119. dics.Add("BirthCity", custInfo?.BirthCity ?? "");//出生城市
  4120. dics.Add("Nationality", "中国");//国籍
  4121. dics.Add("Address", custInfo?.Address ?? "");//现居家庭地址
  4122. dics.Add("IdCard", idCard);//身份证号码
  4123. dics.Add("OldNationality", "无");//默认没有
  4124. dics.Add("Tel11", custInfo?.Phone ?? "");//座机
  4125. //护照
  4126. if (passportInfo != null)
  4127. {
  4128. dics.Add("PassprotNo", passportInfo?.CertNo ?? "");// 护照編號
  4129. dics.Add("PassprotIssuePlase", passportInfo?.Area ?? "");// 护照签发地
  4130. dics.Add("PassprotStartTime", passportInfo?.IssueDt?.ToString("yyyy/MM/dd") ?? "");//护照开始时间
  4131. dics.Add("PassprotEndTime", passportInfo?.ExpiryDt?.ToString("yyyy/MM/dd") ?? "");// 护照过期时间
  4132. }
  4133. //得到签证国家下的城市
  4134. string city = "";
  4135. string county = "";
  4136. //ResidenceTime1 机票三字码信息
  4137. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  4138. if (atbc != null)
  4139. {
  4140. string startTime = ""; //开始停留时间
  4141. string endTime = ""; //离开时间
  4142. string three = ""; //航司
  4143. string threeCode = ""; //入境口岸
  4144. for (int i = 0; i < atbc.Rows.Count; i++)
  4145. {
  4146. if (i == 0) //得到抵达日期
  4147. {
  4148. three = atbc.Rows[i]["Fliagtcode"].ToString();
  4149. startTime = atbc.Rows[i]["Day"].ToString();
  4150. threeCode = atbc.Rows[i]["Three"].ToString();
  4151. continue;
  4152. }
  4153. if (i == 1)
  4154. endTime = atbc.Rows[i]["Day"].ToString();
  4155. }
  4156. dics.Add("ResidenceTime1", startTime);
  4157. dics.Add("ResidenceTime2", endTime);
  4158. dics.Add("EntryTime", startTime);
  4159. if (!string.IsNullOrEmpty(three))
  4160. {
  4161. //查询航司名称
  4162. var threeCodeTwo = three.Substring(0, 2);
  4163. var ac = _sqlSugar.Queryable<Res_AirCompany>().Where(x => x.ShortCode == threeCodeTwo).First();
  4164. if (ac != null)
  4165. {
  4166. dics.Add("AirName", $"{ac?.EnName ?? ""} {three}"); //入境口岸
  4167. }
  4168. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == threeCodeTwo).First();
  4169. if (tc != null)
  4170. {
  4171. county = tc.Country;
  4172. city = tc.City;
  4173. dics.Add("PortOfEntry", tc?.City ?? ""); //入境口岸
  4174. }
  4175. }
  4176. }
  4177. //团组信息
  4178. if (groupInfo != null)
  4179. {
  4180. dics.Add("Destination", groupInfo?.VisitPurpose ?? ""); //出访目的 Destination2
  4181. //DickeyValue.Add("Destination2", dgi.VisitCountry); //出访目的地
  4182. }
  4183. if (!string.IsNullOrEmpty(city))
  4184. {
  4185. //得到当前国家下的城市酒店信息
  4186. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  4187. .Where(x => x.DiId == groupId)
  4188. .Where(x => x.City.contains(city))
  4189. .First();
  4190. //酒店住址
  4191. if (hotelInfo != null)
  4192. {
  4193. dics.Add("HotalName", hotelInfo?.HotelName ?? ""); //酒店名称
  4194. dics.Add("HotalAddress", hotelInfo?.HotelAddress ?? ""); //酒店地址
  4195. dics.Add("HotalTel", hotelInfo?.HotelTel ?? ""); //酒店电话
  4196. }
  4197. }
  4198. dics.Add("Tel", custInfo?.Tel ?? "");//移动电话
  4199. dics.Add("Client", companyInfos?.FirstOrDefault()?.Company ?? "");//单位名称
  4200. dics.Add("ClientPhone", companyInfos?.FirstOrDefault()?.Phone ?? "");//单位电话
  4201. dics.Add("ClientAddress", companyInfos?.FirstOrDefault()?.CompanyAddress ?? "");//单位地址
  4202. dics.Add("Job", custInfo?.Job ?? "");//职务
  4203. dics.Add("MateJob", custInfo?.MateJob ?? "");//配偶职务
  4204. //InvitingPartyInfo RB_IP = new InvitingPartyInfoService().GetAddSelect(int.Parse(ddlTeamNames.SelectedValue), RB_County, RB_City);
  4205. if (!string.IsNullOrEmpty(county) && !string.IsNullOrEmpty(city))
  4206. {
  4207. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  4208. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  4209. .Where(x => x.Country.Contains(county))
  4210. .Where(x => x.Area.Contains(city))
  4211. .First();
  4212. //邀请 接待单位
  4213. if (oa != null)
  4214. {
  4215. dics.Add("OA12", oa?.Contact ?? ""); //接待单位联系人
  4216. dics.Add("OAJob", oa?.Job ?? ""); //接待联系人职务
  4217. dics.Add("OATel", oa?.Tel ?? ""); //接待单位电话
  4218. dics.Add("OAAddress", oa?.Address ?? "");//接待单位地址
  4219. dics.Add("ApplicantGuanxi", "邀请方"); //和申请人关系
  4220. dics.Add("OACountry", "日本"); //邀请方国家
  4221. dics.Add("OADan", "同上"); // 同上
  4222. dics.Add("OAJob1", "同上"); //接待联系人职务
  4223. dics.Add("OATel1", "同上"); // 同上
  4224. dics.Add("OAAddress1", "同上"); // 同上
  4225. dics.Add("ApplicantGuanxi1", "同上"); // 同上
  4226. dics.Add("OACountry1", "同上"); //邀请方国家
  4227. }
  4228. }
  4229. dics.Add("NowTime", DateTime.Now.ToString("yyyy/MM/dd")); //获取当前系统时间
  4230. #endregion
  4231. #region 生成文件
  4232. try
  4233. {
  4234. Document doc = new(currTempPath);
  4235. Aspose.Words.DocumentBuilder builder = new(doc);
  4236. string strTemp = "";
  4237. //循环键值对
  4238. foreach (var key in dics.Keys)
  4239. {
  4240. //将光标移入书签的位置
  4241. builder.MoveToBookmark(key);
  4242. //判断书签值是否为空
  4243. if (!string.IsNullOrEmpty(dics[key]))
  4244. {
  4245. strTemp = dics[key];
  4246. }
  4247. else strTemp = "";
  4248. //填充书签
  4249. builder.Write(strTemp.Replace("\\N", "\n"));
  4250. }
  4251. var custName = custInfo?.LastName + custInfo?.FirstName;
  4252. string fileName = $"{custName}_{visaTypeName}.doc";
  4253. var currFilePath = $"{jpnSavePath}{fileName}";
  4254. doc.Save(currFilePath);
  4255. filePaths.Add(currFilePath);
  4256. }
  4257. catch (Exception ex)
  4258. {
  4259. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4260. }
  4261. #endregion
  4262. }
  4263. break;
  4264. case 3: // 韩国
  4265. visaTypeName = $"韩国签证申请表";
  4266. currTempPath = $"{tempPath}{visaTypeName}.doc";
  4267. var korSavePath = $"{fileServerPath}{visaTypeName}/";
  4268. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(korSavePath);
  4269. foreach (var custInfo in groupCustInfos)
  4270. {
  4271. EncryptionProcessor.DecryptProperties(custInfo);
  4272. Dictionary<string, string> dics = new();
  4273. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  4274. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  4275. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  4276. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4277. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4278. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4279. #region 韩国签证模板书签
  4280. dics.Add("LastNameEn", custInfo?.LastName ?? "");//姓
  4281. dics.Add("FirstNameEn", custInfo?.FirstName ?? "");//名
  4282. var userName = $"{custInfo?.LastName ?? ""}{custInfo?.FirstName ?? ""}";
  4283. dics.Add("User", userName);//姓名
  4284. //判断性别
  4285. if (custInfo.Sex == 0)
  4286. dics.Add("SexMale", "√");
  4287. else if (custInfo.Sex == 1)
  4288. dics.Add("SexFemale", "√");
  4289. string idCard = idInfo.CertNo;
  4290. string birthday = string.Empty;
  4291. if (!string.IsNullOrEmpty(idCard))
  4292. {
  4293. string year = idCard.Substring(6, 4);
  4294. string month = idCard.Substring(10, 2);
  4295. string day = idCard.Substring(12, 2);
  4296. birthday = year + "/" + month + "/" + day;
  4297. }
  4298. dics.Add("BirthDay", birthday);//出生日期
  4299. dics.Add("Nationality", "中国");//国籍
  4300. dics.Add("NationalityCountry", "中国");//出生国
  4301. dics.Add("IdCard", idCard);//身份证号码
  4302. dics.Add("OtherPassProt", "√"); //默认没有其他护照
  4303. //判断是否否曾用名 是否申请过该国家
  4304. string isGetSchengenStr = custInfo.IsGetSchengen == 0 ? "否" : "是";
  4305. if (!string.IsNullOrEmpty(custInfo.OldName) && isGetSchengenStr.equals("是"))
  4306. {
  4307. dics.Add("IsGetSchengenYes", "√");
  4308. string oldName = custInfo?.OldName ?? "";
  4309. if (!string.IsNullOrEmpty(oldName))
  4310. {
  4311. dics.Add("OldLastName", oldName.Substring(0, 1));
  4312. dics.Add("OldFirstName", oldName.Remove(0, 1));
  4313. }
  4314. }
  4315. else
  4316. dics.Add("IsGetSchengenNo", "√");
  4317. dics.Add("IsDoubleNationality", "√"); //默认没有双重国籍
  4318. //护照
  4319. if (passportInfo != null)
  4320. {
  4321. dics.Add("PassprotNo", passportInfo?.CertNo ?? ""); // 护照編號
  4322. dics.Add("PassprotCountry", passportInfo?.Country ?? ""); // 护照签发国
  4323. dics.Add("PassprotIssuePlase", passportInfo?.Area ?? ""); // 护照签发地
  4324. dics.Add("PassprotStartTime", passportInfo?.IssueDt?.ToString("yyyy-MM-dd") ?? ""); //护照开始时间
  4325. dics.Add("PassprotEndTime", passportInfo?.ExpiryDt?.ToString("yyyy-MM-dd") ?? ""); // 护照过期时间
  4326. }
  4327. dics.Add("Address", custInfo?.Address ?? "");//现居家庭地址
  4328. dics.Add("Tel1", custInfo?.Tel ?? "");//移动电话 /家庭电话 /电子信箱
  4329. //dics.Add("Tel2", );//电子信箱
  4330. dics.Add("Email", custInfo?.Email ?? "");//电子信箱
  4331. //判断婚姻状况
  4332. var marriage = custInfo.Marriage switch
  4333. {
  4334. 1 => "未婚",
  4335. 2 => "已婚",
  4336. 3 => "离异",
  4337. 4 => "丧偶",
  4338. _ => "未设置"
  4339. };
  4340. if (marriage.Contains("未婚") || marriage == null || marriage == "")
  4341. dics.Add("Single", "√");
  4342. else if (marriage == "已婚")
  4343. dics.Add("Married", "√");
  4344. else if (marriage == "离婚" || marriage == "离异")
  4345. dics.Add("Divorced", "√");
  4346. //判断是否已婚 已婚则输出配偶信息
  4347. if (marriage == "已婚")
  4348. {
  4349. string mateName = custInfo?.MateName ?? "";
  4350. if (!string.IsNullOrEmpty(mateName))
  4351. {
  4352. try
  4353. {
  4354. string mateFirstName = mateName.Remove(0, 1);
  4355. dics.Add("MateLastName", mateName.Substring(0, 1)); //配偶姓
  4356. dics.Add("MateFirstName", mateFirstName); //配偶名
  4357. //dics.Add("MateLastName", MateName.Substring(0, 1)); //配偶姓
  4358. //dics.Add("MateFirstName", MateName.Substring(1, MateName.Length - 1)); //配偶名
  4359. }
  4360. catch { }
  4361. dics.Add("MateBirthDay", custInfo?.MateBirthDay.ToString("yyyy-MM-dd")); //配偶生日
  4362. //dics.Add("MateNationality", custInfo.ma.ToString()); //配偶国籍
  4363. //dics.Add("MateTel", custInfo..ToString()); //配偶联系电话
  4364. dics.Add("MateAddress", custInfo.MateAddress.ToString()); //配偶居住地址
  4365. //家人信息书签
  4366. if (currFamilyInfos.Count > 0)
  4367. {
  4368. //定义接受子女人数
  4369. int children = currFamilyInfos.Where(x => x.Appellation.contains("儿子") || x.Appellation.contains("女儿")).ToList().Count;
  4370. //判断子女人数
  4371. if (children == 0) //无子女
  4372. dics.Add("NoChildren", "√"); //未查询出 则无子女
  4373. else
  4374. {
  4375. dics.Add("HaveChildren", "√");
  4376. dics.Add("ChildrenNum", children.ToString());//有子女则输出人数
  4377. }
  4378. }
  4379. else
  4380. dics.Add("NoChildren", "√"); //未查询出 则无子女
  4381. }
  4382. }
  4383. else
  4384. dics.Add("NoChildren", "√"); //未婚则无子女
  4385. //学历
  4386. if (custInfo.HighestEducation.Contains("硕士") || custInfo.HighestEducation.Contains("博士"))
  4387. dics.Add("Master", "√");
  4388. else if (custInfo.HighestEducation.Contains("学士"))
  4389. dics.Add("Bachelor", "√");
  4390. else if (custInfo.HighestEducation.Contains("高中"))
  4391. dics.Add("HighSchool", "√");
  4392. else
  4393. {
  4394. dics.Add("Other", "√");
  4395. dics.Add("OtherDetails", custInfo.HighestEducation.Trim());
  4396. }
  4397. //dics.Add("Job", custInfo.Job.ToString()); ;//职业
  4398. dics.Add("Company", companyInfos.FirstOrDefault()?.Company ?? "");//单位名称
  4399. dics.Add("jobs", companyInfos.FirstOrDefault()?.Job ?? ""); //职务
  4400. dics.Add("CompanyAddress", companyInfos.FirstOrDefault()?.CompanyAddress ?? "");//单位地址
  4401. dics.Add("CompanyTel", companyInfos.FirstOrDefault()?.Phone ?? "");//单位电话
  4402. string day1 = ""; //得到抵达日期
  4403. string day2 = ""; //得到离开日期
  4404. string country = groupInfo.VisitCountry; //国家名
  4405. string HG_City = ""; //城市
  4406. string HG_Country = "";//国家
  4407. string[] HG_countryName = new string[] { };
  4408. if (!string.IsNullOrEmpty(country))
  4409. {
  4410. //处理国家名
  4411. if (country.Contains(" "))
  4412. HG_countryName = country.Split(' ');
  4413. else if (country.Contains(","))
  4414. HG_countryName = country.Split(',');
  4415. else if (country.Contains(","))
  4416. HG_countryName = country.Split(',');
  4417. else if (country.Contains("、"))
  4418. HG_countryName = country.Split('、');
  4419. }
  4420. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  4421. int k = 0;
  4422. for (int i = 0; i < HG_countryName.Length; i++)
  4423. {
  4424. for (int j = 0; j < atbc.Rows.Count; j++)
  4425. {
  4426. string HL_Three = atbc.Rows[j]["Three"].ToString();
  4427. if (!string.IsNullOrEmpty(HL_Three))
  4428. {
  4429. var hl_three = HL_Three.Substring(3);
  4430. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == hl_three).First();
  4431. if (tc != null)
  4432. {
  4433. HG_Country = HG_countryName[i];
  4434. HG_City = tc.City; //得到当前国家 城市名
  4435. day1 = atbc.Rows[j]["Day"].ToString(); //得到抵达日期
  4436. k = j + 1;
  4437. }
  4438. }
  4439. if (k == j)
  4440. day2 = atbc.Rows[j]["Day"].ToString(); //离开航班起飞时间
  4441. }
  4442. }
  4443. if (atbc != null)
  4444. {
  4445. if (day2 != null && day1 != null)
  4446. {
  4447. try
  4448. {
  4449. int Han_day = (Convert.ToDateTime(day2) - Convert.ToDateTime(day1)).Days; //得到天数
  4450. dics.Add("Days", Han_day.ToString() + "天");//滞留天数
  4451. dics.Add("EntryTime", day1.ToString());//入境日期 TemporaryAddress
  4452. }
  4453. catch (Exception) { }
  4454. }
  4455. }
  4456. //得到当前国家下的城市酒店信息
  4457. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  4458. .Where(x => x.DiId == groupId)
  4459. .Where(x => x.City.contains(HG_City))
  4460. .First();
  4461. //访问信息
  4462. if (hotelInfo != null)
  4463. {
  4464. dics.Add("TemporaryAddress", hotelInfo?.HotelAddress ?? "");//停留酒店地址 TATel
  4465. dics.Add("TATel", hotelInfo?.HotelTel ?? ""); //停留酒店联系电话
  4466. }
  4467. if (!string.IsNullOrEmpty(HG_Country) && !string.IsNullOrEmpty(HG_City))
  4468. {
  4469. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  4470. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  4471. .Where(x => x.Country.Contains(HG_Country))
  4472. .Where(x => x.Area.Contains(HG_City))
  4473. .First();
  4474. //在韩邀请方信息
  4475. if (oa != null)
  4476. {
  4477. dics.Add("IsYes", "√");
  4478. dics.Add("TT", oa?.Contact ?? ""); //联系人
  4479. dics.Add("TTAddress", oa?.Address ?? ""); //联系地址
  4480. dics.Add("TTtel", oa?.Tel ?? ""); //联系电话
  4481. dics.Add("TTGuanxi", "BY INVITED"); //和在邀联系人关系
  4482. }
  4483. else
  4484. dics.Add("IsNo", "√");
  4485. }
  4486. //费用信息
  4487. if (groupInfo != null)
  4488. {
  4489. //dics.Add("Payer", "Unit"); //在外期间费用承担
  4490. dics.Add("Team1", groupInfo.ClientUnit); //客户单位名称
  4491. dics.Add("Team12", "雇佣"); //与申请人关系 BY INVITED
  4492. dics.Add("PriceType", "Payment By Unit"); //资金类型
  4493. dics.Add("TeamNameTel", custInfo.ClientPhone); //联系方式
  4494. }
  4495. //是否有协助填表人
  4496. if (!string.IsNullOrEmpty(custInfo.TableOpName))
  4497. dics.Add("WirteTableNo", "√");
  4498. else
  4499. {
  4500. dics.Add("WirteTableYes", "√");
  4501. dics.Add("OpTableName", custInfo.TableOpName.ToString()); //协助填表人姓名
  4502. //dics.Add("OpTableDateTime",custInfo.OpDate.ToString()); //填表时间
  4503. dics.Add("OpTableTel", custInfo.TableOpTel.ToString()); //协助人联系电话
  4504. dics.Add("OpTableGuanXi", "雇佣"); //和协助人关系
  4505. }
  4506. dics.Add("NowDateTime", DateTime.Now.ToString("yyyy/MM/dd")); //获取当前系统时间
  4507. dics.Add("ApplicantName", custInfo.LastName + " " + custInfo.FirstName); //申请人
  4508. #endregion
  4509. #region 生成文件
  4510. try
  4511. {
  4512. Document doc = new(currTempPath);
  4513. Aspose.Words.DocumentBuilder builder = new(doc);
  4514. string strTemp = "";
  4515. //循环键值对
  4516. foreach (var key in dics.Keys)
  4517. {
  4518. //将光标移入书签的位置
  4519. builder.MoveToBookmark(key);
  4520. //判断书签值是否为空
  4521. if (!string.IsNullOrEmpty(dics[key]))
  4522. {
  4523. strTemp = dics[key];
  4524. }
  4525. else strTemp = "";
  4526. //填充书签
  4527. builder.Write(strTemp.Replace("\\N", "\n"));
  4528. }
  4529. var custName = custInfo.LastName + custInfo.FirstName;
  4530. string fileName = $"{custName}_{visaTypeName}.doc";
  4531. var currFilePath = $"{korSavePath}{fileName}";
  4532. doc.Save(currFilePath);
  4533. filePaths.Add(currFilePath);
  4534. }
  4535. catch (Exception ex)
  4536. {
  4537. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4538. }
  4539. #endregion
  4540. }
  4541. break;
  4542. case 4: // 瑞典
  4543. visaTypeName = $"瑞典签证申请表";
  4544. currTempPath = $"{tempPath}{visaTypeName}.pdf";
  4545. var swedenSavePath = $"{fileServerPath}{visaTypeName}/";
  4546. if (!Directory.Exists(swedenSavePath)) Directory.CreateDirectory(swedenSavePath);
  4547. if (!System.IO.File.Exists(currTempPath))
  4548. {
  4549. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4550. }
  4551. foreach (var custInfo in groupCustInfos)
  4552. {
  4553. EncryptionProcessor.DecryptProperties(custInfo);
  4554. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  4555. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  4556. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  4557. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4558. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4559. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4560. #region 生成文件
  4561. PdfReader reader = null;
  4562. FileStream templateStream = null;
  4563. FileStream outputStream = null;
  4564. PdfStamper stamper = null;
  4565. try
  4566. {
  4567. string outputPath = $"{swedenSavePath}{custInfo.LastName}{custInfo.FirstName}.pdf";
  4568. //读取模板文件
  4569. templateStream = new FileStream(currTempPath, FileMode.Open, FileAccess.Read, FileShare.Read);
  4570. reader = new PdfReader(templateStream);
  4571. //创建输出文件
  4572. outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write);
  4573. stamper = new PdfStamper(reader, outputStream);
  4574. AcroFields formFields = stamper.AcroFields;
  4575. #region 设置文本值
  4576. SetFieldValue(formFields, "LastName", custInfo.LastName); //姓
  4577. SetFieldValue(formFields, "BirthLastName", custInfo.LastName); // 出生时姓氏
  4578. SetFieldValue(formFields, "FirstName", custInfo.FirstName); // 名
  4579. // 出生日期(日-月-年)
  4580. string idCard = idInfo.CertNo;
  4581. string birthday = string.Empty;
  4582. if (!string.IsNullOrEmpty(idCard))
  4583. {
  4584. string year = idCard.Substring(6, 4);
  4585. string month = idCard.Substring(10, 2);
  4586. string day = idCard.Substring(12, 2);
  4587. birthday = day + "-" + month + "-" + year;
  4588. }
  4589. SetFieldValue(formFields, "Birthday", birthday);
  4590. string currentNationality = custInfo.BirthProvince + custInfo.BirthCity;
  4591. SetFieldValue(formFields, "CurrentNationality", currentNationality); // 出生地
  4592. SetFieldValue(formFields, "CountryBirth","中国"); // 出生国
  4593. SetFieldValue(formFields, "CurrentNationalityCountry", "中国"); // 现国籍
  4594. SetFieldValue(formFields, "NationalityBirth", ""); // 出生时国籍,如与现国籍不同
  4595. SetFieldValue(formFields, "OtherNationalities", ""); // 其他国籍
  4596. #region 性别处理
  4597. //清除性别
  4598. SetFieldValue(formFields, "Male", "Off"); // 性别 - 男
  4599. SetFieldValue(formFields, "Female", "Off"); // 性别 - 女
  4600. //设置性别
  4601. if (custInfo.Sex == 0) //男
  4602. {
  4603. SetFieldValue(formFields, "Male", "Yes"); // 性别 - 男
  4604. }
  4605. else if (custInfo.Sex == 1) //女
  4606. {
  4607. SetFieldValue(formFields, "Female", "Yes"); // 性别 - 女
  4608. }
  4609. #endregion
  4610. #region 婚姻状况处理
  4611. //清除婚姻状况
  4612. SetFieldValue(formFields, "Single", "Off"); // 婚姻状况 - 未婚
  4613. SetFieldValue(formFields, "Married", "Off"); // 婚姻状况 - 已婚
  4614. SetFieldValue(formFields, "RegisteredPartnership", "Off"); // 婚姻状况 - 注册伴侣关系
  4615. SetFieldValue(formFields, "Separated", "Off"); // 婚姻状况 - 分居
  4616. SetFieldValue(formFields, "Divorced", "Off"); // 婚姻状况 - 离婚
  4617. SetFieldValue(formFields, "Widow(er)", "Off"); // 婚姻状况 - 丧偶
  4618. SetFieldValue(formFields, "OtherCivilStatus", "Off"); // 婚姻状况 - 其它
  4619. SetFieldValue(formFields, "CivilStatusOther", ""); // 婚姻状况 - 其它(请注明)
  4620. //设置婚姻状况
  4621. switch (custInfo.Marriage)
  4622. {
  4623. case 1: // 未婚
  4624. SetFieldValue(formFields, "Single", "Yes");
  4625. break;
  4626. case 2: // 已婚
  4627. SetFieldValue(formFields, "Married", "Yes");
  4628. break;
  4629. case 3: // 离异
  4630. SetFieldValue(formFields, "Divorced", "Yes");
  4631. break;
  4632. case 4: // 离异
  4633. SetFieldValue(formFields, "Widow(er)", "Yes");
  4634. break;
  4635. }
  4636. #endregion
  4637. //亲权人(如是未成年申请人 )/合法监护人(姓名、住址,如与申请人不同) 电话号码、电子邮件及国籍
  4638. SetFieldValue(formFields, "ParentalAuthority", "");
  4639. SetFieldValue(formFields, "NationalIdentityNumber", idCard); //公民身份证号码
  4640. #region 护照(旅行证件类型)处理
  4641. //清除值
  4642. SetFieldValue(formFields, "OrdinaryPassport", "Off"); //旅行证件类型 - 普通护照
  4643. SetFieldValue(formFields, "DiplomaticPassport", "Off"); //旅行证件类型 - 外交护照
  4644. SetFieldValue(formFields, "ServicePassport", "Off"); //旅行证件类型 - 公务护照
  4645. SetFieldValue(formFields, "OfficialPassport", "Off"); //旅行证件类型 - 因公护照
  4646. SetFieldValue(formFields, "SpecialPassport", "Off"); //旅行证件类型 - 特殊护照
  4647. SetFieldValue(formFields, "OtherTravel", "Off"); //旅行证件类型 - 其它旅行证件
  4648. SetFieldValue(formFields, "OtherTravelDesc", ""); //旅行证件类型 - 其它旅行证件(请注明)
  4649. //设置值
  4650. SetFieldValue(formFields, "OrdinaryPassport", "Yes"); //旅行证件类型 - 普通护照
  4651. if (passportInfo != null)
  4652. {
  4653. SetFieldValue(formFields, "TravelNumber", passportInfo.CertNo); //旅行证件编号
  4654. SetFieldValue(formFields, "IssueDate", passportInfo.IssueDt?.ToString("yyyy-MM-dd") ?? ""); //签发日期
  4655. SetFieldValue(formFields, "ValidUntil", passportInfo.ExpiryDt?.ToString("yyyy-MM-dd") ?? ""); //有效期至
  4656. SetFieldValue(formFields, "IssuedCountry", passportInfo.Country); //签发(国)
  4657. }
  4658. #endregion
  4659. //如有家庭成员为欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的,请填写该家庭成员的个人信息
  4660. SetFieldValue(formFields, "LastName_om", ""); //姓
  4661. SetFieldValue(formFields, "FirstName_om", ""); //名
  4662. SetFieldValue(formFields, "BirthDate_om", ""); //出生日期(日-月-年)
  4663. SetFieldValue(formFields, "Nationality_om", ""); //国籍
  4664. SetFieldValue(formFields, "TravelNuber_om", ""); //旅行证件或身分证编号
  4665. //申请人与欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的关系
  4666. SetFieldValue(formFields, "Spouse_om", ""); //配偶
  4667. SetFieldValue(formFields, "RegisteredPartnership_om", ""); //注册伴侣
  4668. SetFieldValue(formFields, "Child_om", ""); //子女
  4669. SetFieldValue(formFields, "DependentAscendant_om", ""); //受养人
  4670. SetFieldValue(formFields, "Grandchild_om", ""); //孙子女
  4671. SetFieldValue(formFields, "FamilyOther_om", ""); //其他
  4672. SetFieldValue(formFields, "FamilyOtherDesc_om", ""); //其他(说明)
  4673. //申请人住址及电子邮件
  4674. string applicantHomeAddress = $"{custInfo.Address} {custInfo.Email}";
  4675. SetFieldValue(formFields, "ApplicantHomeAddress", applicantHomeAddress); //申请人住址及电子邮件
  4676. SetFieldValue(formFields, "TelephoneNo", custInfo.Tel); //电话号码
  4677. //是否居住在现时国籍以外的国家
  4678. SetFieldValue(formFields, "AnotherCountryNo", "Yes"); //否
  4679. SetFieldValue(formFields, "AnotherCountryYes", ""); //是。
  4680. SetFieldValue(formFields, "ResidencePermit", ""); //居住许可或同等证
  4681. SetFieldValue(formFields, "Number", ""); //编号
  4682. SetFieldValue(formFields, "ValidUntils", ""); //有效期至
  4683. SetFieldValue(formFields, "CurrentOccupation", custInfo.Job); //当前职业
  4684. //工作单位名称,地址和电话,学生填写学校名称及地址
  4685. var currCompanyInfo = currCompanyInfos.FirstOrDefault();
  4686. string employerInfoStr = $"{currCompanyInfo?.Company ?? ""} {currCompanyInfo?.CompanyAddress ?? ""} {currCompanyInfo?.Phone ?? ""}";
  4687. SetFieldValue(formFields, "EmployerInfo", employerInfoStr);
  4688. #region 旅行的目的
  4689. //清空值
  4690. SetFieldValue(formFields, "Tourism", "Off"); //旅游
  4691. SetFieldValue(formFields, "Business", "Off"); //商务
  4692. SetFieldValue(formFields, "VisitingFamily", "Off"); //探亲访友
  4693. SetFieldValue(formFields, "Cultural", "Off"); //文化
  4694. SetFieldValue(formFields, "Sports", "Off"); //体育
  4695. SetFieldValue(formFields, "OfficialVisit", "Off"); //官方访问
  4696. SetFieldValue(formFields, "MedicalReasons", "Off"); //医疗
  4697. SetFieldValue(formFields, "Study", "Off"); //学习
  4698. SetFieldValue(formFields, "AirportTransit", "Off"); //机场过境
  4699. SetFieldValue(formFields, "Other", "Off"); //其它
  4700. SetFieldValue(formFields, "OtherDesc", ""); //其它 (请注明)
  4701. //设置值
  4702. if (groupInfo.VisitPurpose.contains("旅游")) SetFieldValue(formFields, "Tourism", "Yes"); //旅游
  4703. if (groupInfo.VisitPurpose.contains("商务")) SetFieldValue(formFields, "Business", "Yes"); //商务
  4704. if (groupInfo.VisitPurpose.contains("探亲访友")) SetFieldValue(formFields, "VisitingFamily", "Yes"); //探亲访友
  4705. if (groupInfo.VisitPurpose.contains("文化")) SetFieldValue(formFields, "Cultural", "Yes"); //文化
  4706. if (groupInfo.VisitPurpose.contains("体育")) SetFieldValue(formFields, "Sports", "Yes"); //体育
  4707. if (groupInfo.VisitPurpose.contains("官方访问")) SetFieldValue(formFields, "OfficialVisit", "Yes"); //官方访问
  4708. if (groupInfo.VisitPurpose.contains("医疗")) SetFieldValue(formFields, "MedicalReasons", "Yes"); //医疗
  4709. if (groupInfo.VisitPurpose.contains("学习")) SetFieldValue(formFields, "Study", "Yes"); //学习
  4710. if (groupInfo.VisitPurpose.contains("机场过境")) SetFieldValue(formFields, "AirportTransit", "Yes"); //机场过境
  4711. #endregion
  4712. SetFieldValue(formFields, "AdditionalInfo", ""); //有关停留原因的补充信息
  4713. string[] RD_country = new string[] { }; //接收处理的国家
  4714. string firstEntryLabel = string.Empty; //首入申根国标签
  4715. string membeDescLabel = string.Empty; //申根国目的地
  4716. string stopDays = string.Empty; //停留天数
  4717. if (!string.IsNullOrEmpty(groupInfo.VisitCountry))
  4718. {
  4719. List<string> SGGNames = new List<string>();//接收处理后的国家 是申根国
  4720. if (groupInfo.VisitCountry.Contains(","))
  4721. RD_country = groupInfo.VisitCountry.Split(',');
  4722. else if (groupInfo.VisitCountry.Contains(' '))
  4723. RD_country = groupInfo.VisitCountry.Split(' ');
  4724. else if (groupInfo.VisitCountry.Contains(","))
  4725. RD_country = groupInfo.VisitCountry.Split(',');
  4726. else if (groupInfo.VisitCountry.Contains("、"))
  4727. RD_country = groupInfo.VisitCountry.Split('、');
  4728. else if (groupInfo.VisitCountry.Contains("|"))
  4729. RD_country = groupInfo.VisitCountry.Split('|');
  4730. //判断是否是申根国家
  4731. for (int i = 0; i < RD_country.Length; i++)
  4732. {
  4733. if (RD_country[i].ToString() != null)
  4734. {
  4735. //在申根国家中筛选 该国家是否是申根国家
  4736. for (int j = 0; j < _shenGenGuos.Length; j++)
  4737. {
  4738. if (RD_country[i] == _shenGenGuos[j])
  4739. SGGNames.Add(_shenGenGuos[j]); //添加申根国
  4740. }
  4741. }
  4742. }
  4743. //目的地国是否有申根国
  4744. if (SGGNames.Count > 0)
  4745. {
  4746. firstEntryLabel = SGGNames.First();
  4747. membeDescLabel = string.Join(",", SGGNames.ToArray());
  4748. //接收生根国详细信息 存储顺序 起飞日期:Day 起飞时刻:StartTime 抵达日期:ArrivedDate 到达时刻:EndTime
  4749. List<SSGDetails> ListSSGDetails = new List<SSGDetails>();
  4750. //处理申根国家 预定到达时间 预定离开时间 预定停留天数
  4751. for (int i = 0; i < SGGNames.Count; i++)
  4752. {
  4753. //在相同的国家下 得到该航班的信息 //抵达时间 起飞日期:Day 起飞时刻:StartTime 到达时刻:EndTime 抵达日期:ArrivedDate 飞行时间:FlightTime 航司 Fliagtcode 入境口岸
  4754. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  4755. //ResidenceTime1 机票三字码信息
  4756. if (atbc != null)
  4757. {
  4758. string HL_Three = ""; //三字码 Three
  4759. for (int j = 0; j < atbc.Rows.Count; j++)
  4760. {
  4761. HL_Three = atbc.Rows[j]["Three"].ToString();
  4762. if (!string.IsNullOrEmpty(HL_Three))
  4763. {
  4764. string threeCodeTwo = HL_Three.Substring(3);
  4765. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == threeCodeTwo).First();
  4766. if (tc != null)
  4767. {
  4768. //首入申根国时间
  4769. if (SGGNames[i] == tc.Country)
  4770. {
  4771. SSGDetails SSGDetails = new SSGDetails()
  4772. {
  4773. Three = atbc.Rows[j]["Three"].ToString(), //三字码
  4774. Fliagtcode = atbc.Rows[j]["Fliagtcode"].ToString(), //航司
  4775. startDate = atbc.Rows[j]["Day"].ToString(), //整理起飞日期
  4776. startTime = atbc.Rows[j]["StartTime"].ToString(), //整理起飞时刻
  4777. endDate = atbc.Rows[j]["ArrivedDate"].ToString(), //整理抵达日期
  4778. endTime = atbc.Rows[j]["EndTime"].ToString() //整理抵达时刻
  4779. };
  4780. ListSSGDetails.Add(SSGDetails);
  4781. }
  4782. }
  4783. }
  4784. }
  4785. }
  4786. }
  4787. ListSSGDetails.Sort((a, b) => a.startDate.CompareTo(b.startDate));
  4788. //得到并计算出入境时间
  4789. if (ListSSGDetails != null)
  4790. {
  4791. string RuJingTime = ListSSGDetails.First().endDate + " " + ListSSGDetails.First().endTime.Substring(0, 2) + ":" + ListSSGDetails.First().endTime.Substring(2); //入境时间
  4792. string LiJingTime = ListSSGDetails[ListSSGDetails.Count - 1].startDate + " " + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(0, 2) + ":" + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(2); //离境时间
  4793. stopDays = Convert.ToDateTime(LiJingTime).Subtract(Convert.ToDateTime(RuJingTime)).Days.ToString();
  4794. }
  4795. }
  4796. }
  4797. SetFieldValue(formFields, "MembeDesc", membeDescLabel); //主要申根目的地 (以及其他申根目的地,如适用)
  4798. SetFieldValue(formFields, "FirstEntry", firstEntryLabel); //首入申根国
  4799. //申请入境次数
  4800. SetFieldValue(formFields, "27.SingleEntry", ""); //单次
  4801. SetFieldValue(formFields, "27.TwoEntries", ""); //两次
  4802. SetFieldValue(formFields, "27.MultipleEntries", ""); //多次
  4803. SetFieldValue(formFields, "27.IntendedDateIn", ""); //在申根地区预计首次停留的预计抵达日期
  4804. SetFieldValue(formFields, "27.IntendedDateOut", ""); //在申根地区预计首次停留之后的预计离开日期
  4805. //以往申根国签证是否有指纹记录
  4806. SetFieldValue(formFields, "28.No", ""); //否
  4807. SetFieldValue(formFields, "28.Yes", ""); //是
  4808. SetFieldValue(formFields, "28.KnownDate", ""); //如有,请写明日期
  4809. SetFieldValue(formFields, "28.KnownVisanumber", ""); //如有,请写明签证贴纸号码
  4810. //最后目的地之入境许可
  4811. SetFieldValue(formFields, "29.Issued", ""); //签发机关
  4812. SetFieldValue(formFields, "29.ValidFrom", ""); //有效期由
  4813. SetFieldValue(formFields, "29.Until", ""); //至
  4814. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  4815. //得到当前国家下的城市酒店信息
  4816. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  4817. .Where(x => x.DiId == groupId)
  4818. //.Where(x => x.City.contains(city))
  4819. .First();
  4820. //酒店住址
  4821. if (hotelInfo != null)
  4822. {
  4823. SetFieldValue(formFields, "30.SurnameFirstName", hotelInfo?.HotelName ?? ""); //申根国的酒店
  4824. var otherInfo = $"{hotelInfo.HotelAddress}";
  4825. SetFieldValue(formFields, "30.HotelInfo", otherInfo); //邀请人/酒店/暂住居所的地址及电子邮件
  4826. SetFieldValue(formFields, "30.TelephoneNo", hotelInfo?.HotelTel ?? ""); //电话号码
  4827. }
  4828. //邀请公司或机构的名称及地址
  4829. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  4830. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  4831. //.Where(x => x.Country.Contains(county))
  4832. //.Where(x => x.Area.Contains(city))
  4833. .First();
  4834. if (oa != null)
  4835. {
  4836. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  4837. SetFieldValue(formFields, "30.SurnameFirstName", oa?.Contact ?? ""); //申根国的酒店
  4838. SetFieldValue(formFields, "30.HotelInfo", oa?.Address ?? ""); //邀请人/酒店/暂住居所的地址及电子邮件
  4839. SetFieldValue(formFields, "30.TelephoneNo", oa?.Tel ?? ""); //电话号码
  4840. string nameAddressLabel = $"{oa.Client} {oa.Address}";
  4841. SetFieldValue(formFields, "31.NameAddress", nameAddressLabel); //邀请公司或机构的名称及地址
  4842. string surnameLabel = $"{oa.Contact} {oa.Tel}";
  4843. SetFieldValue(formFields, "31.Surname", surnameLabel); //邀请公司或机构的联系人姓名、地址、电话号码及电子邮件
  4844. SetFieldValue(formFields, "31.TelephoneNo", oa?.Tel ?? ""); //邀请公司或机构的电话
  4845. }
  4846. //申请人的旅费以及在国外停留期间的生活费用
  4847. SetFieldValue(formFields, "32.Applicant", ""); //由申请人支付
  4848. SetFieldValue(formFields, "32.Cash", ""); //支付方式 - 现金
  4849. SetFieldValue(formFields, "32.Traveller", ""); //支付方式 - 旅行支票
  4850. SetFieldValue(formFields, "32.CreditCard", ""); //支付方式 - 信用卡
  4851. SetFieldValue(formFields, "32.Prepaid", ""); //支付方式 - 预缴住宿
  4852. SetFieldValue(formFields, "32.Prepaid1", ""); //支付方式 - 预缴交通
  4853. SetFieldValue(formFields, "32.OtherMeans", ""); //支付方式 - 其它
  4854. SetFieldValue(formFields, "32.OtherMeansDesc", ""); //支付方式 - 其它(请注明)
  4855. SetFieldValue(formFields, "32.Sponsor", ""); //由赞助方(邀请人、公司或机构)支付,请注明
  4856. SetFieldValue(formFields, "32.Referred", ""); //参见第 30 及 31 项
  4857. SetFieldValue(formFields, "32.ReferredDesc", ""); //参见第 30 及 31 项(请注明)
  4858. SetFieldValue(formFields, "32.OtherSponsor", ""); //其它
  4859. SetFieldValue(formFields, "32.OtherSponsorDesc", ""); //其它(请注明)
  4860. SetFieldValue(formFields, "32.SponsorCash", ""); //赞助方式 - 现金
  4861. SetFieldValue(formFields, "32.SponsorAccommodation", ""); //赞助方式 - 提供住宿
  4862. SetFieldValue(formFields, "32.SponsorExpenses", ""); //赞助方式 - 支付旅程期间所有开支
  4863. SetFieldValue(formFields, "32.SponsorPrepaid", ""); //赞助方式 - 预缴交通
  4864. SetFieldValue(formFields, "32.ponsorOther", ""); //赞助方式 - 其它
  4865. SetFieldValue(formFields, "32.ponsorOtherDesc", ""); //赞助方式 - 其它(请注明)
  4866. SetFieldValue(formFields, "33.PlaceAndDate", DateTime.Now.ToString("yyyy-MM-dd")); //地点及日期
  4867. #endregion
  4868. filePaths.Add(outputPath);
  4869. //return outputPath;
  4870. }
  4871. catch (Exception ex)
  4872. {
  4873. return Ok(JsonView(false, $"生成PDF文件时出错:{ex.Message}"));
  4874. }
  4875. finally
  4876. {
  4877. // 按正确顺序关闭资源
  4878. stamper?.Close();
  4879. reader?.Close();
  4880. templateStream?.Close();
  4881. outputStream?.Close();
  4882. }
  4883. #endregion
  4884. }
  4885. break;
  4886. case 5: // 波兰
  4887. visaTypeName = $"波兰签证申请表";
  4888. currTempPath = $"{tempPath}{visaTypeName}.pdf";
  4889. var polandSavePath = $"{fileServerPath}{visaTypeName}/";
  4890. if (!Directory.Exists(polandSavePath)) Directory.CreateDirectory(polandSavePath);
  4891. if (!System.IO.File.Exists(currTempPath))
  4892. {
  4893. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4894. }
  4895. foreach (var custInfo in groupCustInfos)
  4896. {
  4897. EncryptionProcessor.DecryptProperties(custInfo);
  4898. var visaData = new VisaDateView() {
  4899. groupInfo = groupInfo,
  4900. idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773),
  4901. passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774),
  4902. custInfo = custInfo,
  4903. schoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList(),
  4904. familyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList(),
  4905. companyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList()
  4906. };
  4907. //生成文件
  4908. string outFilePath = CreatePolandVisaPdf(visaData, polandSavePath, currTempPath);
  4909. filePaths.Add(outFilePath);
  4910. }
  4911. break;
  4912. default:
  4913. return Ok(JsonView(false, "正在开发中,请等待。。。"));
  4914. }
  4915. //压缩文件
  4916. var zipFilePathName = $"{groupInfo.TeamName}({visaTypeName}).zip";
  4917. var zipFilePath = $"{fileServerPath}{zipFilePathName}";
  4918. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4919. {
  4920. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4921. {
  4922. foreach (string filePath in filePaths)
  4923. {
  4924. if (System.IO.File.Exists(filePath))
  4925. {
  4926. // 获取文件名
  4927. string fileName = Path.GetFileName(filePath);
  4928. // 将文件添加到ZIP归档中
  4929. zipArchive.CreateEntryFromFile(filePath, fileName);
  4930. }
  4931. }
  4932. }
  4933. }
  4934. url = $"{serverPath}{zipFilePathName}";
  4935. if (!string.IsNullOrEmpty(url))
  4936. {
  4937. return Ok(JsonView(true, url));
  4938. }
  4939. return Ok(JsonView(false, "操作失败!"));
  4940. }
  4941. #region iTextSharp pdf 设置值辅助方法
  4942. /// <summary>
  4943. /// 设置文本值
  4944. /// 辅助方法
  4945. /// </summary>
  4946. /// <param name="formFields"></param>
  4947. /// <param name="fieldName"></param>
  4948. /// <param name="value"></param>
  4949. private static void SetFieldValue(AcroFields formFields, string fieldName, string value)
  4950. {
  4951. if (formFields.Fields.ContainsKey(fieldName) && !string.IsNullOrEmpty(value))
  4952. {
  4953. formFields.SetField(fieldName, value);
  4954. }
  4955. }
  4956. /// <summary>
  4957. /// 创建PDF
  4958. /// </summary>
  4959. /// <param name="data"></param>
  4960. /// <param name="currSavePath"></param>
  4961. /// <param name="currTempPath"></param>
  4962. /// <returns></returns>
  4963. /// <exception cref="Exception"></exception>
  4964. private string CreatePolandVisaPdf(VisaDateView data, string currSavePath,string currTempPath)
  4965. {
  4966. var groupInfo = data.groupInfo;
  4967. var groupId = groupInfo.Id;
  4968. var idInfo = data.idInfo;
  4969. var passportInfo = data.passportInfo;
  4970. var custInfo = data.custInfo;
  4971. var currSchoolInfos = data.schoolInfos;
  4972. var currFamilyInfos = data.familyInfos;
  4973. var currCompanyInfos = data.companyInfos;
  4974. string outputPath = $"{currSavePath}{custInfo.LastName}{custInfo.FirstName}.pdf";
  4975. PdfReader reader = null;
  4976. FileStream templateStream = null;
  4977. FileStream outputStream = null;
  4978. PdfStamper stamper = null;
  4979. try
  4980. {
  4981. //读取模板文件
  4982. templateStream = new FileStream(currTempPath, FileMode.Open, FileAccess.Read, FileShare.Read);
  4983. reader = new PdfReader(templateStream);
  4984. //创建输出文件
  4985. outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write);
  4986. stamper = new PdfStamper(reader, outputStream);
  4987. AcroFields formFields = stamper.AcroFields;
  4988. #region 设置文本值
  4989. SetFieldValue(formFields, "1.LastName", custInfo.LastName); //姓
  4990. SetFieldValue(formFields, "2.BirthLastName", custInfo.LastName); // 出生时姓氏
  4991. SetFieldValue(formFields, "3.FirstName", custInfo.FirstName); // 名
  4992. // 出生日期(日-月-年)
  4993. string idCard = idInfo.CertNo;
  4994. string birthday = string.Empty;
  4995. if (!string.IsNullOrEmpty(idCard))
  4996. {
  4997. string year = idCard.Substring(6, 4);
  4998. string month = idCard.Substring(10, 2);
  4999. string day = idCard.Substring(12, 2);
  5000. birthday = day + "-" + month + "-" + year;
  5001. }
  5002. SetFieldValue(formFields, "4.Birthday", birthday);
  5003. string currentNationality = custInfo.BirthProvince + custInfo.BirthCity;
  5004. SetFieldValue(formFields, "5.CurrentNationality", currentNationality); // 出生地
  5005. SetFieldValue(formFields, "6.CountryBirth", "中国"); // 出生国
  5006. SetFieldValue(formFields, "7.CurrentNationalityCountry", "中国"); // 现国籍
  5007. SetFieldValue(formFields, "7.NationalityBirth", ""); // 出生时国籍,如与现国籍不同
  5008. SetFieldValue(formFields, "7.OtherNationalities", ""); // 其他国籍
  5009. #region 性别处理
  5010. //清除性别
  5011. SetFieldValue(formFields, "8.Male", "Off"); // 性别 - 男
  5012. SetFieldValue(formFields, "8.Female", "Off"); // 性别 - 女
  5013. SetFieldValue(formFields, "8.Other", "Off"); // 性别 - 其他
  5014. //设置性别
  5015. if (custInfo.Sex == 0) //男
  5016. {
  5017. SetFieldValue(formFields, "8.Male", "Yes"); // 性别 - 男
  5018. }
  5019. else if (custInfo.Sex == 1) //女
  5020. {
  5021. SetFieldValue(formFields, "8.Female", "Yes"); // 性别 - 女
  5022. }
  5023. else //其他
  5024. {
  5025. SetFieldValue(formFields, "8.Other", "Yes"); // 性别 - 其他
  5026. }
  5027. #endregion
  5028. #region 婚姻状况处理
  5029. //清除婚姻状况
  5030. SetFieldValue(formFields, "9.Single", "Off"); // 婚姻状况 - 未婚
  5031. SetFieldValue(formFields, "9.Married", "Off"); // 婚姻状况 - 已婚
  5032. SetFieldValue(formFields, "9.RegisteredPartnership", "Off"); // 婚姻状况 - 注册伴侣关系
  5033. SetFieldValue(formFields, "9.Separated", "Off"); // 婚姻状况 - 分居
  5034. SetFieldValue(formFields, "9.Divorced", "Off"); // 婚姻状况 - 离婚
  5035. SetFieldValue(formFields, "9.Widow(er)", "Off"); // 婚姻状况 - 丧偶
  5036. SetFieldValue(formFields, "9.OtherCivilStatus", "Off"); // 婚姻状况 - 其它
  5037. SetFieldValue(formFields, "9.CivilStatusOther", ""); // 婚姻状况 - 其它(请注明)
  5038. //设置婚姻状况
  5039. switch (custInfo.Marriage)
  5040. {
  5041. case 1: // 未婚
  5042. SetFieldValue(formFields, "9.Single", "Yes");
  5043. break;
  5044. case 2: // 已婚
  5045. SetFieldValue(formFields, "9.Married", "Yes");
  5046. break;
  5047. case 3: // 离异
  5048. SetFieldValue(formFields, "9.Divorced", "Yes");
  5049. break;
  5050. case 4: // 离异
  5051. SetFieldValue(formFields, "9.Widow(er)", "Yes");
  5052. break;
  5053. }
  5054. #endregion
  5055. //亲权人(如是未成年申请人 )/合法监护人(姓名、住址,如与申请人不同) 电话号码、电子邮件及国籍
  5056. SetFieldValue(formFields, "10.ParentalAuthority", "");
  5057. SetFieldValue(formFields, "11.NationalIdentityNumber", idCard); //公民身份证号码
  5058. #region 护照(旅行证件类型)处理
  5059. //清除值
  5060. SetFieldValue(formFields, "12.OrdinaryPassport", "Off"); //旅行证件类型 - 普通护照
  5061. SetFieldValue(formFields, "12.DiplomaticPassport", "Off"); //旅行证件类型 - 外交护照
  5062. SetFieldValue(formFields, "12.ServicePassport", "Off"); //旅行证件类型 - 公务护照
  5063. SetFieldValue(formFields, "12.OfficialPassport", "Off"); //旅行证件类型 - 因公护照
  5064. SetFieldValue(formFields, "12.SpecialPassport", "Off"); //旅行证件类型 - 特殊护照
  5065. SetFieldValue(formFields, "12.OtherTravel", "Off"); //旅行证件类型 - 其它旅行证件
  5066. SetFieldValue(formFields, "12.OtherTravelDesc", ""); //旅行证件类型 - 其它旅行证件(请注明)
  5067. //设置值
  5068. SetFieldValue(formFields, "12.OrdinaryPassport", "Yes"); //旅行证件类型 - 普通护照
  5069. if (passportInfo != null)
  5070. {
  5071. SetFieldValue(formFields, "13.TravelNumber", passportInfo.CertNo); //旅行证件编号
  5072. SetFieldValue(formFields, "14.IssueDate", passportInfo.IssueDt?.ToString("yyyy-MM-dd") ?? ""); //签发日期
  5073. SetFieldValue(formFields, "15.ValidUntil", passportInfo.ExpiryDt?.ToString("yyyy-MM-dd") ?? ""); //有效期至
  5074. SetFieldValue(formFields, "16.IssuedCountry", passportInfo.Country); //签发(国)
  5075. }
  5076. #endregion
  5077. //如有家庭成员为欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的,请填写该家庭成员的个人信息
  5078. SetFieldValue(formFields, "17.LastName_om", ""); //姓
  5079. SetFieldValue(formFields, "17.FirstName_om", ""); //名
  5080. SetFieldValue(formFields, "17.BirthDate_om", ""); //出生日期(日-月-年)
  5081. SetFieldValue(formFields, "17.Nationality_om", ""); //国籍
  5082. SetFieldValue(formFields, "17.TravelNuber_om", ""); //旅行证件或身分证编号
  5083. //申请人与欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的关系
  5084. SetFieldValue(formFields, "18.Spouse_om", ""); //配偶
  5085. SetFieldValue(formFields, "18.RegisteredPartnership_om", ""); //注册伴侣
  5086. SetFieldValue(formFields, "18.Child_om", ""); //子女
  5087. SetFieldValue(formFields, "18.DependentAscendant_om", ""); //受养人
  5088. SetFieldValue(formFields, "18.Grandchild_om", ""); //孙子女
  5089. SetFieldValue(formFields, "18.FamilyOther_om", ""); //其他
  5090. SetFieldValue(formFields, "18.FamilyOtherDesc_om", ""); //其他(说明)
  5091. //申请人住址及电子邮件
  5092. string applicantHomeAddress = $"{custInfo.Address} {custInfo.Email}";
  5093. SetFieldValue(formFields, "19.ApplicantHomeAddress", applicantHomeAddress); //申请人住址及电子邮件
  5094. SetFieldValue(formFields, "19.TelephoneNo", custInfo.Tel); //电话号码
  5095. //是否居住在现时国籍以外的国家
  5096. SetFieldValue(formFields, "20.AnotherCountryNo", "Yes"); //否
  5097. SetFieldValue(formFields, "20.AnotherCountryYes", ""); //是
  5098. SetFieldValue(formFields, "20.ResidencePermit", ""); //居住许可或同等证
  5099. SetFieldValue(formFields, "20.Number", ""); //编号
  5100. SetFieldValue(formFields, "20.ValidUntils", ""); //有效期至
  5101. SetFieldValue(formFields, "21.CurrentOccupation", custInfo.Job); //当前职业
  5102. //工作单位名称,地址和电话,学生填写学校名称及地址
  5103. var currCompanyInfo = currCompanyInfos.FirstOrDefault();
  5104. string employerInfoStr = $"{currCompanyInfo?.Company ?? ""} {currCompanyInfo?.CompanyAddress ?? ""} {currCompanyInfo?.Phone ?? ""}";
  5105. SetFieldValue(formFields, "22.EmployerInfo", employerInfoStr);
  5106. #region 旅行的目的
  5107. //清空值
  5108. SetFieldValue(formFields, "23.Tourism", "Off"); // 旅游
  5109. SetFieldValue(formFields, "23.Business", "Off"); // 商务
  5110. SetFieldValue(formFields, "23.VisitingFamily", "Off"); // 探亲访友
  5111. SetFieldValue(formFields, "23.Cultural", "Off"); // 文化
  5112. SetFieldValue(formFields, "23.Sports", "Off"); // 体育
  5113. SetFieldValue(formFields, "23.OfficialVisit", "Off"); // 官方访问
  5114. SetFieldValue(formFields, "23.MedicalReasons", "Off"); // 医疗
  5115. SetFieldValue(formFields, "23.Study", "Off"); // 学习
  5116. SetFieldValue(formFields, "23.AirportTransit", "Off"); // 机场过境
  5117. SetFieldValue(formFields, "23.Other", "Off"); // 其它
  5118. SetFieldValue(formFields, "23.OtherDesc", ""); // 其它 (请注明)
  5119. //设置值
  5120. if (groupInfo.VisitPurpose.contains("旅游")) SetFieldValue(formFields, "23.Tourism", "Yes"); //旅游
  5121. if (groupInfo.VisitPurpose.contains("商务")) SetFieldValue(formFields, "23.Business", "Yes"); //商务
  5122. if (groupInfo.VisitPurpose.contains("探亲访友")) SetFieldValue(formFields, "23.VisitingFamily", "Yes"); //探亲访友
  5123. if (groupInfo.VisitPurpose.contains("文化")) SetFieldValue(formFields, "23.Cultural", "Yes"); //文化
  5124. if (groupInfo.VisitPurpose.contains("体育")) SetFieldValue(formFields, "23.Sports", "Yes"); //体育
  5125. if (groupInfo.VisitPurpose.contains("官方访问")) SetFieldValue(formFields, "23.OfficialVisit", "Yes"); //官方访问
  5126. if (groupInfo.VisitPurpose.contains("医疗")) SetFieldValue(formFields, "23.MedicalReasons", "Yes"); //医疗
  5127. if (groupInfo.VisitPurpose.contains("学习")) SetFieldValue(formFields, "23.Study", "Yes"); //学习
  5128. if (groupInfo.VisitPurpose.contains("机场过境")) SetFieldValue(formFields, "23.AirportTransit", "Yes"); //机场过境
  5129. #endregion
  5130. SetFieldValue(formFields, "24.AdditionalInfo", ""); //有关停留原因的补充信息
  5131. string[] RD_country = new string[] { }; //接收处理的国家
  5132. string firstEntryLabel = string.Empty; //首入申根国标签
  5133. string membeDescLabel = string.Empty; //申根国目的地
  5134. string stopDays = string.Empty; //停留天数
  5135. if (!string.IsNullOrEmpty(groupInfo.VisitCountry))
  5136. {
  5137. List<string> SGGNames = new List<string>();//接收处理后的国家 是申根国
  5138. if (groupInfo.VisitCountry.Contains(","))
  5139. RD_country = groupInfo.VisitCountry.Split(',');
  5140. else if (groupInfo.VisitCountry.Contains(' '))
  5141. RD_country = groupInfo.VisitCountry.Split(' ');
  5142. else if (groupInfo.VisitCountry.Contains(","))
  5143. RD_country = groupInfo.VisitCountry.Split(',');
  5144. else if (groupInfo.VisitCountry.Contains("、"))
  5145. RD_country = groupInfo.VisitCountry.Split('、');
  5146. else if (groupInfo.VisitCountry.Contains("|"))
  5147. RD_country = groupInfo.VisitCountry.Split('|');
  5148. //判断是否是申根国家
  5149. for (int i = 0; i < RD_country.Length; i++)
  5150. {
  5151. if (RD_country[i].ToString() != null)
  5152. {
  5153. //在申根国家中筛选 该国家是否是申根国家
  5154. for (int j = 0; j < _shenGenGuos.Length; j++)
  5155. {
  5156. if (RD_country[i] == _shenGenGuos[j])
  5157. SGGNames.Add(_shenGenGuos[j]); //添加申根国
  5158. }
  5159. }
  5160. }
  5161. //目的地国是否有申根国
  5162. if (SGGNames.Count > 0)
  5163. {
  5164. firstEntryLabel = SGGNames.First();
  5165. membeDescLabel = string.Join(",", SGGNames.ToArray());
  5166. //接收生根国详细信息 存储顺序 起飞日期:Day 起飞时刻:StartTime 抵达日期:ArrivedDate 到达时刻:EndTime
  5167. List<SSGDetails> ListSSGDetails = new List<SSGDetails>();
  5168. //处理申根国家 预定到达时间 预定离开时间 预定停留天数
  5169. for (int i = 0; i < SGGNames.Count; i++)
  5170. {
  5171. //在相同的国家下 得到该航班的信息 //抵达时间 起飞日期:Day 起飞时刻:StartTime 到达时刻:EndTime 抵达日期:ArrivedDate 飞行时间:FlightTime 航司 Fliagtcode 入境口岸
  5172. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  5173. //ResidenceTime1 机票三字码信息
  5174. if (atbc != null)
  5175. {
  5176. string HL_Three = ""; //三字码 Three
  5177. for (int j = 0; j < atbc.Rows.Count; j++)
  5178. {
  5179. HL_Three = atbc.Rows[j]["Three"].ToString();
  5180. if (!string.IsNullOrEmpty(HL_Three))
  5181. {
  5182. string threeCodeTwo = HL_Three.Substring(3);
  5183. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == threeCodeTwo).First();
  5184. if (tc != null)
  5185. {
  5186. //首入申根国时间
  5187. if (SGGNames[i] == tc.Country)
  5188. {
  5189. SSGDetails SSGDetails = new SSGDetails()
  5190. {
  5191. Three = atbc.Rows[j]["Three"].ToString(), //三字码
  5192. Fliagtcode = atbc.Rows[j]["Fliagtcode"].ToString(), //航司
  5193. startDate = atbc.Rows[j]["Day"].ToString(), //整理起飞日期
  5194. startTime = atbc.Rows[j]["StartTime"].ToString(), //整理起飞时刻
  5195. endDate = atbc.Rows[j]["ArrivedDate"].ToString(), //整理抵达日期
  5196. endTime = atbc.Rows[j]["EndTime"].ToString() //整理抵达时刻
  5197. };
  5198. ListSSGDetails.Add(SSGDetails);
  5199. }
  5200. }
  5201. }
  5202. }
  5203. }
  5204. }
  5205. ListSSGDetails.Sort((a, b) => a.startDate.CompareTo(b.startDate));
  5206. //得到并计算出入境时间
  5207. if (ListSSGDetails != null)
  5208. {
  5209. string RuJingTime = ListSSGDetails.First().endDate + " " + ListSSGDetails.First().endTime.Substring(0, 2) + ":" + ListSSGDetails.First().endTime.Substring(2); //入境时间
  5210. string LiJingTime = ListSSGDetails[ListSSGDetails.Count - 1].startDate + " " + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(0, 2) + ":" + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(2); //离境时间
  5211. stopDays = Convert.ToDateTime(LiJingTime).Subtract(Convert.ToDateTime(RuJingTime)).Days.ToString();
  5212. }
  5213. }
  5214. }
  5215. SetFieldValue(formFields, "25.MembeDesc", membeDescLabel); //主要申根目的地 (以及其他申根目的地,如适用)
  5216. SetFieldValue(formFields, "26.FirstEntry", firstEntryLabel); //首入申根国
  5217. //申请入境次数
  5218. SetFieldValue(formFields, "27.SingleEntry", ""); //单次
  5219. SetFieldValue(formFields, "27.TwoEntries", ""); //两次
  5220. SetFieldValue(formFields, "27.MultipleEntries", ""); //多次
  5221. SetFieldValue(formFields, "27.IntendedDateIn", ""); //在申根地区预计首次停留的预计抵达日期
  5222. SetFieldValue(formFields, "27.IntendedDateOut", ""); //在申根地区预计首次停留之后的预计离开日期
  5223. //以往申根国签证是否有指纹记录
  5224. SetFieldValue(formFields, "28.No", ""); //否
  5225. SetFieldValue(formFields, "28.Yes", ""); //是
  5226. SetFieldValue(formFields, "28.KnownDate", ""); //如有,请写明日期
  5227. SetFieldValue(formFields, "28.KnownVisanumber", ""); //如有,请写明签证贴纸号码
  5228. //最后目的地之入境许可
  5229. SetFieldValue(formFields, "29.Issued", ""); //签发机关 Entry permit for the final country of destination, where applicable
  5230. SetFieldValue(formFields, "29.ValidFrom", ""); //有效期由
  5231. SetFieldValue(formFields, "29.Until", ""); //至
  5232. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  5233. //得到当前国家下的城市酒店信息
  5234. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  5235. .Where(x => x.DiId == groupId)
  5236. //.Where(x => x.City.contains(city))
  5237. .First();
  5238. //酒店住址
  5239. if (hotelInfo != null)
  5240. {
  5241. SetFieldValue(formFields, "30.SurnameFirstName", hotelInfo?.HotelName ?? ""); //申根国的酒店
  5242. var otherInfo = $"{hotelInfo.HotelAddress}";
  5243. SetFieldValue(formFields, "30.HotelInfo", otherInfo); //邀请人/酒店/暂住居所的地址及电子邮件
  5244. SetFieldValue(formFields, "30.TelephoneNo", hotelInfo?.HotelTel ?? ""); //电话号码
  5245. }
  5246. //邀请公司或机构的名称及地址
  5247. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  5248. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  5249. //.Where(x => x.Country.Contains(county))
  5250. //.Where(x => x.Area.Contains(city))
  5251. .First();
  5252. if (oa != null)
  5253. {
  5254. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  5255. SetFieldValue(formFields, "30.SurnameFirstName", oa?.Contact ?? ""); //申根国的酒店
  5256. SetFieldValue(formFields, "30.HotelInfo", oa?.Address ?? ""); //邀请人/酒店/暂住居所的地址及电子邮件
  5257. SetFieldValue(formFields, "30.TelephoneNo", oa?.Tel ?? ""); //电话号码
  5258. string nameAddressLabel = $"{oa.Client} {oa.Address}";
  5259. SetFieldValue(formFields, "31.NameAddress", nameAddressLabel); //邀请公司或机构的名称及地址
  5260. string surnameLabel = $"{oa.Contact} {oa.Tel}";
  5261. SetFieldValue(formFields, "31.Surname", surnameLabel); //邀请公司或机构的联系人姓名、地址、电话号码及电子邮件
  5262. SetFieldValue(formFields, "31.TelephoneNo", oa?.Tel ?? ""); //邀请公司或机构的电话
  5263. }
  5264. //申请人的旅费以及在国外停留期间的生活费用
  5265. SetFieldValue(formFields, "32.Applicant", ""); //由申请人支付
  5266. SetFieldValue(formFields, "32.Cash", ""); //支付方式 - 现金
  5267. SetFieldValue(formFields, "32.Traveller", ""); //支付方式 - 旅行支票
  5268. SetFieldValue(formFields, "32.CreditCard", ""); //支付方式 - 信用卡
  5269. SetFieldValue(formFields, "32.Prepaid", ""); //支付方式 - 预缴住宿
  5270. SetFieldValue(formFields, "32.Prepaid1", ""); //支付方式 - 预缴交通
  5271. SetFieldValue(formFields, "32.OtherMeans", ""); //支付方式 - 其它
  5272. SetFieldValue(formFields, "32.OtherMeansDesc", ""); //支付方式 - 其它(请注明)
  5273. SetFieldValue(formFields, "32.Sponsor", ""); //由赞助方(邀请人、公司或机构)支付,请注明
  5274. SetFieldValue(formFields, "32.Referred", ""); //参见第 30 及 31 项
  5275. SetFieldValue(formFields, "32.ReferredDesc", ""); //参见第 30 及 31 项(请注明)
  5276. SetFieldValue(formFields, "32.OtherSponsor", ""); //其它
  5277. SetFieldValue(formFields, "32.OtherSponsorDesc", ""); //其它(请注明)
  5278. SetFieldValue(formFields, "32.SponsorCash", ""); //赞助方式 - 现金
  5279. SetFieldValue(formFields, "32.SponsorAccommodation", ""); //赞助方式 - 提供住宿
  5280. SetFieldValue(formFields, "32.SponsorExpenses", ""); //赞助方式 - 支付旅程期间所有开支
  5281. SetFieldValue(formFields, "32.SponsorPrepaid", ""); //赞助方式 - 预缴交通
  5282. SetFieldValue(formFields, "32.ponsorOther", ""); //赞助方式 - 其它
  5283. SetFieldValue(formFields, "32.ponsorOtherDesc", ""); //赞助方式 - 其它(请注明)
  5284. //填表人与申请人不同
  5285. SetFieldValue(formFields, "33.WriteTableName", ""); //姓名
  5286. SetFieldValue(formFields, "33.WriteTableAddress", ""); //住址
  5287. SetFieldValue(formFields, "33.WriteTableTel", ""); //电话
  5288. SetFieldValue(formFields, "EndPlaceAndDate", DateTime.Now.ToString("yyyy-MM-dd")); //地点及日期
  5289. #endregion
  5290. }
  5291. catch (Exception ex)
  5292. {
  5293. throw new Exception($"生成PDF文件时出错: {ex.Message}", ex);
  5294. }
  5295. finally
  5296. {
  5297. // 按正确顺序关闭资源
  5298. stamper?.Close();
  5299. reader?.Close();
  5300. templateStream?.Close();
  5301. outputStream?.Close();
  5302. }
  5303. return outputPath;
  5304. }
  5305. #endregion
  5306. #region 文档下载辅助实体类
  5307. private class VisaDateView
  5308. {
  5309. /// <summary>
  5310. /// 团组信息
  5311. /// </summary>
  5312. public Grp_DelegationInfo groupInfo { get; set; }
  5313. /// <summary>
  5314. /// 身份证信息
  5315. /// </summary>
  5316. public Crm_CustomerCert idInfo { get; set; }
  5317. /// <summary>
  5318. /// 护照信息
  5319. /// </summary>
  5320. public Crm_CustomerCert passportInfo { get; set; }
  5321. /// <summary>
  5322. /// 客户信息
  5323. /// </summary>
  5324. public Crm_DeleClient custInfo { get; set; }
  5325. /// <summary>
  5326. /// 学校资料
  5327. /// </summary>
  5328. public List<Crm_VisaCustomerSchool> schoolInfos { get; set; }
  5329. /// <summary>
  5330. /// 家庭成员资料
  5331. /// </summary>
  5332. public List<Crm_VisaCustomerFamily> familyInfos { get; set; }
  5333. /// <summary>
  5334. /// 公司资料
  5335. /// </summary>
  5336. public List<Crm_VisaCustomerCompany> companyInfos { get; set; }
  5337. }
  5338. private class SSGDetails
  5339. {
  5340. public string Three { get; set; } //三字码
  5341. public string Fliagtcode { get; set; } //航司
  5342. public string startDate { get; set; } //首入申根国日期
  5343. public string startTime { get; set; } //首入申根国时间
  5344. public string endDate { get; set; } //离开申根国日期
  5345. public string endTime { get; set; } //离开申根国时间
  5346. }
  5347. #endregion
  5348. #endregion
  5349. /// <summary>
  5350. /// 根据团组Id获取签证客户信息List
  5351. /// </summary>
  5352. /// <param name="dto">请求dto</param>
  5353. /// <returns></returns>
  5354. [HttpPost]
  5355. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5356. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  5357. {
  5358. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  5359. if (groupData.Code != 0)
  5360. {
  5361. return Ok(JsonView(false, groupData.Msg));
  5362. }
  5363. return Ok(JsonView(groupData.Data));
  5364. }
  5365. /// <summary>
  5366. /// IOS获取团组签证拍照上传进度01(团组列表)
  5367. /// </summary>
  5368. /// <param name="dto">请求dto</param>
  5369. /// <returns></returns>
  5370. [HttpPost]
  5371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5372. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  5373. {
  5374. if (dto == null)
  5375. {
  5376. return Ok(JsonView(false, "参数为空"));
  5377. }
  5378. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  5379. return Ok(JsonView(visaList));
  5380. }
  5381. /// <summary>
  5382. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  5383. /// </summary>
  5384. /// <returns></returns>
  5385. [HttpPost]
  5386. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5387. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  5388. {
  5389. if (dto == null)
  5390. {
  5391. return Ok(JsonView(false, "请求错误:"));
  5392. }
  5393. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  5394. return Ok(JsonView(list));
  5395. }
  5396. /// <summary>
  5397. /// IOS获取团组签证拍照上传进度03(相册)
  5398. /// </summary>
  5399. /// <returns></returns>
  5400. [HttpPost]
  5401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5402. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  5403. {
  5404. if (dto == null)
  5405. {
  5406. return Ok(JsonView(false, "请求错误:"));
  5407. }
  5408. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  5409. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  5410. list.ForEach(s => s.url = url);
  5411. return Ok(JsonView(list));
  5412. }
  5413. /// <summary>
  5414. /// IOS获取团组签证拍照上传进度04(图片上传)
  5415. /// </summary>
  5416. /// <param name="dto"></param>
  5417. /// <returns></returns>
  5418. [HttpPost]
  5419. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5420. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  5421. {
  5422. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  5423. //if (!string.IsNullOrEmpty(result))
  5424. //{
  5425. //}
  5426. //else {
  5427. // return Ok(JsonView(false, "上传失败"));
  5428. //}
  5429. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  5430. int sucNum = 0;
  5431. try
  5432. {
  5433. foreach (var item in dto.base64DataList)
  5434. {
  5435. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  5436. string result = DecodeBase64ToImage(item, imageName);
  5437. if (!string.IsNullOrEmpty(result))
  5438. {
  5439. var pic = new Grp_VisaProgressCustomerPicture
  5440. {
  5441. CreateUserId = dto.CreateUserId,
  5442. PicName = imageName,
  5443. PicPath = result,
  5444. VisaProgressCustomerId = dto.visaProgressCustomerId
  5445. };
  5446. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  5447. if (insertResult > 0)
  5448. {
  5449. sucNum++;
  5450. }
  5451. }
  5452. }
  5453. }
  5454. catch (Exception ex)
  5455. {
  5456. return Ok(JsonView(false, ex.Message));
  5457. }
  5458. string msg = string.Format(@"成功上传{0}张", sucNum);
  5459. return Ok(JsonView(true, msg));
  5460. }
  5461. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  5462. {
  5463. string filename = "";//声明一个string类型的相对路径
  5464. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  5465. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  5466. try//会有异常抛出,try,catch一下
  5467. {
  5468. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  5469. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  5470. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  5471. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  5472. //文件名称
  5473. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  5474. //上传的文件的路径
  5475. string filePath = "";
  5476. if (!Directory.Exists(fileDir))
  5477. {
  5478. Directory.CreateDirectory(fileDir);
  5479. }
  5480. //上传的文件的路径
  5481. filePath = fileDir + filename;
  5482. //string url = HttpRuntime.AppDomainAppPath.ToString();
  5483. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  5484. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  5485. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  5486. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  5487. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  5488. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  5489. ms.Close();//关闭当前流,并释放所有与之关联的资源
  5490. bitmap.Dispose();
  5491. }
  5492. catch (Exception e)
  5493. {
  5494. string massage = e.Message;
  5495. Logs("IOS图片上传Error:" + massage);
  5496. //filename = e.Message;
  5497. }
  5498. return filename;//返回相对路径
  5499. }
  5500. /// <summary>
  5501. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  5502. /// </summary>
  5503. /// <param name="dto"></param>
  5504. /// <returns></returns>
  5505. [HttpPost]
  5506. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5507. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  5508. {
  5509. if (dto == null)
  5510. {
  5511. return Ok(JsonView(false, "请求错误:"));
  5512. }
  5513. string msg = "参数错误";
  5514. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  5515. {
  5516. try
  5517. {
  5518. //_delegationVisaRep.BeginTran();
  5519. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  5520. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  5521. .Where(s => s.Id == dto.visaProgressCustomerId)
  5522. .ExecuteCommandAsync();
  5523. if (updCount > 0 && dto.publishCode == 1)
  5524. {
  5525. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  5526. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  5527. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  5528. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  5529. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  5530. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  5531. if (groupData == null)
  5532. {
  5533. _delegationVisaRep.RollbackTran();
  5534. }
  5535. string title = string.Format(@"[签证进度更新]");
  5536. string content = string.Format(@"测试文本");
  5537. bool rst = await _message.AddMsg(new MessageDto()
  5538. {
  5539. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  5540. IssuerId = dto.publisher,
  5541. Title = title,
  5542. Content = content,
  5543. ReleaseTime = DateTime.Now,
  5544. UIdList = new List<int> {
  5545. 234
  5546. }
  5547. });
  5548. if (rst)
  5549. {
  5550. return Ok(JsonView(true, "发送通知成功"));
  5551. }
  5552. }
  5553. //_delegationVisaRep.CommitTran();
  5554. }
  5555. catch (Exception)
  5556. {
  5557. //_delegationVisaRep.RollbackTran();
  5558. }
  5559. }
  5560. return Ok(JsonView(true, msg));
  5561. }
  5562. #endregion
  5563. #endregion
  5564. #region 团组任务分配
  5565. /// <summary>
  5566. /// 团组任务分配初始化
  5567. /// </summary>
  5568. /// <returns></returns>
  5569. [HttpPost]
  5570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5571. public async Task<IActionResult> GetTaskAssignmen()
  5572. {
  5573. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  5574. if (groupData.Code != 0)
  5575. {
  5576. return Ok(JsonView(false, groupData.Msg));
  5577. }
  5578. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5579. }
  5580. /// <summary>
  5581. /// 团组任务分配查询
  5582. /// </summary>
  5583. /// <param name="dto"></param>
  5584. /// <returns></returns>
  5585. [HttpPost]
  5586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5587. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  5588. {
  5589. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  5590. if (groupData.Code != 0)
  5591. {
  5592. return Ok(JsonView(false, groupData.Msg));
  5593. }
  5594. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5595. }
  5596. /// <summary>
  5597. /// 团组任务分配操作
  5598. /// </summary>
  5599. /// <param name="dto"></param>
  5600. /// <returns></returns>
  5601. [HttpPost]
  5602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5603. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  5604. {
  5605. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  5606. if (groupData.Code != 0)
  5607. {
  5608. return Ok(JsonView(false, groupData.Msg));
  5609. }
  5610. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5611. }
  5612. /// <summary>
  5613. /// 团组任务分配
  5614. /// 批量分配
  5615. /// 查询团组
  5616. /// </summary>
  5617. /// <param name="dto"></param>
  5618. /// <returns></returns>
  5619. [HttpPost]
  5620. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5621. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  5622. {
  5623. //参数验证
  5624. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  5625. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  5626. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  5627. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  5628. }
  5629. /// <summary>
  5630. /// 团组任务分配
  5631. /// 批量分配
  5632. /// </summary>
  5633. /// <param name="dto"></param>
  5634. /// <returns></returns>
  5635. [HttpPost]
  5636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5637. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  5638. {
  5639. //参数验证
  5640. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  5641. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  5642. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  5643. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  5644. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  5645. }
  5646. #endregion
  5647. #region 团组费用审核
  5648. /// <summary>
  5649. /// 费用审核
  5650. /// 团组列表 Page
  5651. /// </summary>
  5652. /// <param name="_dto">团组列表请求dto</param>
  5653. /// <returns></returns>
  5654. [HttpPost]
  5655. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5656. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  5657. {
  5658. #region 参数验证
  5659. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  5660. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  5661. #region 页面操作权限验证
  5662. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  5663. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  5664. #endregion
  5665. #endregion
  5666. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 3) // web/Android/IOS
  5667. {
  5668. string sqlWhere = string.Empty;
  5669. if (_dto.IsSure == 0) //未完成
  5670. {
  5671. sqlWhere += string.Format(@" And IsSure = 0");
  5672. }
  5673. else if (_dto.IsSure == 1) //已完成
  5674. {
  5675. sqlWhere += string.Format(@" And IsSure = 1");
  5676. }
  5677. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  5678. {
  5679. string tj = _dto.SearchCriteria;
  5680. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or su.CnName Like '%{3}%')",
  5681. tj, tj, tj, tj);
  5682. }
  5683. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  5684. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  5685. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  5686. From (
  5687. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  5688. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  5689. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  5690. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  5691. From Grp_DelegationInfo gdi
  5692. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  5693. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  5694. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  5695. Where gdi.IsDel = 0 {0}
  5696. ) temp ", sqlWhere);
  5697. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  5698. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  5699. var _view = new
  5700. {
  5701. PageFuncAuth = pageFunAuthView,
  5702. Data = _DelegationList
  5703. };
  5704. return Ok(JsonView(true, "查询成功!", _view, total));
  5705. }
  5706. else
  5707. {
  5708. return Ok(JsonView(false, "查询失败"));
  5709. }
  5710. }
  5711. /// <summary>
  5712. /// 获取团组费用审核
  5713. /// </summary>
  5714. /// <param name="_dto"></param>
  5715. /// <returns></returns>
  5716. [HttpPost]
  5717. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5718. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  5719. {
  5720. try
  5721. {
  5722. #region 参数验证
  5723. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  5724. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  5725. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  5726. #region 页面操作权限验证
  5727. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  5728. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  5729. #endregion
  5730. #endregion
  5731. var _view = new Grp_CreditCardPaymentView();
  5732. var clientNameList = GetSimplClientList(_dto.DiId);
  5733. #region 费用清单
  5734. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  5735. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  5736. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  5737. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  5738. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  5739. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  5740. /*
  5741. * 76://酒店预订
  5742. */
  5743. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5744. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5745. /*
  5746. * 79://车/导游地接
  5747. */
  5748. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5749. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5750. /*
  5751. * 80: //签证
  5752. */
  5753. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5754. /*
  5755. *81: //邀请/公务活动
  5756. */
  5757. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5758. /*
  5759. * 82: //团组客户保险
  5760. */
  5761. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5762. /*
  5763. * Lable = 85 机票预订
  5764. */
  5765. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5766. /*
  5767. * 85 机票预定
  5768. */
  5769. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5770. /*
  5771. * 98 其他款项
  5772. */
  5773. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5774. /*
  5775. * 285:收款退还
  5776. */
  5777. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5778. /*
  5779. * 1015: //超支费用
  5780. */
  5781. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5782. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  5783. /*
  5784. * 币种信息
  5785. */
  5786. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  5787. /*
  5788. * 车/导游地接 费用类型
  5789. */
  5790. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  5791. /*
  5792. * 车/导游地接 费用类型
  5793. */
  5794. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  5795. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  5796. /*
  5797. * 用户信息
  5798. */
  5799. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  5800. /*
  5801. * 费用模块
  5802. */
  5803. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  5804. string priceModule = string.Empty;
  5805. if (sdPriceName != null)
  5806. {
  5807. priceModule = sdPriceName.Name;
  5808. }
  5809. /*
  5810. * 成本信息
  5811. */
  5812. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  5813. decimal _groupRate = 0.0000M;
  5814. string _groupCurrencyCode = "-";
  5815. if (groupCost != null)
  5816. {
  5817. _groupRate = groupCost.Rate;
  5818. if (int.TryParse(groupCost.Currency, out int _currency))
  5819. {
  5820. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  5821. }
  5822. else _groupCurrencyCode = groupCost.Currency;
  5823. }
  5824. string costContentSql = $"Select * From Grp_GroupCost";
  5825. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  5826. //处理日期为空的天数
  5827. for (int i = 0; i < groupCostDetails.Count; i++)
  5828. if (i != 0)
  5829. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  5830. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  5831. /*
  5832. * 处理详情数据
  5833. */
  5834. foreach (var entity in entityList)
  5835. {
  5836. var _detail = new Grp_CreditCardPaymentDetailView
  5837. {
  5838. Id = entity.Id,
  5839. PriceName = priceModule,
  5840. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  5841. };
  5842. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  5843. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  5844. //处理金额
  5845. if (entity.CTable == 1015)
  5846. {
  5847. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  5848. if (czInfo != null)
  5849. {
  5850. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  5851. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  5852. }
  5853. }
  5854. /*
  5855. * 应付款金额
  5856. */
  5857. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  5858. string PaymentCurrency_WaitPay = "Unknown";
  5859. string hotelCurrncyCode = "Unknown";
  5860. string hotelCurrncyName = "Unknown";
  5861. if (sdPaymentCurrency_WaitPay != null)
  5862. {
  5863. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  5864. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  5865. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  5866. if (hotelCurrncyCode.Equals("CNY"))
  5867. {
  5868. entity.DayRate = 1.0000M;
  5869. }
  5870. }
  5871. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  5872. /*
  5873. * 此次付款金额
  5874. */
  5875. decimal CurrPayStr = 0.00M,
  5876. OriginalCurrPay = 0.00M;
  5877. if (entity.PayPercentage == 0)
  5878. {
  5879. if (entity.PayThenMoney != 0)
  5880. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  5881. }
  5882. else
  5883. {
  5884. if (entity.PayMoney != 0)
  5885. {
  5886. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  5887. }
  5888. }
  5889. //if (_dto.Label == 79)
  5890. //{
  5891. // string original = string.Empty;
  5892. // if (hotelCurrncyCode.Equals("CNY"))
  5893. // {
  5894. // OriginalCurrPay = CurrPayStr;
  5895. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  5896. // }
  5897. // else
  5898. // {
  5899. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  5900. // //760 EUR(7600.00 CNY)
  5901. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  5902. // }
  5903. //}
  5904. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  5905. string original = string.Empty;
  5906. if (hotelCurrncyCode.Equals("CNY"))
  5907. {
  5908. OriginalCurrPay = CurrPayStr;
  5909. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  5910. }
  5911. else
  5912. {
  5913. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  5914. //760 EUR(7600.00 CNY)
  5915. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  5916. }
  5917. /*
  5918. * 剩余尾款
  5919. */
  5920. decimal BalanceStr = 0;
  5921. if (CurrPayStr != 0)
  5922. {
  5923. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  5924. BalanceStr = 0;
  5925. else
  5926. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  5927. }
  5928. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  5929. /*
  5930. * Bus名称
  5931. */
  5932. _detail.BusName = "待增加";
  5933. /*
  5934. *费用所属
  5935. */
  5936. switch (entity.CTable)
  5937. {
  5938. case 76://酒店预订
  5939. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  5940. if (hotelReservations != null)
  5941. {
  5942. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  5943. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  5944. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  5945. string roomFeeStr = "", roomFeestr1 = "";
  5946. //是否比较房型价格
  5947. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  5948. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  5949. roomFeeStr += $"<br/>";
  5950. var roomTotal = 0.00M;
  5951. if (hotelReservations.SingleRoomPrice > 0)
  5952. {
  5953. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  5954. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5955. //__isSingle = true;
  5956. roomTotal += fee;
  5957. }
  5958. if (hotelReservations.DoubleRoomPrice > 0)
  5959. {
  5960. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  5961. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5962. // __isDouble = true;
  5963. roomTotal += fee;
  5964. }
  5965. if (hotelReservations.SuiteRoomPrice > 0)
  5966. {
  5967. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  5968. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5969. //__isSuite = true;
  5970. roomTotal += fee;
  5971. }
  5972. if (hotelReservations.OtherRoomPrice > 0)
  5973. {
  5974. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  5975. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5976. //__isOther = true;
  5977. roomTotal += fee;
  5978. }
  5979. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  5980. else roomFeeStr += " 0.00 * 0";
  5981. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  5982. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  5983. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  5984. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  5985. /*
  5986. * 费用类型
  5987. * 1:房费
  5988. * 2:早餐
  5989. * 3:地税
  5990. * 4:城市税
  5991. * </summary>
  5992. */
  5993. //地税
  5994. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  5995. if (governmentRentData != null)
  5996. {
  5997. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  5998. governmentRentFee = governmentRentData.Price;
  5999. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  6000. if (governmentRentCurrData != null)
  6001. {
  6002. governmentRentCode = governmentRentCurrData.Name;
  6003. governmentRentName = $"({governmentRentCurrData.Remark})";
  6004. }
  6005. }
  6006. //城市税
  6007. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  6008. if (cityTaxData != null)
  6009. {
  6010. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  6011. cityTaxFee = cityTaxData.Price;
  6012. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  6013. if (cityTaxCurrData != null)
  6014. {
  6015. cityTaxCode = cityTaxCurrData.Name;
  6016. cityTaxName = $"({cityTaxCurrData.Remark})";
  6017. }
  6018. }
  6019. //酒店早餐
  6020. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  6021. if (breakfastData != null)
  6022. {
  6023. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  6024. breakfastFee = breakfastData.Price;
  6025. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  6026. if (breakfastCurrData != null)
  6027. {
  6028. breakfastCode = breakfastCurrData.Name;
  6029. breakfastName = $"({breakfastCurrData.Remark})";
  6030. }
  6031. }
  6032. //房间费用
  6033. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  6034. if (roomData != null)
  6035. {
  6036. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  6037. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  6038. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  6039. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  6040. roomFee = roomData.Price;
  6041. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  6042. if (roomCurrData != null)
  6043. {
  6044. roomCode = roomCurrData.Name;
  6045. roomName = $"({roomCurrData.Remark})";
  6046. }
  6047. }
  6048. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  6049. string hotelCostStr = "";
  6050. decimal hotelCsotTotal = 0.00M;
  6051. if (groupCost != null)
  6052. {
  6053. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  6054. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  6055. }
  6056. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  6057. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  6058. string hotelCost_day = "";
  6059. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  6060. foreach (var item in hotelCostDetails1)
  6061. {
  6062. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  6063. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  6064. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  6065. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  6066. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  6067. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  6068. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  6069. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  6070. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  6071. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  6072. hotelCost_day += @$"<br/>";
  6073. }
  6074. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  6075. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  6076. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  6077. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  6078. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  6079. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  6080. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  6081. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  6082. $"房间说明: {hotelReservations.Remark} <br/>" +
  6083. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  6084. $"{hotelBreakfastStr}" +
  6085. $"{hotelGovernmentRentStr}" +
  6086. $"{hotelCityTaxStr}";
  6087. _detail.PriceNameContent = hotelReservations.HotelName;
  6088. }
  6089. break;
  6090. case 79://车/导游地接
  6091. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  6092. if (touristGuideGroundReservations != null)
  6093. {
  6094. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  6095. {
  6096. _detail.BusName = touristGuideGroundReservations.BusName;
  6097. }
  6098. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  6099. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  6100. //if (isInt)
  6101. //{
  6102. // var cityInfo = cityData.Find(it => it.Id == cityId);
  6103. // if (cityInfo != null)
  6104. // {
  6105. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  6106. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  6107. // if (carFeeItem != null)
  6108. // {
  6109. // nameContent += $@"({carFeeItem.Name})";
  6110. // }
  6111. // _detail.PriceNameContent = nameContent;
  6112. // }
  6113. //}
  6114. //else
  6115. //{
  6116. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  6117. //}
  6118. var touristGuideGroundReservationsContents =
  6119. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  6120. var opContent_sb = new StringBuilder();
  6121. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  6122. opContent_sb.AppendLine(contetTitle);
  6123. foreach (var item in touristGuideGroundReservationsContents)
  6124. {
  6125. string typeName = "Unknown";
  6126. string carCurrencyCode = "Unknown";
  6127. string carCurrencyName = "Unknown";
  6128. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  6129. if (carTypeData != null) typeName = carTypeData.Name;
  6130. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  6131. if (currencyData != null)
  6132. {
  6133. carCurrencyCode = currencyData.Name;
  6134. carCurrencyName = currencyData.Remark;
  6135. }
  6136. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  6137. bool IsCurrencyAgreement = false;
  6138. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  6139. string opCostStr = string.Empty;
  6140. decimal opCostTypePrice = 0.00M;
  6141. #region 处理成本各项费用
  6142. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  6143. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  6144. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  6145. costOPFeeCNY = 0.00M, //团组成本 op费用
  6146. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  6147. if (opCost.Count > 0)
  6148. {
  6149. switch (item.SId)
  6150. {
  6151. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  6152. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  6153. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  6154. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  6155. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  6156. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  6157. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  6158. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  6159. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  6160. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  6161. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  6162. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  6163. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  6164. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  6165. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  6166. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  6167. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  6168. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  6169. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  6170. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  6171. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  6172. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  6173. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  6174. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  6175. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  6176. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  6177. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  6178. }
  6179. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  6180. costOPFeeCNY = opCostTypePrice * _groupRate;
  6181. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  6182. }
  6183. #endregion
  6184. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  6185. aduitOPFeeCNY = item.Price * entity.DayRate;
  6186. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  6187. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  6188. $"{opTypeStr} {opCostStr}<br/>" +
  6189. $"明细:{item.PriceContent ?? "-"}<br/>" +
  6190. $"备注:{item.Remark ?? "-"}<br/><br/>";
  6191. if (entity.IsAuditGM != 3) //状态 != 自动审核
  6192. {
  6193. if (IsCurrencyAgreement)
  6194. {
  6195. if (item.Price > opCostTypePrice)
  6196. {
  6197. opContent_sb.Append("<span style='color:red;'>");
  6198. opContent_sb.Append(opContent);
  6199. opContent_sb.Append("</span>");
  6200. opContent_sb.AppendLine();
  6201. }
  6202. else
  6203. {
  6204. opContent_sb.Append(opContent);
  6205. opContent_sb.AppendLine();
  6206. }
  6207. }
  6208. else
  6209. {
  6210. //验证是否超成本 按付款比例计算
  6211. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  6212. {
  6213. opContent_sb.Append("<span style='color:red;'>");
  6214. opContent_sb.Append(opContent);
  6215. opContent_sb.Append("</span>");
  6216. opContent_sb.AppendLine();
  6217. }
  6218. else
  6219. {
  6220. opContent_sb.Append(opContent);
  6221. opContent_sb.AppendLine();
  6222. }
  6223. }
  6224. }
  6225. else
  6226. {
  6227. opContent_sb.Append(opContent);
  6228. opContent_sb.AppendLine();
  6229. }
  6230. }
  6231. _detail.PriceMsgContent = opContent_sb.ToString();
  6232. }
  6233. break;
  6234. case 80: //签证
  6235. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  6236. if (visaInfo != null)
  6237. {
  6238. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  6239. _detail.PriceNameContent = visaInfo.VisaDescription;
  6240. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  6241. }
  6242. break;
  6243. case 81: //邀请/公务活动
  6244. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  6245. if (_ioa != null)
  6246. {
  6247. string inviteCurrName = "Unknown", //邀请费用币种 Name
  6248. inviteCurrCode = "Unknown", //邀请费用币种 Code
  6249. sendCurrName = "Unknown", //快递费用币种 Name
  6250. sendCurrCode = "Unknown", //快递费用币种 Code
  6251. eventsCurrName = "Unknown", //公务活动费币种 Name
  6252. eventsCurrCode = "Unknown", //公务活动费币种 Code
  6253. translateCurrName = "Unknown", //公务翻译费 Name
  6254. translateCurrCode = "Unknown"; //公务翻译费 Code
  6255. #region 处理费用币种
  6256. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  6257. if (inviteCurrData != null)
  6258. {
  6259. inviteCurrName = inviteCurrData.Remark;
  6260. inviteCurrCode = inviteCurrData.Name;
  6261. }
  6262. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  6263. if (sendCurrData != null)
  6264. {
  6265. sendCurrName = sendCurrData.Remark;
  6266. sendCurrCode = sendCurrData.Name;
  6267. }
  6268. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  6269. if (eventsCurrData != null)
  6270. {
  6271. eventsCurrName = eventsCurrData.Remark;
  6272. eventsCurrCode = eventsCurrData.Name;
  6273. }
  6274. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  6275. if (translateCurrData != null)
  6276. {
  6277. translateCurrName = translateCurrData.Remark;
  6278. translateCurrCode = translateCurrData.Name;
  6279. }
  6280. #endregion
  6281. _detail.PriceNameContent = _ioa.InviterArea;
  6282. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  6283. List<string> priceExpNames = new List<string>();
  6284. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  6285. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  6286. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  6287. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  6288. if (priceExpNames != null && priceExpNames.Count > 0)
  6289. {
  6290. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  6291. }
  6292. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  6293. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  6294. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  6295. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  6296. $@"备注:" + _ioa.Remark + "<br/>";
  6297. }
  6298. break;
  6299. case 82: //团组客户保险
  6300. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  6301. if (customers != null)
  6302. {
  6303. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  6304. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  6305. }
  6306. break;
  6307. case 85: //机票预订
  6308. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  6309. if (jpRes != null)
  6310. {
  6311. string FlightsDescription = jpRes.FlightsDescription;
  6312. string PriceDescription = jpRes.PriceDescription;
  6313. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  6314. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  6315. }
  6316. break;
  6317. case 98://其他款项
  6318. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  6319. if (gdpRes != null)
  6320. {
  6321. //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/";
  6322. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  6323. //{
  6324. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  6325. //}
  6326. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  6327. _detail.PriceNameContent = gdpRes.PriceName;
  6328. }
  6329. break;
  6330. case 285://收款退还
  6331. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  6332. if (refundAndOtherMoney != null)
  6333. {
  6334. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  6335. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  6336. }
  6337. break;
  6338. case 751://酒店早餐
  6339. break;
  6340. case 1015://超支费用
  6341. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  6342. if (groupExtraCost != null)
  6343. {
  6344. _detail.PriceNameContent = groupExtraCost.PriceName;
  6345. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  6346. }
  6347. break;
  6348. default:
  6349. break;
  6350. }
  6351. /*
  6352. * 申请人
  6353. */
  6354. string operatorName = " - ";
  6355. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  6356. if (_opUser != null)
  6357. {
  6358. operatorName = _opUser.CnName;
  6359. }
  6360. _detail.OperatorName = operatorName;
  6361. /*
  6362. * 审核人
  6363. */
  6364. string auditOperatorName = " - ";
  6365. if (entity.IsAuditGM != 0)
  6366. {
  6367. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  6368. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  6369. else
  6370. {
  6371. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  6372. if (_adUser != null)
  6373. {
  6374. auditOperatorName = _adUser.CnName;
  6375. }
  6376. }
  6377. }
  6378. _detail.AuditOperatorName = auditOperatorName;
  6379. /*
  6380. * 超预算比例
  6381. */
  6382. string overBudgetStr = "";
  6383. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  6384. else if (entity.ExceedBudget == 0)
  6385. {
  6386. if (entity.CTable == 76 || entity.CTable == 79)
  6387. {
  6388. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  6389. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  6390. }
  6391. else
  6392. {
  6393. overBudgetStr = "未超预算";
  6394. }
  6395. }
  6396. else overBudgetStr = entity.ExceedBudget.ToString("P");
  6397. _detail.OverBudget = overBudgetStr;
  6398. decimal auditFee = 0.00M; //已审核金额 人名币
  6399. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  6400. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  6401. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  6402. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  6403. {
  6404. auditedFeeOriginal = entity.PayMoney;
  6405. auditFee = CurrPayStr;
  6406. }
  6407. else if (entity.IsAuditGM == 0)
  6408. {
  6409. unAuditFeeCNY = CurrPayStr;
  6410. unAuditFeeOriginal = OriginalCurrPay;
  6411. OriginalCurrPay = 0.00M;
  6412. }
  6413. /*
  6414. * 费用总计
  6415. */
  6416. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  6417. {
  6418. CurrencyId = entity.PaymentCurrency,
  6419. CurrencyName = PaymentCurrency_WaitPay,
  6420. AmountPayable = entity.PayMoney,
  6421. ThisPayment = OriginalCurrPay,
  6422. BalancePayment = BalanceStr,
  6423. AuditedFunds = auditFee,
  6424. AuditedFundsOriginal = auditedFeeOriginal,
  6425. UnAuditFundsCNY = unAuditFeeCNY,
  6426. UnAuditFundsOriginal = unAuditFeeOriginal
  6427. });
  6428. _detail.IsAuditGM = entity.IsAuditGM;
  6429. detailList.Add(_detail);
  6430. }
  6431. #endregion
  6432. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  6433. /*
  6434. * 下方描述处理
  6435. */
  6436. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  6437. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  6438. if (ccpCurrencyPrice != null)
  6439. {
  6440. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  6441. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  6442. }
  6443. else
  6444. {
  6445. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  6446. }
  6447. string amountPayableStr = string.Format(@"应付款总金额: ");
  6448. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  6449. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  6450. string auditedFundsStr = string.Format(@"已审费用总额: ");
  6451. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  6452. foreach (var item in nonDuplicat)
  6453. {
  6454. var currencyName = item.CurrencyName;
  6455. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  6456. if (strs.Count > 0)
  6457. {
  6458. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  6459. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  6460. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  6461. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  6462. //单独处理此次付款金额
  6463. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  6464. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  6465. //单独处理已审核费用
  6466. //if (item.CurrencyId == 836) //人民币
  6467. //{
  6468. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  6469. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  6470. //}
  6471. //else
  6472. //{
  6473. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  6474. //}
  6475. if (currencyName.Equals("CNY"))
  6476. {
  6477. //已审核费用
  6478. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  6479. //未审核费用
  6480. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  6481. }
  6482. else
  6483. {
  6484. //已审核费用
  6485. 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"));
  6486. //未审核费用
  6487. 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"));
  6488. }
  6489. }
  6490. }
  6491. _view.TotalStr1 = amountPayableStr[..^1];
  6492. _view.TotalStr2 = thisPaymentStr[..^1];
  6493. _view.TotalStr3 = balancePaymentStr[..^1];
  6494. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  6495. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  6496. var _view1 = new
  6497. {
  6498. PageFuncAuth = pageFunAuthView,
  6499. Data = _view
  6500. };
  6501. return Ok(JsonView(_view1));
  6502. }
  6503. catch (Exception ex)
  6504. {
  6505. return Ok(JsonView(false, ex.Message));
  6506. }
  6507. }
  6508. /// <summary>
  6509. /// 费用审核
  6510. /// 修改团组费用审核状态
  6511. /// </summary>
  6512. /// <param name="_dto">参数Json字符串</param>
  6513. /// <returns></returns>
  6514. [HttpPost]
  6515. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6516. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  6517. {
  6518. #region 参数验证
  6519. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6520. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  6521. #endregion
  6522. #region 页面操作权限验证
  6523. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6524. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  6525. #endregion
  6526. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  6527. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  6528. DateTime dtNow = DateTime.Now;
  6529. _groupRepository.BeginTran();
  6530. int rst = 0;
  6531. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  6532. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  6533. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6534. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  6535. var msgDatas = new List<dynamic>();
  6536. var dic_ccp_user = new Dictionary<int, int>() { };
  6537. foreach (var item in idList)
  6538. {
  6539. int CreditId = int.Parse(item);
  6540. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  6541. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  6542. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  6543. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  6544. .Where(s => s.Id == CreditId)
  6545. .ExecuteCommandAsync();
  6546. if (result < 1)
  6547. {
  6548. rst = -1;
  6549. _groupRepository.RollbackTran();
  6550. return Ok(JsonView(false, "操作失败并回滚!"));
  6551. }
  6552. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  6553. if (creditData != null)
  6554. {
  6555. #region 应用通知配置
  6556. try
  6557. {
  6558. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  6559. }
  6560. catch (Exception ex)
  6561. {
  6562. }
  6563. #endregion
  6564. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  6565. string groupNameStr = string.Empty;
  6566. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  6567. if (groupData != null) groupNameStr = groupData.TeamName;
  6568. string creditTypeStr = string.Empty;
  6569. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  6570. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  6571. string creditCurrency = string.Empty;
  6572. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  6573. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  6574. if (creditCurrency.Equals("CNY"))
  6575. {
  6576. creditData.DayRate = 1.0000M;
  6577. }
  6578. if (creditData.PayPercentage == 0.00M)
  6579. {
  6580. creditData.PayPercentage = 100M;
  6581. }
  6582. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  6583. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  6584. string msgContent = "";
  6585. if (creditCurrency.Equals("CNY"))
  6586. {
  6587. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  6588. }
  6589. else
  6590. {
  6591. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  6592. }
  6593. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  6594. }
  6595. }
  6596. if (rst == 0)
  6597. {
  6598. _groupRepository.CommitTran();
  6599. foreach (var item in msgDatas)
  6600. {
  6601. //发送消息
  6602. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  6603. }
  6604. #region 应用推送
  6605. try
  6606. {
  6607. foreach (var ccpId in dic_ccp_user.Keys)
  6608. {
  6609. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  6610. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  6611. }
  6612. }
  6613. catch (Exception)
  6614. {
  6615. }
  6616. #endregion
  6617. return Ok(JsonView(true, "操作成功!"));
  6618. }
  6619. return Ok(JsonView(false, "操作失败!"));
  6620. }
  6621. /// <summary>
  6622. /// 费用审核
  6623. /// 其他款项 文件下载
  6624. /// </summary>
  6625. /// <param name="id">其他款项 主键编号</param>
  6626. /// <returns></returns>
  6627. [HttpGet("{id}")]
  6628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6629. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  6630. {
  6631. //网站域名
  6632. 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/";
  6633. var otherInfo = await _decreasePaymentsRep._sqlSugar
  6634. .Queryable<Grp_DecreasePayments>()
  6635. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  6636. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  6637. .Select((x, y) => new
  6638. {
  6639. x.Id,
  6640. x.FilePath
  6641. })
  6642. .FirstAsync();
  6643. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  6644. {
  6645. var url = $"{baseUrl}{otherInfo.FilePath}";
  6646. return Ok(JsonView(true, "操作成功!", url));
  6647. }
  6648. return Ok(JsonView(false, "暂无附件"));
  6649. }
  6650. #endregion
  6651. #region 机票费用录入
  6652. /// <summary>
  6653. /// 机票录入当前登录人可操作团组
  6654. /// </summary>
  6655. /// <param name="dto"></param>
  6656. /// <returns></returns>
  6657. [HttpPost]
  6658. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6659. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  6660. {
  6661. try
  6662. {
  6663. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  6664. if (groupData.Code != 0)
  6665. {
  6666. return Ok(JsonView(false, groupData.Msg));
  6667. }
  6668. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6669. }
  6670. catch (Exception ex)
  6671. {
  6672. return Ok(JsonView(false, ex.Message));
  6673. }
  6674. }
  6675. /// <summary>
  6676. /// 机票费用录入列表
  6677. /// </summary>
  6678. /// <param name="dto"></param>
  6679. /// <returns></returns>
  6680. [HttpPost]
  6681. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6682. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  6683. {
  6684. try
  6685. {
  6686. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  6687. if (groupData.Code != 0)
  6688. {
  6689. return Ok(JsonView(false, groupData.Msg));
  6690. }
  6691. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6692. }
  6693. catch (Exception ex)
  6694. {
  6695. return Ok(JsonView(false, ex.Message));
  6696. throw;
  6697. }
  6698. }
  6699. /// <summary>
  6700. /// 根据id查询费用录入信息
  6701. /// </summary>
  6702. /// <param name="dto"></param>
  6703. /// <returns></returns>
  6704. [HttpPost]
  6705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6706. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  6707. {
  6708. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  6709. if (groupData.Code != 0)
  6710. {
  6711. return Ok(JsonView(false, groupData.Msg));
  6712. }
  6713. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6714. }
  6715. /// <summary>
  6716. /// 机票费用录入操作(Status:1.新增,2.修改)
  6717. /// </summary>
  6718. /// <param name="dto"></param>
  6719. /// <returns></returns>
  6720. [HttpPost]
  6721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6722. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  6723. {
  6724. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  6725. if (groupData.Code != 0)
  6726. {
  6727. return Ok(JsonView(false, groupData.Msg));
  6728. }
  6729. #region 应用推送
  6730. try
  6731. {
  6732. var diId = dto.AirTicketResOpData.DiId;
  6733. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6734. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6735. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  6736. //自动审核
  6737. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  6738. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  6739. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  6740. $"GroupId:{diId};airId:{dataId};",
  6741. status,
  6742. auditMsg);
  6743. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6744. //2024-10-21 新增LZ UID
  6745. var userIds = new List<int>() { 21 };
  6746. string title = $"系统通知";
  6747. string content = "";
  6748. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6749. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6750. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6751. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6752. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6753. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  6754. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6755. }
  6756. catch (Exception ex)
  6757. {
  6758. }
  6759. #endregion
  6760. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6761. }
  6762. /// <summary>
  6763. /// 机票费用自动审核 AI识别方式
  6764. /// </summary>
  6765. /// <returns></returns>
  6766. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  6767. {
  6768. var ecoTypeIds = new List<int>() {
  6769. 459, //超经舱
  6770. 460, //经济舱
  6771. 1430, //公务舱(实际经济舱)
  6772. 1432, //头等舱(实际经济舱)
  6773. };
  6774. var bizTypeIds = new List<int>() {
  6775. 457, //头等舱
  6776. 458, //公务舱
  6777. 1431, //头等舱(实际公务舱)
  6778. };
  6779. var auditFeeTypeIds = new List<int>() { };
  6780. auditFeeTypeIds.AddRange(ecoTypeIds);
  6781. auditFeeTypeIds.AddRange(bizTypeIds);
  6782. int currModule = 85;
  6783. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  6784. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  6785. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  6786. .Select((x, y) => new
  6787. {
  6788. x.Id,
  6789. CcpId = y.Id,
  6790. x.FlightsDate,
  6791. x.PrePrice,
  6792. x.CType,
  6793. x.ClientNum,
  6794. x.DIId
  6795. })
  6796. .FirstAsync();
  6797. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  6798. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  6799. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  6800. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  6801. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  6802. var groupCostContents = await _sqlSugar
  6803. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  6804. .Where(x => x.IsDel == 0 && x.Diid == diId)
  6805. .ToListAsync();
  6806. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  6807. //处理 成本详细信息日期为空 填装费用信息
  6808. var airFeeLabel = new StringBuilder();
  6809. airFeeLabel.AppendLine("费用成本:");
  6810. for (int i = 0; i < groupCostContents.Count; i++)
  6811. {
  6812. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  6813. {
  6814. int index = i - 1;
  6815. if (index >= 0)
  6816. {
  6817. groupCostContents[i].Date = groupCostContents[index].Date;
  6818. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  6819. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  6820. }
  6821. }
  6822. else
  6823. {
  6824. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  6825. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  6826. }
  6827. var item = groupCostContents[i];
  6828. airFeeLabel.AppendLine($"{item.Date}");
  6829. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  6830. }
  6831. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  6832. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  6833. //访问Kimi AI 返回价格结果
  6834. var msgs = new List<SeedMessages>()
  6835. {
  6836. new ()
  6837. {
  6838. Role = KimiRole.user,
  6839. Content = airFeeLabel.ToString()
  6840. }
  6841. };
  6842. var client = new KiMiApiClient();
  6843. var kimiApiResult = await client.SeedMessage(msgs);
  6844. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  6845. string clients = kimiApiResult_JObject["content"].ToString();
  6846. decimal ecoPri_kimiAI = 0.00M,
  6847. bizPri_kimiAI = 0.00M;
  6848. //单个价格: 经济舱价格
  6849. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  6850. //价格文本包含/:/前经济舱价格 /后公务舱价格
  6851. if (clients.Contains('/'))
  6852. {
  6853. var priArray = clients.Split('/');
  6854. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  6855. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  6856. }
  6857. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  6858. var isAutoAudit = false;
  6859. //价格验证处理
  6860. //经济舱
  6861. if (ecoTypeIds.Contains(airInfo.CType))
  6862. {
  6863. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  6864. }
  6865. //公务舱
  6866. else if (bizTypeIds.Contains(airInfo.CType))
  6867. {
  6868. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  6869. }
  6870. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  6871. //是否执行自动审核
  6872. if (isAutoAudit)
  6873. {
  6874. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6875. .SetColumns(x => x.IsAuditGM == 3)
  6876. .SetColumns(x => x.AuditGMOperate == 4)
  6877. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  6878. .Where(x => x.Id == airInfo.CcpId)
  6879. .ExecuteCommandAsync();
  6880. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  6881. }
  6882. return (false, "当前费用超过成本费用,不可自动审核!");
  6883. }
  6884. /// <summary>
  6885. /// 机票费用录入
  6886. /// 自动审核测试 - AI 识别
  6887. /// </summary>
  6888. /// <param name="groupId"></param>
  6889. /// <param name="Id"></param>
  6890. /// <returns></returns>
  6891. [HttpPost]
  6892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6893. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  6894. {
  6895. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  6896. return Ok(JsonView(status, msg));
  6897. }
  6898. /// <summary>
  6899. /// 根据舱位类型查询接团客户名单信息
  6900. /// </summary>
  6901. /// <param name="dto"></param>
  6902. /// <returns></returns>
  6903. [HttpPost]
  6904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6905. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  6906. {
  6907. try
  6908. {
  6909. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  6910. if (crm_Groups.Count != 0)
  6911. {
  6912. var Customer = new List<dynamic>();
  6913. foreach (var item in crm_Groups)
  6914. {
  6915. var data = new
  6916. {
  6917. item.Id,
  6918. item.Pinyin,
  6919. Name = item.LastName + item.FirstName
  6920. };
  6921. Customer.Add(data);
  6922. }
  6923. return Ok(JsonView(true, "查询成功!", Customer));
  6924. }
  6925. return Ok(JsonView(true, "暂无数据", crm_Groups));
  6926. }
  6927. catch (Exception ex)
  6928. {
  6929. return Ok(JsonView(false, "程序错误!"));
  6930. throw;
  6931. }
  6932. }
  6933. /// <summary>
  6934. /// 根据团号获取客户信息
  6935. /// </summary>
  6936. /// <param name="dto"></param>
  6937. /// <returns></returns>
  6938. [HttpPost]
  6939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6940. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  6941. {
  6942. var jw = JsonView(false);
  6943. if (dto.DIID < 1)
  6944. {
  6945. jw.Msg += "请输入正确的diid";
  6946. return Ok(jw);
  6947. }
  6948. var arr = GetSimplClientList(dto.DIID);
  6949. jw = JsonView(true, "获取成功!", arr);
  6950. return Ok(jw);
  6951. }
  6952. private List<SimplClientInfo> GetSimplClientList(int diId)
  6953. {
  6954. 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);
  6955. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  6956. foreach (var item in arr)
  6957. {
  6958. EncryptionProcessor.DecryptProperties(item);
  6959. }
  6960. return arr;
  6961. }
  6962. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  6963. {
  6964. string result = origin;
  6965. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  6966. {
  6967. string[] temparr = origin.Split(',');
  6968. string fistrStr = temparr[0];
  6969. int count = temparr.Length;
  6970. bool success = int.TryParse(fistrStr, out int tempId);
  6971. if (success)
  6972. {
  6973. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  6974. if (tempInfo != null)
  6975. {
  6976. if (count > 1)
  6977. {
  6978. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  6979. }
  6980. else
  6981. {
  6982. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  6983. }
  6984. }
  6985. }
  6986. }
  6987. return result;
  6988. }
  6989. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  6990. {
  6991. string result = origin;
  6992. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  6993. {
  6994. string[] temparr = origin.Split(',');
  6995. result = "";
  6996. foreach (var item in temparr)
  6997. {
  6998. bool success = int.TryParse(item, out int tempId);
  6999. if (success)
  7000. {
  7001. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  7002. if (tempInfo != null)
  7003. {
  7004. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  7005. }
  7006. }
  7007. }
  7008. }
  7009. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  7010. return result;
  7011. }
  7012. /// <summary>
  7013. /// 机票费用录入,删除
  7014. /// </summary>
  7015. /// <param name="dto"></param>
  7016. /// <returns></returns>
  7017. [HttpPost]
  7018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7019. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  7020. {
  7021. try
  7022. {
  7023. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7024. if (res)
  7025. {
  7026. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  7027. {
  7028. IsDel = 1,
  7029. DeleteUserId = dto.DeleteUserId,
  7030. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7031. }).ExecuteCommandAsync();
  7032. return Ok(JsonView(true, "删除成功!"));
  7033. }
  7034. return Ok(JsonView(false, "删除失败!"));
  7035. }
  7036. catch (Exception ex)
  7037. {
  7038. return Ok(JsonView(false, "程序错误!"));
  7039. throw;
  7040. }
  7041. }
  7042. /// <summary>
  7043. /// 导出机票录入报表
  7044. /// </summary>
  7045. /// <param name="dto"></param>
  7046. /// <returns></returns>
  7047. [HttpPost]
  7048. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7049. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  7050. {
  7051. try
  7052. {
  7053. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  7054. if (groupData.Code != 0)
  7055. {
  7056. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  7057. }
  7058. else
  7059. {
  7060. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  7061. if (AirTicketReservations.Count != 0)
  7062. {
  7063. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  7064. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  7065. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  7066. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  7067. var designer = new WorkbookDesigner
  7068. {
  7069. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  7070. };
  7071. decimal countCost = 0;
  7072. foreach (var item in AirTicketReservations)
  7073. {
  7074. #region 处理客人姓名
  7075. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  7076. item.ClientName = clientNames;
  7077. #endregion
  7078. if (item.BankType == "其他")
  7079. {
  7080. item.BankNo = "--";
  7081. }
  7082. else
  7083. {
  7084. if (!string.IsNullOrEmpty(item.BankType))
  7085. {
  7086. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  7087. }
  7088. }
  7089. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  7090. item.Price = System.Decimal.Round(item.Price, 2);
  7091. countCost += Convert.ToDecimal(item.Price);
  7092. }
  7093. designer.SetDataSource("Export", AirTicketReservations);
  7094. designer.SetDataSource("ExportDiCode", diCode);
  7095. designer.SetDataSource("ExportDiName", diName);
  7096. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  7097. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  7098. designer.Process();
  7099. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  7100. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  7101. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  7102. return Ok(JsonView(true, "成功", url = rst));
  7103. }
  7104. else
  7105. {
  7106. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  7107. }
  7108. }
  7109. }
  7110. catch (Exception ex)
  7111. {
  7112. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  7113. throw;
  7114. }
  7115. }
  7116. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  7117. /// <summary>
  7118. /// 行程单导出
  7119. /// </summary>
  7120. /// <param name="dto"></param>
  7121. /// <returns></returns>
  7122. [HttpPost]
  7123. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7124. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  7125. {
  7126. try
  7127. {
  7128. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  7129. if (groupData.Code != 0)
  7130. {
  7131. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  7132. }
  7133. else
  7134. {
  7135. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  7136. if (dto.Language == "CN")
  7137. {
  7138. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  7139. var builder = new DocumentBuilder(doc);
  7140. int tableIndex = 0;//表格索引
  7141. //得到文档中的第一个表格
  7142. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  7143. foreach (var item in _AirTicketReservations)
  7144. {
  7145. #region 处理固定数据
  7146. string[] FlightsCode = item.FlightsCode.Split('/');
  7147. if (FlightsCode.Length != 0)
  7148. {
  7149. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7150. if (_AirCompany != null)
  7151. {
  7152. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  7153. }
  7154. else
  7155. {
  7156. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7157. }
  7158. }
  7159. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7160. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7161. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7162. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7163. string name = "";
  7164. foreach (string clientName in nameArray)
  7165. {
  7166. if (!name.Contains(clientName))
  7167. {
  7168. name += clientName + ",";
  7169. }
  7170. }
  7171. if (!string.IsNullOrWhiteSpace(name))
  7172. {
  7173. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  7174. }
  7175. else
  7176. {
  7177. table.Range.Bookmarks["ClientName"].Text = "--";
  7178. }
  7179. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7180. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7181. table.Range.Bookmarks["JointTicket"].Text = "--";
  7182. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7183. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7184. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7185. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7186. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7187. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7188. #endregion
  7189. #region 循环数据处理
  7190. var airs = new List<AirInfo>();
  7191. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  7192. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  7193. for (int i = 0; i < FlightsCode.Length; i++)
  7194. {
  7195. var air = new AirInfo();
  7196. string[] tempstr = DayArray[i]
  7197. .Replace("\r\n", string.Empty)
  7198. .Replace("\\r\\n", string.Empty)
  7199. .TrimStart().TrimEnd()
  7200. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  7201. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  7202. string starCity = "";
  7203. if (star_Three != null)
  7204. {
  7205. starCity = star_Three.AirPort;
  7206. }
  7207. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  7208. string EndCity = "";
  7209. if (End_Three != null)
  7210. {
  7211. EndCity = End_Three.AirPort;
  7212. }
  7213. air.Destination = starCity + "/" + EndCity;
  7214. air.Flight = FlightsCode[i];
  7215. air.SeatingClass = item.CTypeName;
  7216. string dateTime = tempstr[2];
  7217. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  7218. air.FlightDate = DateTemp;
  7219. air.DepartureTime = tempstr[5];
  7220. air.LandingTime = tempstr[6];
  7221. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  7222. air.TicketStatus = "--";
  7223. air.Luggage = "--";
  7224. air.DepartureTerminal = "--";
  7225. air.LandingTerminal = "--";
  7226. airs.Add(air);
  7227. }
  7228. int row = 13;
  7229. for (int i = 0; i < airs.Count; i++)
  7230. {
  7231. if (airs.Count > 2)
  7232. {
  7233. for (int j = 0; j < airs.Count - 2; j++)
  7234. {
  7235. var CopyRow = table.Rows[12].Clone(true);
  7236. table.Rows.Add(CopyRow);
  7237. }
  7238. }
  7239. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  7240. int index = 0;
  7241. foreach (PropertyInfo property in properties)
  7242. {
  7243. string value = property.GetValue(airs[i]).ToString();
  7244. Cell ishcel0 = table.Rows[row].Cells[index];
  7245. var p = new Paragraph(doc);
  7246. string s = value;
  7247. p.AppendChild(new Run(doc, s));
  7248. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  7249. ishcel0.AppendChild(p);
  7250. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  7251. index++;
  7252. }
  7253. row++;
  7254. }
  7255. #endregion
  7256. var lastParagraph = new Paragraph(doc);
  7257. //第一个表格末尾加段落
  7258. table.ParentNode.InsertAfter(lastParagraph, table);
  7259. //复制第一个表格
  7260. Table cloneTable = (Table)table.Clone(true);
  7261. //在文档末尾段落后面加入复制的表格
  7262. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  7263. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  7264. {
  7265. int rownewsIndex = 13;
  7266. for (int i = 0; i < 2; i++)
  7267. {
  7268. var CopyRow = table.Rows[12].Clone(true);
  7269. table.Rows.RemoveAt(13);
  7270. table.Rows.Add(CopyRow);
  7271. rownewsIndex++;
  7272. }
  7273. }
  7274. else
  7275. {
  7276. table.Rows.RemoveAt(12);
  7277. }
  7278. cloneTable.Rows.RemoveAt(12);
  7279. }
  7280. if (_AirTicketReservations.Count != 0)
  7281. {
  7282. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  7283. if (FlightsCode.Length != 0)
  7284. {
  7285. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7286. if (_AirCompany != null)
  7287. {
  7288. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  7289. }
  7290. else
  7291. {
  7292. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7293. }
  7294. }
  7295. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7296. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7297. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7298. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7299. string name = "";
  7300. foreach (string clientName in nameArray)
  7301. {
  7302. if (!name.Contains(clientName))
  7303. {
  7304. name += clientName + ",";
  7305. }
  7306. }
  7307. if (!string.IsNullOrWhiteSpace(name))
  7308. {
  7309. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  7310. }
  7311. else
  7312. {
  7313. table.Range.Bookmarks["ClientName"].Text = "--";
  7314. }
  7315. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7316. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7317. table.Range.Bookmarks["JointTicket"].Text = "--";
  7318. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7319. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7320. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7321. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7322. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7323. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7324. }
  7325. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  7326. //保存合并后的文档
  7327. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  7328. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  7329. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  7330. return Ok(JsonView(true, "成功!", rst));
  7331. }
  7332. else
  7333. {
  7334. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  7335. var builder = new DocumentBuilder(doc);
  7336. int tableIndex = 0;//表格索引
  7337. //得到文档中的第一个表格
  7338. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  7339. var texts = new List<string>();
  7340. foreach (var item in _AirTicketReservations)
  7341. {
  7342. string[] FlightsCode = item.FlightsCode.Split('/');
  7343. if (FlightsCode.Length != 0)
  7344. {
  7345. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7346. if (_AirCompany != null)
  7347. {
  7348. if (!transDic.ContainsKey(_AirCompany.CnName))
  7349. {
  7350. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  7351. }
  7352. }
  7353. else
  7354. {
  7355. if (!transDic.ContainsKey("--"))
  7356. {
  7357. transDic.Add("--", "--");
  7358. }
  7359. }
  7360. }
  7361. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7362. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7363. string name = "";
  7364. foreach (string clientName in nameArray)
  7365. {
  7366. name += clientName + ",";
  7367. }
  7368. if (!texts.Contains(name))
  7369. {
  7370. texts.Add(name);
  7371. }
  7372. var airs = new List<AirInfo>();
  7373. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  7374. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  7375. for (int i = 0; i < FlightsCode.Length; i++)
  7376. {
  7377. var air = new AirInfo();
  7378. string[] tempstr = DayArray[i]
  7379. .Replace("\r\n", string.Empty)
  7380. .Replace("\\r\\n", string.Empty)
  7381. .TrimStart().TrimEnd()
  7382. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  7383. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  7384. if (star_Three != null)
  7385. {
  7386. if (!transDic.ContainsKey(star_Three.AirPort))
  7387. {
  7388. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  7389. }
  7390. }
  7391. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  7392. if (End_Three != null)
  7393. {
  7394. if (!transDic.ContainsKey(End_Three.AirPort))
  7395. {
  7396. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  7397. }
  7398. }
  7399. if (!texts.Contains(item.CTypeName))
  7400. {
  7401. texts.Add(item.CTypeName);
  7402. }
  7403. }
  7404. }
  7405. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  7406. if (transData.Count > 0)
  7407. {
  7408. foreach (TranslateResult item in transData)
  7409. {
  7410. if (!transDic.ContainsKey(item.Query))
  7411. {
  7412. transDic.Add(item.Query, item.Translation);
  7413. }
  7414. }
  7415. }
  7416. foreach (var item in _AirTicketReservations)
  7417. {
  7418. #region 处理固定数据
  7419. string[] FlightsCode = item.FlightsCode.Split('/');
  7420. if (FlightsCode.Length != 0)
  7421. {
  7422. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7423. if (_AirCompany != null)
  7424. {
  7425. string str = "--";
  7426. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  7427. if (!string.IsNullOrEmpty(translateResult))
  7428. {
  7429. str = translateResult;
  7430. str = _airTicketResRep.Processing(str);
  7431. }
  7432. table.Range.Bookmarks["AirlineCompany"].Text = str;
  7433. }
  7434. else
  7435. {
  7436. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7437. }
  7438. }
  7439. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7440. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7441. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7442. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7443. string names = "";
  7444. foreach (string clientName in nameArray)
  7445. {
  7446. names += clientName + ",";
  7447. }
  7448. if (!string.IsNullOrWhiteSpace(names))
  7449. {
  7450. string str = "--";
  7451. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  7452. if (!string.IsNullOrEmpty(translateResult))
  7453. {
  7454. str = translateResult;
  7455. str = _airTicketResRep.Processing(str);
  7456. }
  7457. table.Range.Bookmarks["ClientName"].Text = str;
  7458. }
  7459. else
  7460. {
  7461. table.Range.Bookmarks["ClientName"].Text = "--";
  7462. }
  7463. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7464. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7465. table.Range.Bookmarks["JointTicket"].Text = "--";
  7466. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7467. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7468. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7469. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7470. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7471. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7472. #endregion
  7473. #region 循环数据处理
  7474. var airs = new List<AirInfo>();
  7475. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  7476. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  7477. for (int i = 0; i < FlightsCode.Length; i++)
  7478. {
  7479. var air = new AirInfo();
  7480. string[] tempstr = DayArray[i]
  7481. .Replace("\r\n", string.Empty)
  7482. .Replace("\\r\\n", string.Empty)
  7483. .TrimStart().TrimEnd()
  7484. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  7485. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  7486. string starCity = "";
  7487. if (star_Three != null)
  7488. {
  7489. string str2 = "--";
  7490. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  7491. if (!string.IsNullOrEmpty(translateResult2))
  7492. {
  7493. str2 = translateResult2;
  7494. str2 = _airTicketResRep.Processing(str2);
  7495. }
  7496. starCity = str2;
  7497. }
  7498. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  7499. string EndCity = "";
  7500. if (End_Three != null)
  7501. {
  7502. string str1 = "--";
  7503. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  7504. if (!string.IsNullOrEmpty(translateResult1))
  7505. {
  7506. str1 = translateResult1;
  7507. str1 = _airTicketResRep.Processing(str1);
  7508. }
  7509. EndCity = str1;
  7510. }
  7511. air.Destination = starCity + "/" + EndCity;
  7512. air.Flight = FlightsCode[i];
  7513. string str = "--";
  7514. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  7515. if (!string.IsNullOrEmpty(translateResult))
  7516. {
  7517. str = translateResult;
  7518. str = _airTicketResRep.Processing(str);
  7519. }
  7520. air.SeatingClass = str;
  7521. string dateTime = tempstr[2];
  7522. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  7523. air.FlightDate = DateTemp;
  7524. air.DepartureTime = tempstr[5];
  7525. air.LandingTime = tempstr[6];
  7526. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  7527. air.TicketStatus = "--";
  7528. air.Luggage = "--";
  7529. air.DepartureTerminal = "--";
  7530. air.LandingTerminal = "--";
  7531. airs.Add(air);
  7532. }
  7533. int row = 13;
  7534. for (int i = 0; i < airs.Count; i++)
  7535. {
  7536. if (airs.Count > 2)
  7537. {
  7538. for (int j = 0; j < airs.Count - 2; j++)
  7539. {
  7540. var CopyRow = table.Rows[12].Clone(true);
  7541. table.Rows.Add(CopyRow);
  7542. }
  7543. }
  7544. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  7545. int index = 0;
  7546. foreach (PropertyInfo property in properties)
  7547. {
  7548. string value = property.GetValue(airs[i]).ToString();
  7549. Cell ishcel0 = table.Rows[row].Cells[index];
  7550. var p = new Paragraph(doc);
  7551. string s = value;
  7552. p.AppendChild(new Run(doc, s));
  7553. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  7554. ishcel0.AppendChild(p);
  7555. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  7556. //ishcel0.CellFormat.VerticalAlignment=
  7557. index++;
  7558. }
  7559. row++;
  7560. }
  7561. #endregion
  7562. var lastParagraph = new Paragraph(doc);
  7563. //第一个表格末尾加段落
  7564. table.ParentNode.InsertAfter(lastParagraph, table);
  7565. //复制第一个表格
  7566. Table cloneTable = (Table)table.Clone(true);
  7567. //在文档末尾段落后面加入复制的表格
  7568. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  7569. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  7570. {
  7571. int rownewsIndex = 13;
  7572. for (int i = 0; i < 2; i++)
  7573. {
  7574. var CopyRow = table.Rows[12].Clone(true);
  7575. table.Rows.RemoveAt(13);
  7576. table.Rows.Add(CopyRow);
  7577. rownewsIndex++;
  7578. }
  7579. }
  7580. else
  7581. {
  7582. table.Rows.RemoveAt(12);
  7583. }
  7584. cloneTable.Rows.RemoveAt(12);
  7585. }
  7586. if (_AirTicketReservations.Count != 0)
  7587. {
  7588. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  7589. if (FlightsCode.Length != 0)
  7590. {
  7591. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7592. if (_AirCompany != null)
  7593. {
  7594. string str = "--";
  7595. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  7596. if (!string.IsNullOrEmpty(translateResult))
  7597. {
  7598. str = translateResult;
  7599. str = _airTicketResRep.Processing(str);
  7600. }
  7601. table.Range.Bookmarks["AirlineCompany"].Text = str;
  7602. }
  7603. else
  7604. {
  7605. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7606. }
  7607. }
  7608. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7609. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7610. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7611. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7612. string names = "";
  7613. foreach (string clientName in nameArray)
  7614. {
  7615. names += clientName + ",";
  7616. }
  7617. if (!string.IsNullOrWhiteSpace(names))
  7618. {
  7619. string str = "--";
  7620. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  7621. if (!string.IsNullOrEmpty(translateResult))
  7622. {
  7623. str = translateResult;
  7624. str = _airTicketResRep.Processing(str);
  7625. }
  7626. table.Range.Bookmarks["ClientName"].Text = str;
  7627. }
  7628. else
  7629. {
  7630. table.Range.Bookmarks["ClientName"].Text = "--";
  7631. }
  7632. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7633. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7634. table.Range.Bookmarks["JointTicket"].Text = "--";
  7635. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7636. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7637. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7638. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7639. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7640. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7641. }
  7642. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  7643. //保存合并后的文档
  7644. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  7645. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  7646. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  7647. return Ok(JsonView(true, "成功!", rst));
  7648. }
  7649. }
  7650. }
  7651. catch (Exception ex)
  7652. {
  7653. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  7654. throw;
  7655. }
  7656. }
  7657. #endregion
  7658. #region 团组增减款项 --> 其他款项
  7659. /// <summary>
  7660. /// 团组增减款项下拉框绑定
  7661. /// </summary>
  7662. /// <param name="dto"></param>
  7663. /// <returns></returns>
  7664. [HttpPost]
  7665. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7666. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  7667. {
  7668. #region 参数验证
  7669. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7670. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  7671. #endregion
  7672. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  7673. }
  7674. /// <summary>
  7675. /// 根据团组Id查询团组增减款项
  7676. /// </summary>
  7677. /// <param name="dto"></param>
  7678. /// <returns></returns>
  7679. [HttpPost]
  7680. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7681. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  7682. {
  7683. #region 参数验证
  7684. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7685. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7686. #endregion
  7687. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  7688. }
  7689. /// <summary>
  7690. /// 团组增减款项操作(Status:1.新增,2.修改)
  7691. /// </summary>
  7692. /// <param name="dto"></param>
  7693. /// <returns></returns>
  7694. [HttpPost]
  7695. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7696. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  7697. {
  7698. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  7699. if (groupData.Code != 200)
  7700. {
  7701. return Ok(JsonView(false, groupData.Msg));
  7702. }
  7703. #region 应用推送
  7704. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  7705. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7706. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7707. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  7708. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  7709. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  7710. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  7711. if (recheck)
  7712. {
  7713. //自动审核
  7714. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  7715. }
  7716. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7717. //2024-10-21 新增LZ UID
  7718. var userIds = new List<int>() { 21 };
  7719. string title = $"系统通知";
  7720. string content = "";
  7721. var diId = dto.DiId;
  7722. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7723. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7724. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7725. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7726. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7727. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  7728. #endregion
  7729. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7730. }
  7731. /// <summary>
  7732. /// 团组增减款项操作 删除
  7733. /// </summary>
  7734. /// <param name="dto"></param>
  7735. /// <returns></returns>
  7736. [HttpPost]
  7737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7738. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  7739. {
  7740. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  7741. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  7742. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  7743. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  7744. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  7745. }
  7746. /// <summary>
  7747. /// 根据团组增减款项Id查询
  7748. /// </summary>
  7749. /// <param name="dto"></param>
  7750. /// <returns></returns>
  7751. [HttpPost]
  7752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7753. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  7754. {
  7755. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  7756. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  7757. }
  7758. /// <summary>
  7759. /// 查询供应商名称
  7760. /// </summary>
  7761. /// <param name="dto"></param>
  7762. /// <returns></returns>
  7763. [HttpPost]
  7764. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  7765. {
  7766. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  7767. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  7768. ?? new List<Grp_DecreasePayments>();
  7769. dbResult = dbResult.Distinct(new
  7770. ProductComparer()).ToList();
  7771. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  7772. {
  7773. x.Id,
  7774. x.SupplierAddress,
  7775. x.SupplierArea,
  7776. x.SupplierContact,
  7777. x.SupplierContactNumber,
  7778. x.SupplierEmail,
  7779. x.SupplierName,
  7780. x.SupplierSocialAccount,
  7781. x.SupplierTypeId,
  7782. }).ToList());
  7783. return Ok(jw);
  7784. }
  7785. /// <summary>
  7786. /// 团组增减款项 OTA匹配
  7787. /// </summary>
  7788. /// <param name="file"></param>
  7789. /// <returns></returns>
  7790. [HttpPost]
  7791. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  7792. {
  7793. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  7794. string fileName = file.FileName;
  7795. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  7796. {
  7797. return Ok(JsonView(false, "请上传Excel文件!"));
  7798. }
  7799. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  7800. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  7801. if (!Directory.Exists(path))
  7802. {
  7803. Directory.CreateDirectory(path);
  7804. }
  7805. var filePath = @$"{path}/{fileName}";
  7806. //保存文件
  7807. using (FileStream fs = System.IO.File.Create(filePath))
  7808. {
  7809. file.CopyTo(fs);
  7810. fs.Flush();
  7811. }
  7812. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  7813. //读取ExcelFile
  7814. DataTable dt = ConvertExcelToDataTable(filePath);
  7815. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  7816. dt.TableName = "TB";
  7817. //修改table列名
  7818. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  7819. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  7820. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  7821. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  7822. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  7823. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  7824. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  7825. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  7826. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  7827. dt.Columns[9].ColumnName = "Quantity"; // 台数
  7828. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  7829. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  7830. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  7831. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  7832. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  7833. var otaOrderNos = new List<string>();
  7834. foreach (DataRow item in dt.Rows)
  7835. {
  7836. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  7837. }
  7838. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  7839. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  7840. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  7841. .Select((dp, di) => new
  7842. {
  7843. dp.PriceName,
  7844. dp.OTAOrderNo,
  7845. dp.FeeTotal,
  7846. di.TeamName,
  7847. })
  7848. .ToListAsync();
  7849. foreach (DataRow item in dt.Rows)
  7850. {
  7851. var otaOrderNo = item["OTAOrderNo"].ToString();
  7852. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  7853. if (oaData == null) continue;
  7854. item["GroupName"] = oaData.TeamName;
  7855. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  7856. }
  7857. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  7858. var pairs = new Dictionary<string, object>();
  7859. var datas = new List<DataTable>
  7860. {
  7861. dt
  7862. };
  7863. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  7864. return Ok(JsonView(true, "操作成功", new { url }));
  7865. }
  7866. #region
  7867. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  7868. {
  7869. // 创建Workbook对象
  7870. var workbook = new Workbook(excelFilePath);
  7871. // 获取第一个工作表
  7872. var worksheet = workbook.Worksheets[0];
  7873. // 将工作表转换为DataTable
  7874. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  7875. return dataTable;
  7876. }
  7877. #endregion
  7878. /// <summary>
  7879. /// 世运会数据
  7880. /// </summary>
  7881. /// <returns></returns>
  7882. [HttpGet]
  7883. public IActionResult WorldGamesData()
  7884. {
  7885. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  7886. var groupMenu = setData.GroupBy(x => x.T0);
  7887. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  7888. foreach (var item in groupMenu)
  7889. {
  7890. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  7891. {
  7892. Data = new SetDataView
  7893. {
  7894. Name = item.Key
  7895. },
  7896. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  7897. });
  7898. }
  7899. return Ok(JsonView(true, "success", resultArr));
  7900. }
  7901. #endregion
  7902. #region 文件上传、删除
  7903. /// <summary>
  7904. /// region 文件上传 可以带参数
  7905. /// </summary>
  7906. /// <param name="file"></param>
  7907. /// <returns></returns>
  7908. [HttpPost]
  7909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7910. public async Task<IActionResult> UploadProject(IFormFile file)
  7911. {
  7912. //var TypeName = Request.Headers["TypeName"].ToString();
  7913. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  7914. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7915. ////文件名称
  7916. //string projectFileName = file.FileName;
  7917. ////上传的文件的路径
  7918. //string filePath = $"{fileDir}/{projectFileName}";
  7919. //if (TypeName == "A")//A代表团组增减款项
  7920. //{
  7921. // filePath = fileDir + $@"\团组增减款项相关文件";
  7922. // if (!Directory.Exists(filePath))
  7923. // {
  7924. // Directory.CreateDirectory(filePath);
  7925. // }
  7926. // //上传的文件的路径
  7927. // filePath += $@"\{projectFileName}";
  7928. //}
  7929. //else if (TypeName == "B")//B代表商邀相关文件
  7930. //{
  7931. // //上传的文件的路径
  7932. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  7933. // if (!Directory.Exists(filePath))
  7934. // {
  7935. // Directory.CreateDirectory(filePath);
  7936. // }
  7937. // //上传的文件的路径
  7938. // filePath = $@"\{projectFileName}";
  7939. //}
  7940. //try
  7941. //{
  7942. // using (FileStream fs = System.IO.File.Create(filePath))
  7943. // {
  7944. // file.CopyTo(fs);
  7945. // fs.Flush();
  7946. // }
  7947. //}
  7948. //catch (Exception ex)
  7949. //{
  7950. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  7951. //}
  7952. //return Ok(JsonView(true, "上传成功!", projectFileName));
  7953. try
  7954. {
  7955. var TypeName = Request.Headers["TypeName"].ToString();
  7956. if (file != null)
  7957. {
  7958. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7959. //文件名称
  7960. string projectFileName = file.FileName;
  7961. //上传的文件的路径
  7962. string filePath = $"{fileDir}/{projectFileName}";
  7963. if (TypeName == "A")//A代表团组增减款项
  7964. {
  7965. if (!Directory.Exists(fileDir))
  7966. {
  7967. Directory.CreateDirectory(fileDir);
  7968. }
  7969. //上传的文件的路径
  7970. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  7971. }
  7972. else if (TypeName == "B")//B代表商邀相关文件
  7973. {
  7974. if (!Directory.Exists(fileDir))
  7975. {
  7976. Directory.CreateDirectory(fileDir);
  7977. }
  7978. //上传的文件的路径
  7979. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  7980. }
  7981. using (FileStream fs = System.IO.File.Create(filePath))
  7982. {
  7983. file.CopyTo(fs);
  7984. fs.Flush();
  7985. }
  7986. return Ok(JsonView(true, "上传成功!", projectFileName));
  7987. }
  7988. else
  7989. {
  7990. return Ok(JsonView(false, "上传失败!"));
  7991. }
  7992. }
  7993. catch (Exception ex)
  7994. {
  7995. return Ok(JsonView(false, ex.Message));
  7996. }
  7997. }
  7998. /// <summary>
  7999. /// 删除指定文件
  8000. /// </summary>
  8001. /// <param name="dto"></param>
  8002. /// <returns></returns>
  8003. [HttpPost]
  8004. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8005. public async Task<IActionResult> DelFile(DelFileDto dto)
  8006. {
  8007. try
  8008. {
  8009. var TypeName = Request.Headers["TypeName"].ToString();
  8010. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  8011. string filePath = "";
  8012. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  8013. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  8014. int id = 0;
  8015. if (TypeName == "A")
  8016. {
  8017. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  8018. // 删除该文件
  8019. System.IO.File.Delete(filePath);
  8020. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  8021. .Where(a => a.Id == dto.Id)
  8022. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  8023. .ExecuteCommandAsync();
  8024. }
  8025. else if (TypeName == "B")
  8026. {
  8027. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  8028. // 删除该文件
  8029. System.IO.File.Delete(filePath);
  8030. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  8031. if (info != null)
  8032. {
  8033. string[] files = Array.Empty<string>();
  8034. if (!string.IsNullOrEmpty(info.Attachment))
  8035. {
  8036. try
  8037. {
  8038. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  8039. }
  8040. catch (Exception)
  8041. {
  8042. files = new List<string>() { info.Attachment }.ToArray();
  8043. }
  8044. }
  8045. if (files.Length > 0)
  8046. {
  8047. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  8048. string filePath2 = string.Empty;
  8049. if (files1.Length > 0)
  8050. {
  8051. filePath2 = JsonConvert.SerializeObject(files1);
  8052. }
  8053. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  8054. .Where(a => a.Id == dto.Id)
  8055. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  8056. .ExecuteCommandAsync();
  8057. }
  8058. }
  8059. }
  8060. if (id != 0)
  8061. {
  8062. return Ok(JsonView(true, "成功!"));
  8063. }
  8064. else
  8065. {
  8066. return Ok(JsonView(false, "失败!"));
  8067. }
  8068. }
  8069. catch (Exception ex)
  8070. {
  8071. return Ok(JsonView(false, "程序错误!"));
  8072. throw;
  8073. }
  8074. }
  8075. /// <summary>
  8076. /// 文件上传多个文件 可以带参数
  8077. /// </summary>
  8078. /// <param name="files"></param>
  8079. /// <returns></returns>
  8080. [HttpPost]
  8081. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8082. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  8083. {
  8084. try
  8085. {
  8086. var TypeName = Request.Headers["TypeName"].ToString();
  8087. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  8088. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  8089. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  8090. var filePahts = new List<string>();
  8091. foreach (var file in files)
  8092. {
  8093. //文件名称
  8094. string projectFileName = file.FileName;
  8095. //上传的文件的路径
  8096. string filePath = $"{fileDir}/{projectFileName}";
  8097. if (TypeName == "A")//A代表团组增减款项
  8098. {
  8099. if (!Directory.Exists(fileDir))
  8100. {
  8101. Directory.CreateDirectory(fileDir);
  8102. }
  8103. //上传的文件的路径
  8104. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  8105. }
  8106. else if (TypeName == "B")//B代表商邀相关文件
  8107. {
  8108. if (!Directory.Exists(fileDir))
  8109. {
  8110. Directory.CreateDirectory(fileDir);
  8111. }
  8112. //上传的文件的路径
  8113. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  8114. }
  8115. using (FileStream fs = System.IO.File.Create(filePath))
  8116. {
  8117. file.CopyTo(fs);
  8118. fs.Flush();
  8119. }
  8120. filePahts.Add(projectFileName);
  8121. }
  8122. return Ok(JsonView(true, "上传成功!", filePahts));
  8123. }
  8124. catch (Exception ex)
  8125. {
  8126. return Ok(JsonView(false, ex.Message));
  8127. }
  8128. }
  8129. #endregion
  8130. #region 商邀费用录入
  8131. /// <summary>
  8132. /// 根据团组Id查询商邀费用列表
  8133. /// </summary>
  8134. /// <param name="dto"></param>
  8135. /// <returns></returns>
  8136. [HttpPost]
  8137. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8138. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  8139. {
  8140. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  8141. if (groupData.Code != 0)
  8142. {
  8143. return Ok(JsonView(false, groupData.Msg));
  8144. }
  8145. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8146. }
  8147. /// <summary>
  8148. /// 商邀费用列表
  8149. /// 下载文件
  8150. /// </summary>
  8151. /// <param name="id"></param>
  8152. /// <returns></returns>
  8153. [HttpGet("{id}")]
  8154. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8155. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  8156. {
  8157. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  8158. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  8159. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  8160. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  8161. var filePaths = new List<string>();
  8162. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  8163. try
  8164. {
  8165. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  8166. }
  8167. catch (Exception ex)
  8168. {
  8169. filePaths.Add(info.Attachment);
  8170. }
  8171. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  8172. for (int i = 0; i < filePaths.Count; i++)
  8173. {
  8174. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  8175. }
  8176. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  8177. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  8178. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  8179. {
  8180. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  8181. {
  8182. foreach (string filePath in filePaths)
  8183. {
  8184. if (System.IO.File.Exists(filePath))
  8185. {
  8186. // 获取文件名
  8187. string fileName = Path.GetFileName(filePath);
  8188. // 将文件添加到ZIP归档中
  8189. zipArchive.CreateEntryFromFile(filePath, fileName);
  8190. }
  8191. }
  8192. }
  8193. }
  8194. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  8195. }
  8196. /// <summary>
  8197. /// 商邀费用 Info Page 基础数据源
  8198. /// </summary>
  8199. /// <returns></returns>
  8200. [HttpPost]
  8201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8202. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  8203. {
  8204. try
  8205. {
  8206. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  8207. if (groupData.Code != 0)
  8208. {
  8209. return Ok(JsonView(false, groupData.Msg));
  8210. }
  8211. return Ok(JsonView(true, "操作成功", groupData.Data));
  8212. }
  8213. catch (Exception ex)
  8214. {
  8215. return Ok(JsonView(false, ex.Message));
  8216. throw;
  8217. }
  8218. }
  8219. /// <summary>
  8220. /// 根据商邀费用ID查询C表和商邀费用数据
  8221. /// </summary>
  8222. /// <param name="dto"></param>
  8223. /// <returns></returns>
  8224. [HttpPost]
  8225. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8226. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  8227. {
  8228. try
  8229. {
  8230. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  8231. if (groupData.Code != 0)
  8232. {
  8233. return Ok(JsonView(false, groupData.Msg));
  8234. }
  8235. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8236. }
  8237. catch (Exception ex)
  8238. {
  8239. return Ok(JsonView(false, ex.Message));
  8240. throw;
  8241. }
  8242. }
  8243. /// <summary>
  8244. /// 商邀费用录入操作(Status:1.新增,2.修改)
  8245. /// </summary>
  8246. /// <param name="dto"></param>
  8247. /// <returns></returns>
  8248. [HttpPost]
  8249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8250. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  8251. {
  8252. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  8253. if (groupData.Code != 0)
  8254. {
  8255. return Ok(JsonView(false, groupData.Msg));
  8256. }
  8257. #region 应用推送
  8258. try
  8259. {
  8260. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  8261. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  8262. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8263. //2024-10-21 新增LZ UID
  8264. var userIds = new List<int>() { 21 };
  8265. string title = $"系统通知";
  8266. string content = "";
  8267. var diId = dto.DiId;
  8268. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  8269. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  8270. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8271. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8272. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  8273. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  8274. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  8275. }
  8276. catch (Exception ex)
  8277. {
  8278. }
  8279. #endregion
  8280. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8281. }
  8282. /// <summary>
  8283. /// 商邀删除
  8284. /// </summary>
  8285. /// <param name="dto"></param>
  8286. /// <returns></returns>
  8287. [HttpPost]
  8288. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8289. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  8290. {
  8291. try
  8292. {
  8293. _sqlSugar.BeginTran();
  8294. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  8295. .SetColumns(it => new Grp_InvitationOfficialActivities()
  8296. {
  8297. IsDel = 1,
  8298. DeleteUserId = dto.DeleteUserId,
  8299. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8300. })
  8301. .Where(it => it.Id == dto.Id)
  8302. .ExecuteCommand();
  8303. if (res1 > 0)
  8304. {
  8305. int _diId = 0;
  8306. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  8307. if (_ioaInfo != null)
  8308. {
  8309. _diId = _ioaInfo.DiId;
  8310. }
  8311. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  8312. .SetColumns(a => new Grp_CreditCardPayment()
  8313. {
  8314. IsDel = 1,
  8315. DeleteUserId = dto.DeleteUserId,
  8316. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8317. })
  8318. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  8319. .ExecuteCommand();
  8320. if (res2 > 0)
  8321. {
  8322. _sqlSugar.CommitTran();
  8323. return Ok(JsonView(true, "删除成功!"));
  8324. }
  8325. }
  8326. _sqlSugar.RollbackTran();
  8327. return Ok(JsonView(false, "删除失败"));
  8328. }
  8329. catch (Exception ex)
  8330. {
  8331. _sqlSugar.RollbackTran();
  8332. return Ok(JsonView(false, ex.Message));
  8333. }
  8334. }
  8335. #endregion
  8336. #region 票据上传
  8337. /// <summary>
  8338. /// 团组模块文件上传
  8339. /// </summary>
  8340. /// <param name="dto"></param>
  8341. /// <returns></returns>
  8342. [HttpPost]
  8343. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  8344. {
  8345. var jw = JsonView(false);
  8346. long M = 1024 * 1024;
  8347. if (dto.Files == null || dto.Files.Count == 0)
  8348. {
  8349. jw.Msg = "无文件信息!";
  8350. return Ok(jw);
  8351. }
  8352. if (dto.Files.Sum(x => x.Length) > 20 * M)
  8353. {
  8354. jw.Msg = "文件大小超过20M!";
  8355. return Ok(jw);
  8356. }
  8357. //var nameSp = dto.File.FileName.Split(".");
  8358. //if (nameSp.Length < 2)
  8359. //{
  8360. // jw.Msg = "拓展名称有误!";
  8361. // return Ok(jw);
  8362. //}
  8363. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  8364. //if (!existsName.Contains(nameSp[1].ToUpper()))
  8365. //{
  8366. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  8367. // return Ok(jw);
  8368. //}
  8369. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  8370. if (Ctable == null)
  8371. {
  8372. jw.Msg = "Ctable指向有误!";
  8373. return Ok(jw);
  8374. }
  8375. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  8376. if (groupInfo == null)
  8377. {
  8378. jw.Msg = "团组信息不存在!";
  8379. return Ok(jw);
  8380. }
  8381. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  8382. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8383. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  8384. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8385. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  8386. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  8387. try
  8388. {
  8389. if (!Directory.Exists(fileBase))
  8390. {
  8391. Directory.CreateDirectory(fileBase);
  8392. }
  8393. var saveArr = new List<Grp_GroupModelFile>();
  8394. foreach (var fileStream in dto.Files)
  8395. {
  8396. var fileName = fileStream.FileName;
  8397. string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
  8398. string extension = Path.GetExtension(fileName);
  8399. int counter = 0;
  8400. //文件重命名验证
  8401. string newFilePath;
  8402. string currFileName;
  8403. do
  8404. {
  8405. string newFileName;
  8406. if (counter == 0) newFileName = $"{fileNameWithoutExtension}{extension}";
  8407. else newFileName = $"{fileNameWithoutExtension} ({counter}){extension}";
  8408. currFileName = newFileName;
  8409. newFilePath = Path.Combine(fileBase, newFileName);
  8410. counter++;
  8411. } while (System.IO.File.Exists(newFilePath));
  8412. var saveFilePath = fileBase + "\\" + currFileName;
  8413. var file = new Grp_GroupModelFile()
  8414. {
  8415. Cid = dto.Cid,
  8416. CreateTime = DateTime.Now,
  8417. CreateUserId = dto.Userid,
  8418. Ctable = dto.Ctable,
  8419. Diid = dto.Diid,
  8420. IsDel = 0,
  8421. FilePath = saveFilePath,
  8422. FileName = currFileName
  8423. };
  8424. using (FileStream fs = System.IO.File.Create(saveFilePath))
  8425. {
  8426. fileStream.CopyTo(fs);
  8427. fs.Flush();
  8428. }
  8429. saveArr.Add(file);
  8430. }
  8431. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  8432. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  8433. jw = JsonView(true, "保存成功!", new
  8434. {
  8435. count = addResult,
  8436. filesName = saveArr.Select(x => x.FileName)
  8437. });
  8438. }
  8439. catch (Exception ex)
  8440. {
  8441. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  8442. {
  8443. count = 0,
  8444. filesName = Array.Empty<string>(),
  8445. });
  8446. }
  8447. return Ok(jw);
  8448. }
  8449. /// <summary>
  8450. /// 查询各模块已保存文件
  8451. /// </summary>
  8452. /// <param name="dto"></param>
  8453. /// <returns></returns>
  8454. [HttpPost]
  8455. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  8456. {
  8457. var expression = Expressionable.Create<Grp_GroupModelFile>()
  8458. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  8459. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  8460. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  8461. {
  8462. expression = Expressionable.Create<Grp_GroupModelFile>()
  8463. .And(x => visaIds.Contains(x.CreateUserId));
  8464. }
  8465. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  8466. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  8467. .Where(expression.ToExpression())
  8468. .ToList();
  8469. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  8470. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  8471. {
  8472. x.FileName,
  8473. x.Id,
  8474. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  8475. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  8476. })));
  8477. }
  8478. /// <summary>
  8479. /// 下载该团组下的所有文件
  8480. /// </summary>
  8481. /// <param name="dto"></param>
  8482. /// <returns></returns>
  8483. [HttpPost]
  8484. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  8485. {
  8486. var jw = JsonView(false);
  8487. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  8488. if (groupInfo == null)
  8489. {
  8490. jw.Msg = "团组信息不存在!";
  8491. return Ok(jw);
  8492. }
  8493. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  8494. var isModule = Convert.ToBoolean(dto.isModule);
  8495. var Zips = new Dictionary<string, Stream>();
  8496. var io = new IOOperatorHelper();
  8497. if (isModule)
  8498. {
  8499. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  8500. foreach (var moduleArr in moduleGroup)
  8501. {
  8502. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  8503. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  8504. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8505. var chiZips = new Dictionary<string, Stream>();
  8506. foreach (var item in moduleArr)
  8507. {
  8508. if (System.IO.File.Exists(item.FilePath))
  8509. {
  8510. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  8511. {
  8512. byte[] bytes = new byte[fileStream.Length];
  8513. fileStream.Read(bytes, 0, bytes.Length);
  8514. fileStream.Close();
  8515. Stream stream = new MemoryStream(bytes);
  8516. chiZips.Add(item.FileName, stream);
  8517. }
  8518. }
  8519. }
  8520. if (chiZips.Count > 0)
  8521. {
  8522. var byts = io.ConvertZipStream(chiZips);
  8523. Stream stream = new MemoryStream(byts);
  8524. Zips.Add(key.Name + "_.zip", stream);
  8525. }
  8526. }
  8527. }
  8528. else
  8529. {
  8530. foreach (var item in dbQuery)
  8531. {
  8532. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  8533. {
  8534. byte[] bytes = new byte[fileStream.Length];
  8535. fileStream.Read(bytes, 0, bytes.Length);
  8536. fileStream.Close();
  8537. var stream = new MemoryStream(bytes);
  8538. while (Zips.ContainsKey(item.FileName))
  8539. {
  8540. item.FileName = new Random().Next(100) + "_" + item.FileName;
  8541. }
  8542. Zips.Add(item.FileName, stream);
  8543. }
  8544. }
  8545. }
  8546. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  8547. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8548. if (Zips.Count > 0)
  8549. {
  8550. var byts = io.ConvertZipStream(Zips);
  8551. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  8552. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  8553. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  8554. }
  8555. else
  8556. {
  8557. jw.Msg = "暂无生成文件!";
  8558. }
  8559. return Ok(jw);
  8560. }
  8561. /// <summary>
  8562. /// 下载该团组下此模块的所有文件
  8563. /// </summary>
  8564. /// <param name="dto"></param>
  8565. /// <returns></returns>
  8566. [HttpPost]
  8567. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  8568. {
  8569. var jw = JsonView(false);
  8570. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  8571. if (groupInfo == null)
  8572. {
  8573. jw.Msg = "团组信息不存在!";
  8574. return Ok(jw);
  8575. }
  8576. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  8577. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  8578. && x.IsDel == 0);
  8579. if (key == null)
  8580. {
  8581. jw.Msg = "Ctable指向错误!";
  8582. return Ok(jw);
  8583. }
  8584. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  8585. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8586. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  8587. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8588. var io = new IOOperatorHelper();
  8589. var Zips = new Dictionary<string, Stream>();
  8590. foreach (var item in dbQuery)
  8591. {
  8592. if (System.IO.File.Exists(item.FilePath))
  8593. {
  8594. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  8595. {
  8596. byte[] bytes = new byte[fileStream.Length];
  8597. fileStream.Read(bytes, 0, bytes.Length);
  8598. fileStream.Close();
  8599. var stream = new MemoryStream(bytes);
  8600. while (Zips.ContainsKey(item.FileName))
  8601. {
  8602. item.FileName = new Random().Next(100) + "_" + item.FileName;
  8603. }
  8604. Zips.Add(item.FileName, stream);
  8605. }
  8606. }
  8607. }
  8608. if (Zips.Count > 0)
  8609. {
  8610. var byts = io.ConvertZipStream(Zips);
  8611. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  8612. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  8613. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  8614. }
  8615. else
  8616. {
  8617. jw.Msg = "暂无生成文件!";
  8618. }
  8619. return Ok(jw);
  8620. }
  8621. /// <summary>
  8622. /// 删除该团组下的指定文件
  8623. /// </summary>
  8624. /// <param name="dto"></param>
  8625. /// <returns></returns>
  8626. [HttpPost]
  8627. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  8628. {
  8629. var jw = JsonView(false);
  8630. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  8631. if (sing == null)
  8632. {
  8633. jw.Msg = "暂无";
  8634. return Ok(jw);
  8635. }
  8636. if (System.IO.File.Exists(sing.FilePath))
  8637. {
  8638. try
  8639. {
  8640. System.IO.File.Delete(sing.FilePath);
  8641. }
  8642. catch (Exception ex)
  8643. {
  8644. jw.Msg = "删除失败!" + ex.Message;
  8645. return Ok(jw);
  8646. }
  8647. }
  8648. sing.IsDel = 1;
  8649. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  8650. sing.DeleteUserId = dto.UserId;
  8651. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  8652. jw = JsonView(true, "删除成功!");
  8653. return Ok(jw);
  8654. }
  8655. #endregion
  8656. #region 共享文件上传
  8657. /// <summary>
  8658. /// 超支通知推送
  8659. /// </summary>
  8660. /// <param name="dto"></param>
  8661. /// <returns></returns>
  8662. [HttpPost]
  8663. public async Task<IActionResult> qyWeChatNotification(qyWeChatNotificationDto dto)
  8664. {
  8665. //81 邀请/公务活动
  8666. var syCTable = new List<int> { 81 };
  8667. //76 酒店预订
  8668. //79 车/导游地接
  8669. //85 机票预订
  8670. var gjCTable = new List<int> { 76, 79, 85 };
  8671. var jw = JsonView(false);
  8672. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  8673. if (di == null)
  8674. {
  8675. jw.Msg = "团组信息不存在!";
  8676. return Ok(jw);
  8677. }
  8678. var user = _sqlSugar.Queryable<Sys_Users>().First(x => x.IsDel == 0 && x.Id == dto.UserId);
  8679. if (user == null)
  8680. {
  8681. jw.Msg = "用户信息不存在!";
  8682. return Ok(jw);
  8683. }
  8684. if (syCTable.Contains(dto.CTable))
  8685. {
  8686. await AppNoticeLibrary.SendChatMsg_ExpenseOverrunsChat(dto.Diid, dto.UserId, dto.CTable, QiyeWeChatEnum.ExpenseOverrunsChat02);
  8687. }
  8688. else if (gjCTable.Contains(dto.CTable))
  8689. {
  8690. await AppNoticeLibrary.SendChatMsg_ExpenseOverrunsChat(dto.Diid, dto.UserId, dto.CTable, QiyeWeChatEnum.ExpenseOverrunsChat01);
  8691. }
  8692. else
  8693. {
  8694. jw.Msg = "CTABLE类型有误!";
  8695. }
  8696. jw = JsonView(true, "推送成功!", "");
  8697. return Ok(jw);
  8698. }
  8699. /// <summary>
  8700. /// 共享文件数据初始化
  8701. /// </summary>
  8702. /// <returns></returns>
  8703. [HttpGet]
  8704. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  8705. {
  8706. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  8707. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  8708. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  8709. .Select(x => x.Id)
  8710. .ToList()
  8711. .Contains(userid);
  8712. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  8713. .Where(x => x.STid == 111 && x.IsDel == 0)
  8714. .Select(x => new
  8715. {
  8716. x.Name,
  8717. x.Id,
  8718. }).ToList();
  8719. if (isMarketingDepartment)
  8720. {
  8721. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  8722. }
  8723. if (portType == 1)
  8724. {
  8725. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  8726. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  8727. .Where(x => x.IsDel == 0)
  8728. .OrderByDescending(x => x.VisitDate)
  8729. .Select(x => new
  8730. {
  8731. x.TeamName,
  8732. x.Id,
  8733. x.CityId,
  8734. })
  8735. .ToList()
  8736. .Select(x =>
  8737. {
  8738. var provinceId = x.CityId;
  8739. var isDefualtVal = true;
  8740. if (provinceId > 0)
  8741. {
  8742. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  8743. if (parentId != null)
  8744. {
  8745. isDefualtVal = false;
  8746. provinceId = (int)parentId;
  8747. }
  8748. }
  8749. if (isDefualtVal)
  8750. {
  8751. provinceId = 122; //默认四川
  8752. }
  8753. return new
  8754. {
  8755. x.TeamName,
  8756. x.Id,
  8757. provinceId,
  8758. };
  8759. })
  8760. .ToList();
  8761. return Ok(JsonView(true, "SUCCESS!", new
  8762. {
  8763. dropDownType,
  8764. dropDownGroupList,
  8765. isMarketingDepartment
  8766. }));
  8767. }
  8768. else if (portType == 2 || portType == 3)
  8769. {
  8770. return Ok(JsonView(true, "SUCCESS!", new
  8771. {
  8772. dropDownType,
  8773. isMarketingDepartment
  8774. }));
  8775. }
  8776. else
  8777. {
  8778. return Ok(JsonView(false, "portType有误!"));
  8779. }
  8780. }
  8781. /// <summary>
  8782. /// 共享文件上传
  8783. /// </summary>
  8784. /// <param name="dto"></param>
  8785. /// <returns></returns>
  8786. [HttpPost]
  8787. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  8788. {
  8789. var isGroup = new List<int> { 1412 };
  8790. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  8791. {
  8792. return Ok(JsonView(false, "该文件需要关联团组!"));
  8793. }
  8794. if (dto.Files == null || dto.Files.Count == 0)
  8795. {
  8796. return Ok(JsonView(false, "无文件信息!"));
  8797. }
  8798. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  8799. {
  8800. return Ok(JsonView(false, "文件大小超过20M!"));
  8801. }
  8802. if (dto.Userid < 1)
  8803. {
  8804. return Ok(JsonView(false, "请传入有效的Userid!"));
  8805. }
  8806. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  8807. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  8808. .Select((u, j) => new
  8809. {
  8810. u.CnName,
  8811. UserId = u.Id,
  8812. j.JobName,
  8813. })
  8814. .First();
  8815. if (jobInfo == null)
  8816. {
  8817. return Ok(JsonView(false, "请传入有效的Userid!"));
  8818. }
  8819. var commonFileExtensions = new List<string>
  8820. {
  8821. // 文本文件
  8822. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  8823. // 图片文件
  8824. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  8825. // 视频文件
  8826. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  8827. // 音频文件
  8828. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  8829. // 压缩文件
  8830. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  8831. // 数据文件
  8832. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  8833. };
  8834. try
  8835. {
  8836. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  8837. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  8838. commonFileExtensions.AddRange(settingExtend);
  8839. }
  8840. catch (Exception)
  8841. { }
  8842. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  8843. if (setdata == null)
  8844. {
  8845. return Ok(JsonView(false, "请传入有效的FileType!"));
  8846. }
  8847. var insertList = new List<Grp_GroupShareFile>();
  8848. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  8849. if (!Directory.Exists(winPath))
  8850. {
  8851. Directory.CreateDirectory(winPath);
  8852. }
  8853. foreach (var item in dto.Files)
  8854. {
  8855. var houzui = Path.GetExtension(item.FileName);
  8856. if (!commonFileExtensions.Contains(houzui))
  8857. {
  8858. return Ok(JsonView(false, "未知后缀名称!"));
  8859. }
  8860. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  8861. var saveFilePath = winPath + fileName;
  8862. using (FileStream fs = System.IO.File.Create(saveFilePath))
  8863. {
  8864. item.CopyTo(fs);
  8865. fs.Flush();
  8866. }
  8867. var fileDetail = new Grp_GroupShareFile()
  8868. {
  8869. CreateUserId = dto.Userid,
  8870. CreateTime = DateTime.Now,
  8871. UploadJob = jobInfo.JobName,
  8872. FileName = fileName,
  8873. FileType = dto.FileType,
  8874. Diid = dto.Diid,
  8875. FilePath = winPath + fileName,
  8876. };
  8877. insertList.Add(fileDetail);
  8878. }
  8879. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  8880. return Ok(JsonView(true, "保存成功!"));
  8881. }
  8882. /// <summary>
  8883. /// 查询共享文件列表
  8884. /// </summary>
  8885. /// <param name="dto"></param>
  8886. /// <returns></returns>
  8887. [HttpPost]
  8888. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  8889. {
  8890. var isGroup = new List<int> { 1412 };
  8891. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  8892. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  8893. .And(x => x.Diid == dto.Diid)
  8894. .And(x => x.FileType == dto.FileType)
  8895. .And(x => x.IsDel == 0)
  8896. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  8897. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  8898. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  8899. int totalCount = 0;
  8900. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  8901. .Where(queryExpression.ToExpression())
  8902. .OrderBy(x => x.UploadJob)
  8903. .Select(x => new
  8904. {
  8905. x.Id,
  8906. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  8907. x.FileName,
  8908. x.FileType,
  8909. x.CreateTime,
  8910. })
  8911. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  8912. return Ok(JsonView(true, "SUCCESS!", new
  8913. {
  8914. FileList = dbQuery,
  8915. dto.PageSize,
  8916. dto.PageIndex,
  8917. totalCount
  8918. }));
  8919. }
  8920. /// <summary>
  8921. /// 删除共享文件模块下的指定文件
  8922. /// </summary>
  8923. /// <param name="dto"></param>
  8924. /// <returns></returns>
  8925. [HttpPost]
  8926. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  8927. {
  8928. var jw = JsonView(false);
  8929. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  8930. if (sing == null)
  8931. {
  8932. jw.Msg = "暂无文件信息!";
  8933. return Ok(jw);
  8934. }
  8935. if (sing.CreateUserId != dto.UserId)
  8936. {
  8937. jw.Msg = "只能删除自己上传的文件!";
  8938. return Ok(jw);
  8939. }
  8940. if (System.IO.File.Exists(sing.FilePath))
  8941. {
  8942. try
  8943. {
  8944. System.IO.File.Delete(sing.FilePath);
  8945. }
  8946. catch (Exception ex)
  8947. {
  8948. jw.Msg = "删除失败!" + ex.Message;
  8949. return Ok(jw);
  8950. }
  8951. }
  8952. sing.IsDel = 1;
  8953. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  8954. sing.DeleteUserId = dto.UserId;
  8955. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  8956. jw = JsonView(true, "删除成功!");
  8957. return Ok(jw);
  8958. }
  8959. #endregion
  8960. #region 团组英文资料
  8961. /// <summary>
  8962. /// 查询团组英文所有资料
  8963. /// </summary>
  8964. /// <param name="dto"></param>
  8965. /// <returns></returns>
  8966. [HttpPost]
  8967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8968. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  8969. {
  8970. try
  8971. {
  8972. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  8973. if (groupData.Code != 0)
  8974. {
  8975. return Ok(JsonView(false, groupData.Msg));
  8976. }
  8977. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8978. }
  8979. catch (Exception ex)
  8980. {
  8981. return Ok(JsonView(false, ex.Message));
  8982. throw;
  8983. }
  8984. }
  8985. /// <summary>
  8986. /// 团组英文资料操作(Status:1.新增,2.修改)
  8987. /// </summary>
  8988. /// <param name="dto"></param>
  8989. /// <returns></returns>
  8990. [HttpPost]
  8991. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8992. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  8993. {
  8994. try
  8995. {
  8996. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  8997. if (groupData.Code != 0)
  8998. {
  8999. return Ok(JsonView(false, groupData.Msg));
  9000. }
  9001. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9002. }
  9003. catch (Exception ex)
  9004. {
  9005. return Ok(JsonView(false, ex.Message));
  9006. throw;
  9007. }
  9008. }
  9009. /// <summary>
  9010. /// 团组英文资料Id查询数据
  9011. /// </summary>
  9012. /// <param name="dto"></param>
  9013. /// <returns></returns>
  9014. [HttpPost]
  9015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9016. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  9017. {
  9018. try
  9019. {
  9020. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  9021. if (_DelegationEnData != null)
  9022. {
  9023. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  9024. }
  9025. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  9026. }
  9027. catch (Exception ex)
  9028. {
  9029. return Ok(JsonView(false, "程序错误!"));
  9030. throw;
  9031. }
  9032. }
  9033. /// <summary>
  9034. /// 团组英文资料删除
  9035. /// </summary>
  9036. /// <param name="dto"></param>
  9037. /// <returns></returns>
  9038. [HttpPost]
  9039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9040. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  9041. {
  9042. try
  9043. {
  9044. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  9045. if (!res)
  9046. {
  9047. return Ok(JsonView(false, "删除失败"));
  9048. }
  9049. return Ok(JsonView(true, "删除成功!"));
  9050. }
  9051. catch (Exception ex)
  9052. {
  9053. return Ok(JsonView(false, ex.Message));
  9054. throw;
  9055. }
  9056. }
  9057. #endregion
  9058. #region 导出邀请函
  9059. /// <summary>
  9060. /// 导出邀请函页面初始化
  9061. /// </summary>
  9062. /// <param name="dto"></param>
  9063. /// <returns></returns>
  9064. [HttpPost]
  9065. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9066. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  9067. {
  9068. try
  9069. {
  9070. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  9071. var crm_Deles = new List<Crm_DeleClient>();
  9072. if (dto.DiId == 0)
  9073. {
  9074. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  9075. }
  9076. else
  9077. {
  9078. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  9079. }
  9080. return Ok(JsonView(true, "查询成功!", new
  9081. {
  9082. deleClient = crm_Deles,
  9083. delegations = grp_Delegations
  9084. }));
  9085. }
  9086. catch (Exception ex)
  9087. {
  9088. return Ok(JsonView(false, "程序错误!"));
  9089. throw;
  9090. }
  9091. }
  9092. /// <summary>
  9093. /// 导出邀请函
  9094. /// </summary>
  9095. /// <param name="dto"></param>
  9096. /// <returns></returns>
  9097. [HttpPost]
  9098. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9099. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  9100. {
  9101. #region 参数验证
  9102. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  9103. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9104. #endregion
  9105. try
  9106. {
  9107. var transDic = new Dictionary<string, string>();
  9108. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9109. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9110. From Grp_TourClientList tcl
  9111. Left Join
  9112. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9113. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9114. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9115. From Crm_DeleClient dc
  9116. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9117. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9118. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9119. Where dc.IsDel = 0) temp
  9120. On temp.DcId =tcl.ClientId
  9121. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  9122. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  9123. var texts = new List<string>();
  9124. if (datas.Count != 0)
  9125. {
  9126. foreach (TourClientListDetailsView item in datas)
  9127. {
  9128. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  9129. {
  9130. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  9131. }
  9132. else
  9133. {
  9134. string name = item.LastName + item.FirstName;
  9135. texts.Add(name);
  9136. }
  9137. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  9138. {
  9139. if (!transDic.ContainsKey(item.Job))
  9140. {
  9141. texts.Add(item.Job);
  9142. }
  9143. }
  9144. if (!string.IsNullOrEmpty(item.CompanyFullName))
  9145. {
  9146. texts.Add(item.CompanyFullName);
  9147. }
  9148. }
  9149. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  9150. if (transData.Count > 0)
  9151. {
  9152. foreach (TranslateResult item in transData)
  9153. {
  9154. if (!transDic.ContainsKey(item.Query))
  9155. {
  9156. transDic.Add(item.Query, item.Translation);
  9157. }
  9158. }
  9159. }
  9160. var list = new List<GuestList>();
  9161. foreach (var dele in datas)
  9162. {
  9163. var guestList = new GuestList();
  9164. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  9165. {
  9166. guestList.Name = dele.Pinyin;
  9167. }
  9168. else
  9169. {
  9170. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  9171. guestList.Name = Name;
  9172. }
  9173. if (dele.Sex == 0)
  9174. {
  9175. guestList.Sex = "Male";
  9176. }
  9177. else if (dele.Sex == 1)
  9178. {
  9179. guestList.Sex = "Female";
  9180. }
  9181. guestList.DOB = dele.BirthDay.Replace('-', '.');
  9182. if (!string.IsNullOrEmpty(dele.Job))
  9183. {
  9184. guestList.Job = dele.Job;
  9185. }
  9186. list.Add(guestList);
  9187. }
  9188. //载入模板
  9189. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  9190. var builder = new DocumentBuilder(doc);
  9191. //获取word里所有表格
  9192. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9193. //获取所填表格的序数
  9194. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9195. var rowStart = tableOne.Rows[0]; //获取第1行
  9196. //循环赋值
  9197. for (int i = 0; i < list.Count; i++)
  9198. {
  9199. builder.MoveToCell(0, i + 1, 0, 0);
  9200. builder.Write(list[i].Name.ToString());
  9201. builder.MoveToCell(0, i + 1, 1, 0);
  9202. builder.Write(list[i].Sex.ToString());
  9203. builder.MoveToCell(0, i + 1, 2, 0);
  9204. builder.Write(list[i].DOB.ToString());
  9205. builder.MoveToCell(0, i + 1, 3, 0);
  9206. builder.Write(list[i].Job.ToString());
  9207. }
  9208. //删除多余行
  9209. while (tableOne.Rows.Count > list.Count + 1)
  9210. {
  9211. tableOne.Rows.RemoveAt(list.Count + 1);
  9212. }
  9213. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9214. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  9215. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  9216. doc.Save(filePath);
  9217. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  9218. return Ok(JsonView(true, "操作成功!", Url));
  9219. }
  9220. else
  9221. {
  9222. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  9223. }
  9224. }
  9225. catch (Exception ex)
  9226. {
  9227. return Ok(JsonView(false, ex.Message));
  9228. throw;
  9229. }
  9230. }
  9231. #endregion
  9232. #region 团组经理模块 出入境费用
  9233. /// <summary>
  9234. /// 团组模块 - 出入境费用 - 省份基础数据源
  9235. /// </summary>
  9236. /// <returns></returns>
  9237. [HttpGet]
  9238. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9239. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  9240. {
  9241. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  9242. }
  9243. /// <summary>
  9244. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  9245. /// </summary>
  9246. /// <param name="dto"></param>
  9247. /// <returns></returns>
  9248. [HttpPost]
  9249. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9250. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  9251. {
  9252. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  9253. var groupNamFirst = groupNameData.FirstOrDefault();
  9254. //SetDataInfoView
  9255. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  9256. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  9257. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  9258. //验证城市归属并给默认值
  9259. int provinceId = 122;
  9260. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  9261. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  9262. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  9263. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9264. return Ok(JsonView(true, "查询成功!", new
  9265. {
  9266. GroupNameData = groupNameData,
  9267. CurrencyData = _CurrencyData,
  9268. WordTypeData = wordTypeData,
  9269. ExcelTypeData = excelTypeData,
  9270. CurrencyInit = _currencyInfos,
  9271. ViewPermissionData = viewPermissionData
  9272. }));
  9273. }
  9274. /// <summary>
  9275. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  9276. /// </summary>
  9277. /// <returns></returns>
  9278. [HttpGet("{provinceId}")]
  9279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9280. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  9281. {
  9282. //验证城市归属并给默认值
  9283. if (provinceId < 1) provinceId = 122;
  9284. /*
  9285. * 122 四川
  9286. * 108 贵州
  9287. * 103 重庆
  9288. * 132 云南
  9289. */
  9290. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  9291. return Ok(JsonView(true, "查询成功!", new
  9292. {
  9293. WordTypeData = wordTypeData,
  9294. ExcelTypeData = excelTypeData,
  9295. }));
  9296. }
  9297. /// <summary>
  9298. /// 团组模块 - 出入境费用
  9299. /// 实时汇率 tips
  9300. /// 签证费用 tips
  9301. /// 机票费用 tips
  9302. /// </summary>
  9303. /// <returns></returns>
  9304. [HttpPost]
  9305. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9306. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  9307. {
  9308. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  9309. //默认币种显示
  9310. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  9311. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  9312. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  9313. return Ok(JsonView(true, "查询成功!", new
  9314. {
  9315. //GroupNameData = groupNameData.Data,
  9316. visaData = visaData.Data,
  9317. airData,
  9318. reteInfos
  9319. }));
  9320. }
  9321. /// <summary>
  9322. /// 团组模块 - 出入境费用 - Info
  9323. /// </summary>
  9324. /// <param name="dto"></param>
  9325. /// <returns></returns>
  9326. [HttpPost]
  9327. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  9328. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9329. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  9330. {
  9331. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9332. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9333. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  9334. }
  9335. /// <summary>
  9336. /// 团组模块 - 出入境费用 - 设置view权限
  9337. /// </summary>
  9338. /// <returns></returns>
  9339. [HttpPost]
  9340. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9341. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  9342. {
  9343. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9344. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9345. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9346. var permissions = new List<Grp_EnterExitCostPermission>();
  9347. foreach (var userId in dto.UserIds)
  9348. {
  9349. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  9350. }
  9351. if (permissions.Any())
  9352. {
  9353. _sqlSugar.BeginTran();
  9354. try
  9355. {
  9356. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  9357. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9358. if (result < 1)
  9359. {
  9360. _sqlSugar.RollbackTran();
  9361. return Ok(JsonView(false));
  9362. }
  9363. }
  9364. catch (Exception ex)
  9365. {
  9366. _sqlSugar.RollbackTran();
  9367. return Ok(JsonView(false, ex.Message));
  9368. }
  9369. _sqlSugar.CommitTran();
  9370. return Ok(JsonView(true));
  9371. }
  9372. return Ok(JsonView(false));
  9373. }
  9374. /// <summary>
  9375. /// 团组模块 - 出入境费用 - Add And Update
  9376. /// </summary>
  9377. /// <returns></returns>
  9378. [HttpPost]
  9379. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  9380. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9381. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  9382. {
  9383. try
  9384. {
  9385. var rateRecords = new List<RateRecordInfo>();
  9386. #region 汇率保存前存储
  9387. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  9388. if (info != null)
  9389. {
  9390. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  9391. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  9392. {
  9393. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  9394. {
  9395. CurrencyCode = x.CurrencyCode,
  9396. CurrencyName = x.CurrencyName,
  9397. UpdatePreRate = x.Rate,
  9398. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  9399. }).ToList();
  9400. }
  9401. else
  9402. {
  9403. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  9404. {
  9405. CurrencyCode = x.CurrencyCode,
  9406. CurrencyName = x.CurrencyName,
  9407. UpdatePreRate = 0.00M,
  9408. UpdateBreRate = x.Rate
  9409. }).ToList();
  9410. }
  9411. }
  9412. else
  9413. {
  9414. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  9415. {
  9416. CurrencyCode = x.CurrencyCode,
  9417. CurrencyName = x.CurrencyName,
  9418. UpdatePreRate = 0.00M,
  9419. UpdateBreRate = x.Rate
  9420. }).ToList();
  9421. }
  9422. #endregion
  9423. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  9424. if (dto.DayOtherPriceData.Any())
  9425. {
  9426. var inserList = dto.DayOtherPriceData
  9427. .Where(x => x.Id == 0)
  9428. .Select(x => new Grp_DayOtherPrice
  9429. {
  9430. Cost = x.Cost,
  9431. Id = x.Id,
  9432. CreateTime = DateTime.Now,
  9433. CreateUserId = dto.UserId,
  9434. Currency = x.Currency,
  9435. Diid = x.DiId,
  9436. Index = x.Index,
  9437. IsDel = 0,
  9438. SetDataId = x.SetDataId,
  9439. SubTotal = x.SubTotal,
  9440. Remark = x.Remark
  9441. })
  9442. .ToList();
  9443. var updateList = dto.DayOtherPriceData
  9444. .Where(x => x.Id != 0)
  9445. .Select(x => new Grp_DayOtherPrice
  9446. {
  9447. Cost = x.Cost,
  9448. Id = x.Id,
  9449. CreateTime = DateTime.Now,
  9450. CreateUserId = dto.UserId,
  9451. Currency = x.Currency,
  9452. Diid = x.DiId,
  9453. Index = x.Index,
  9454. IsDel = 0,
  9455. SetDataId = x.SetDataId,
  9456. SubTotal = x.SubTotal,
  9457. Remark = x.Remark
  9458. })
  9459. .ToList();
  9460. //添加
  9461. _sqlSugar.BeginTran();
  9462. if (inserList.Any())
  9463. {
  9464. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  9465. }
  9466. if (updateList.Any())
  9467. {
  9468. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  9469. }
  9470. _sqlSugar.CommitTran();
  9471. }
  9472. if (data.Code != 0)
  9473. {
  9474. return Ok(JsonView(false, data.Msg));
  9475. }
  9476. //生成默认文件pdf并且通知人员
  9477. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9478. {
  9479. DiId = dto.DiId,
  9480. ExportType = 1,
  9481. SubTypeId = 1005
  9482. }, "pdf");
  9483. //发送通知
  9484. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9485. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9486. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  9487. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  9488. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9489. //汇率信息记录
  9490. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  9491. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  9492. //汇率验证、反推
  9493. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  9494. if (isSendMsg)
  9495. {
  9496. //消息推送
  9497. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  9498. }
  9499. #region 日志汇率记录
  9500. //按照已使用币种记录
  9501. if (checkCurrencys != null && checkCurrencys.Count > 0)
  9502. {
  9503. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  9504. //汇率记录中加入实时汇率
  9505. if (liveRates != null && liveRates.Count > 0)
  9506. {
  9507. foreach (var item in rateRecords)
  9508. {
  9509. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  9510. }
  9511. }
  9512. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  9513. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  9514. var logContent = new StringBuilder();
  9515. foreach (var item in rateRecords)
  9516. {
  9517. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  9518. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  9519. logContent.AppendLine(msg);
  9520. }
  9521. _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());
  9522. }
  9523. #endregion
  9524. return Ok(JsonView(true, data.Msg, data.Data));
  9525. }
  9526. catch (Exception ex)
  9527. {
  9528. return Ok(JsonView(false, ex.Message));
  9529. }
  9530. }
  9531. /// <summary>
  9532. /// 团组模块 - 出入境费用 - Confirm 费用
  9533. /// </summary>
  9534. /// <returns></returns>
  9535. [HttpPost]
  9536. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9537. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  9538. {
  9539. //TODO:测试完毕需把对应的用户ID更改
  9540. //1、数据表添加字段
  9541. //2、更改字段接口()
  9542. var _view = await _enterExitCostRep.ConfirmCost(dto);
  9543. //3、确认成功 给财务发送消息
  9544. if (_view.Code == 200)
  9545. {
  9546. if (dto.Type == 1)
  9547. {
  9548. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  9549. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  9550. }
  9551. }
  9552. return Ok(_view);
  9553. }
  9554. /// <summary>
  9555. /// 团组模块 - 出入境费用 - File download
  9556. /// </summary>
  9557. /// <param name="dto"></param>
  9558. /// <returns></returns>
  9559. [HttpPost]
  9560. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  9561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9562. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  9563. {
  9564. try
  9565. {
  9566. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  9567. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  9568. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  9569. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  9570. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  9571. 3 团组成员名单 1 团组成员名单", ""));
  9572. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  9573. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9574. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  9575. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  9576. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  9577. //数据源
  9578. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  9579. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  9580. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  9581. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  9582. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9583. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  9584. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  9585. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  9586. .Select((x, a, b) => new
  9587. {
  9588. x.Index,
  9589. itemName = a.Name,
  9590. CurrencyStr = b.Name,
  9591. x.Cost,
  9592. x.SubTotal,
  9593. x.Remark
  9594. })
  9595. .OrderBy((x) => x.Index)
  9596. .ToList(); //其他款项费用
  9597. var peiceItemCurrencys = new List<string>();
  9598. if (_DayAndCosts.Any())
  9599. {
  9600. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  9601. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  9602. }
  9603. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  9604. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  9605. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  9606. {
  9607. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  9608. }
  9609. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9610. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  9611. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  9612. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  9613. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  9614. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  9615. .Select((tcl, dc, cc) => new ClientInfo
  9616. {
  9617. LastName = dc.LastName,
  9618. FirstName = dc.FirstName,
  9619. Sex = dc.Sex,
  9620. Birthday = dc.BirthDay,
  9621. Company = cc.CompanyFullName,
  9622. Job = dc.Job
  9623. })
  9624. .ToList();
  9625. foreach (var item in DeleClientList)
  9626. {
  9627. EncryptionProcessor.DecryptProperties(item);
  9628. }
  9629. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  9630. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  9631. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  9632. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  9633. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  9634. if (dto.ExportType == 1) //明细表
  9635. {
  9636. if (dto.SubTypeId == 1005) //1005(默认明细表)
  9637. {
  9638. //获取模板
  9639. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  9640. //载入模板
  9641. var doc = new Document(tempPath);
  9642. var builder = new DocumentBuilder(doc);
  9643. var dic = new Dictionary<string, string>();
  9644. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  9645. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  9646. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  9647. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  9648. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  9649. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  9650. //境内费用(其他费用)
  9651. if (_EnterExitCosts.ChoiceOne == 1)
  9652. {
  9653. string row1_1 = "";
  9654. if (_EnterExitCosts.Visa > 0)
  9655. {
  9656. //insidePayTotal += _EnterExitCosts.Visa;
  9657. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  9658. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  9659. //{
  9660. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  9661. //}
  9662. }
  9663. string row1_2 = "";
  9664. if (_EnterExitCosts.YiMiao > 0)
  9665. {
  9666. //insidePayTotal += _EnterExitCosts.YiMiao;
  9667. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  9668. }
  9669. if (_EnterExitCosts.HeSuan > 0)
  9670. {
  9671. //insidePayTotal += _EnterExitCosts.HeSuan;
  9672. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  9673. }
  9674. if (_EnterExitCosts.Service > 0)
  9675. {
  9676. //insidePayTotal += _EnterExitCosts.Service;
  9677. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  9678. }
  9679. string row1_3 = "";
  9680. if (_EnterExitCosts.Safe > 0)
  9681. {
  9682. //insidePayTotal += _EnterExitCosts.Safe;
  9683. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  9684. }
  9685. if (_EnterExitCosts.Ticket > 0)
  9686. {
  9687. //insidePayTotal += _EnterExitCosts.Ticket;
  9688. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  9689. }
  9690. string row1 = "";
  9691. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  9692. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  9693. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  9694. row1 += $"备注:{_EnterExitCosts.Remark}";
  9695. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  9696. dic.Add("Row1Str", row1);
  9697. }
  9698. var airTotalStr = new StringBuilder();
  9699. var airPriceStr = new StringBuilder();
  9700. var cityTrafficLabel = new StringBuilder();
  9701. //经济舱
  9702. if (_EnterExitCosts.SumJJC == 1)
  9703. {
  9704. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)");
  9705. airPriceStr.AppendFormat($"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)");
  9706. cityTrafficLabel.AppendFormat("经济舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic);
  9707. }
  9708. //公务舱
  9709. if (_EnterExitCosts.SumGWC == 1)
  9710. {
  9711. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)");
  9712. airPriceStr.AppendFormat($"{_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)");
  9713. cityTrafficLabel.AppendFormat("公务舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic1);
  9714. }
  9715. //头等舱
  9716. if (_EnterExitCosts.SumTDC == 1)
  9717. {
  9718. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)");
  9719. airPriceStr.AppendFormat($"{_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)");
  9720. cityTrafficLabel.AppendFormat("头等舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic2);
  9721. }
  9722. //描述
  9723. var remarkLable = new StringBuilder();
  9724. //第二项描述
  9725. remarkLable.Append("备注:");
  9726. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) remarkLable.AppendFormat(_EnterExitCosts.TwoItemRemark);
  9727. //汇率描述
  9728. if (peiceItemCurrencyInfos.Any())
  9729. {
  9730. remarkLable.AppendLine();
  9731. remarkLable.AppendFormat("汇率描述:");
  9732. foreach (var item in peiceItemCurrencyInfos)
  9733. {
  9734. remarkLable.AppendFormat($"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ");
  9735. }
  9736. }
  9737. dic.Add("AirTotalStr", airTotalStr.ToString());
  9738. dic.Add("AirPriceStr", airPriceStr.ToString());
  9739. dic.Add("CityTranffic", cityTrafficLabel.ToString());
  9740. dic.Add("TwoItemRemark", remarkLable.ToString());
  9741. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9742. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9743. int table1Row = 0,
  9744. table2Row = 0,
  9745. table3Row = 0,
  9746. table4Row = 0,
  9747. table5Row = 0;
  9748. //住宿费
  9749. if (_EnterExitCosts.ChoiceThree == 1)
  9750. {
  9751. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  9752. table1Row = dac1.Count;
  9753. #region 填充word表格内容
  9754. for (int i = 0; i < dac1.Count; i++)
  9755. {
  9756. Grp_DayAndCost dac = dac1[i];
  9757. if (dac == null) continue;
  9758. builder.MoveToCell(0, i, 0, 0);
  9759. builder.Write("第" + dac.Days.ToString() + "晚:");
  9760. builder.MoveToCell(0, i, 1, 0);
  9761. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  9762. //builder.Write(dac.Place == null ? "" : dac.Place);
  9763. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9764. builder.MoveToCell(0, i, 2, 0);
  9765. builder.Write("费用标准:");
  9766. string curr = "";
  9767. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9768. if (currData != null)
  9769. {
  9770. curr = currData.Name;
  9771. }
  9772. builder.MoveToCell(0, i, 3, 0);
  9773. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9774. builder.MoveToCell(0, i, 4, 0);
  9775. builder.Write("费用小计:");
  9776. builder.MoveToCell(0, i, 5, 0);
  9777. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9778. }
  9779. #endregion
  9780. }
  9781. else dic.Add("SubZS", "0.00");
  9782. //删除多余行
  9783. while (table1.Rows.Count > table1Row)
  9784. {
  9785. table1.Rows.RemoveAt(table1Row);
  9786. }
  9787. //伙食费
  9788. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  9789. if (_EnterExitCosts.ChoiceFour == 1)
  9790. {
  9791. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  9792. table2Row = dac2.Count;
  9793. #region 填充word表格内容
  9794. for (int i = 0; i < dac2.Count; i++)
  9795. {
  9796. Grp_DayAndCost dac = dac2[i];
  9797. if (dac == null) continue;
  9798. builder.MoveToCell(1, i, 0, 0);
  9799. builder.Write("第" + dac.Days.ToString() + "天:");
  9800. builder.MoveToCell(1, i, 1, 0);
  9801. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9802. builder.MoveToCell(1, i, 2, 0);
  9803. builder.Write("费用标准:");
  9804. string curr = "";
  9805. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9806. if (currData != null)
  9807. {
  9808. curr = currData.Name;
  9809. }
  9810. builder.MoveToCell(1, i, 3, 0);
  9811. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9812. builder.MoveToCell(1, i, 4, 0);
  9813. builder.Write("费用小计:");
  9814. builder.MoveToCell(1, i, 5, 0);
  9815. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9816. }
  9817. #endregion
  9818. }
  9819. else dic.Add("SubHS", "0.00");
  9820. //删除多余行
  9821. while (table2.Rows.Count > table2Row)
  9822. {
  9823. table2.Rows.RemoveAt(table2Row);
  9824. }
  9825. //公杂费
  9826. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  9827. if (_EnterExitCosts.ChoiceFive == 1)
  9828. {
  9829. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  9830. table3Row = dac3.Count;
  9831. #region 填充word表格内容
  9832. for (int i = 0; i < dac3.Count; i++)
  9833. {
  9834. Grp_DayAndCost dac = dac3[i];
  9835. if (dac == null) continue;
  9836. builder.MoveToCell(2, i, 0, 0);
  9837. builder.Write("第" + dac.Days.ToString() + "天:");
  9838. builder.MoveToCell(2, i, 1, 0);
  9839. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9840. builder.MoveToCell(2, i, 2, 0);
  9841. builder.Write("费用标准:");
  9842. string curr = "";
  9843. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9844. if (currData != null)
  9845. {
  9846. curr = currData.Name;
  9847. }
  9848. builder.MoveToCell(2, i, 3, 0);
  9849. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9850. builder.MoveToCell(2, i, 4, 0);
  9851. builder.Write("费用小计:");
  9852. builder.MoveToCell(2, i, 5, 0);
  9853. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9854. }
  9855. //删除多余行
  9856. while (table3.Rows.Count > table3Row)
  9857. {
  9858. table3.Rows.RemoveAt(table3Row);
  9859. }
  9860. #endregion
  9861. }
  9862. else dic.Add("SubGZF", "0.00");
  9863. //删除多余行
  9864. while (table3.Rows.Count > table3Row)
  9865. {
  9866. table3.Rows.RemoveAt(table3Row);
  9867. }
  9868. //培训费
  9869. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  9870. if (_EnterExitCosts.ChoiceSix == 1)
  9871. {
  9872. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  9873. dic.Add("SubPX", pxStr);
  9874. table4Row = dac4.Count;
  9875. #region 填充word表格内容
  9876. for (int i = 0; i < dac4.Count; i++)
  9877. {
  9878. Grp_DayAndCost dac = dac4[i];
  9879. if (dac == null) continue;
  9880. builder.MoveToCell(3, i, 0, 0);
  9881. builder.Write("第" + dac.Days.ToString() + "天:");
  9882. builder.MoveToCell(3, i, 1, 0);
  9883. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9884. builder.MoveToCell(3, i, 2, 0);
  9885. builder.Write("费用标准:");
  9886. string curr = "";
  9887. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9888. if (currData != null)
  9889. {
  9890. curr = currData.Name;
  9891. }
  9892. builder.MoveToCell(3, i, 3, 0);
  9893. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9894. builder.MoveToCell(3, i, 4, 0);
  9895. builder.Write("费用小计:");
  9896. builder.MoveToCell(3, i, 5, 0);
  9897. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9898. }
  9899. #endregion
  9900. }
  9901. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  9902. //删除多余行
  9903. while (table4.Rows.Count > table4Row)
  9904. {
  9905. table4.Rows.RemoveAt(table4Row);
  9906. }
  9907. //其他费用
  9908. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  9909. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  9910. {
  9911. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  9912. dic.Add("titleQi", qtStr);
  9913. table5Row = dac5.Count;
  9914. #region 填充word表格内容
  9915. for (int i = 0; i < dac5.Count; i++)
  9916. {
  9917. var dac = dac5[i];
  9918. if (dac == null) continue;
  9919. builder.MoveToCell(4, i, 0, 0);
  9920. builder.Write("第" + dac.Index.ToString() + "项:");
  9921. builder.MoveToCell(4, i, 1, 0);
  9922. builder.Write(dac.itemName);
  9923. builder.MoveToCell(4, i, 2, 0);
  9924. builder.Write("费用标准:");
  9925. builder.MoveToCell(4, i, 3, 0);
  9926. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  9927. builder.MoveToCell(4, i, 4, 0);
  9928. builder.Write("费用小计:");
  9929. builder.MoveToCell(4, i, 5, 0);
  9930. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9931. builder.MoveToCell(4, i, 6, 0);
  9932. builder.Write("备注:");
  9933. builder.MoveToCell(4, i, 7, 0);
  9934. builder.Write(dac.Remark);
  9935. }
  9936. #endregion
  9937. }
  9938. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  9939. //删除多余行
  9940. while (table5.Rows.Count > table5Row)
  9941. {
  9942. table5.Rows.RemoveAt(table5Row);
  9943. }
  9944. //加上其他费用
  9945. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  9946. decimal subJJC = 0.00M,
  9947. subGWC = 0.00M,
  9948. subTDC = 0.00M;
  9949. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  9950. string totalLabel = string.Format("全部费用总计:");
  9951. //经济舱
  9952. if (_EnterExitCosts.SumJJC == 1)
  9953. {
  9954. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9955. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  9956. }
  9957. //公务舱
  9958. if (_EnterExitCosts.SumGWC == 1)
  9959. {
  9960. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9961. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  9962. }
  9963. //头等舱
  9964. if (_EnterExitCosts.SumTDC == 1)
  9965. {
  9966. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9967. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  9968. }
  9969. //TotalLabel
  9970. dic.Add("TotalLabel", totalLabel);
  9971. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  9972. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  9973. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  9974. #region 填充word模板书签内容
  9975. foreach (var key in dic.Keys)
  9976. {
  9977. Bookmark bookmark = doc.Range.Bookmarks[key];
  9978. if (bookmark != null)
  9979. {
  9980. builder.MoveToBookmark(key);
  9981. builder.Write(dic[key]);
  9982. }
  9983. }
  9984. #endregion
  9985. #region 设置页眉
  9986. string userLabel = string.Empty;
  9987. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  9988. if (currUserInfo != null)
  9989. {
  9990. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  9991. if (userInfo != null)
  9992. {
  9993. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  9994. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  9995. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  9996. }
  9997. }
  9998. //设置页脚
  9999. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  10000. #endregion
  10001. var guid = CommonFun.GUID.Substring(0, 8);
  10002. //文件名
  10003. string strFileName = CommonFun.ValidFileName($"{_DelegationInfo.TeamName}出入境费用{guid}.docx");
  10004. AsposeHelper.removewatermark_v2180();
  10005. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10006. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10007. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10008. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10009. }
  10010. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  10011. {
  10012. //获取模板
  10013. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  10014. //载入模板
  10015. var doc = new Document(tempPath);
  10016. var builder = new DocumentBuilder(doc);
  10017. var dic = new Dictionary<string, string>();
  10018. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  10019. {
  10020. var list = new List<string>();
  10021. try
  10022. {
  10023. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  10024. foreach (var item in spilitArr)
  10025. {
  10026. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  10027. var depCode = spDotandEmpty[2].Substring(0, 3);
  10028. var arrCode = spDotandEmpty[2].Substring(3, 3);
  10029. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  10030. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  10031. list.Add(depName);
  10032. list.Add(arrName);
  10033. }
  10034. list = list.Distinct().ToList();
  10035. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  10036. }
  10037. catch (Exception)
  10038. {
  10039. dic.Add("ReturnCode", "行程录入不正确!");
  10040. }
  10041. }
  10042. else
  10043. {
  10044. dic.Add("ReturnCode", "未录入行程!");
  10045. }
  10046. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  10047. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10048. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10049. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  10050. {
  10051. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10052. dic.Add("Day", sp.Days.ToString());
  10053. }
  10054. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10055. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  10056. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  10057. //dic.Add("Names", Names);
  10058. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10059. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10060. decimal dac1totalPrice = 0.00M;
  10061. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  10062. foreach (var dac in dac1)
  10063. {
  10064. if (dac.SubTotal == 0.00M)
  10065. {
  10066. continue;
  10067. }
  10068. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  10069. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  10070. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10071. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  10072. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  10073. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  10074. builder.Write(currency);//币种
  10075. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  10076. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10077. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  10078. builder.Write("");//人数
  10079. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  10080. builder.Write("");//天数
  10081. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  10082. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10083. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  10084. decimal rate = 0.00M;
  10085. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  10086. builder.Write(rate.ToString("#0.0000"));//汇率
  10087. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10088. decimal rbmPrice = dac.SubTotal;
  10089. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10090. accommodationStartIndex++;
  10091. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  10092. }
  10093. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10094. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  10095. {
  10096. table1.Rows.RemoveAt(i - 1);
  10097. foodandotherStartIndex--;
  10098. }
  10099. if (dac2.Count == dac3.Count)//国家 币种 金额
  10100. {
  10101. for (int i = 0; i < dac2.Count; i++)
  10102. {
  10103. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10104. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10105. }
  10106. }
  10107. decimal dac2totalPrice = 0.00M;
  10108. foreach (var dac in dac2)
  10109. {
  10110. if (dac.SubTotal == 0)
  10111. {
  10112. continue;
  10113. }
  10114. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  10115. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  10116. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  10117. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  10118. builder.Write(currency);//币种
  10119. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  10120. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10121. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  10122. builder.Write("");//人数
  10123. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  10124. builder.Write("");//天数
  10125. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  10126. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10127. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  10128. decimal rate = 0.00M;
  10129. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  10130. builder.Write(rate.ToString("#0.0000"));//汇率
  10131. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  10132. decimal rbmPrice = dac.SubTotal;
  10133. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10134. foodandotherStartIndex++;
  10135. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  10136. }
  10137. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  10138. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  10139. {
  10140. table1.Rows.RemoveAt(i - 1);
  10141. }
  10142. var cityTrafficLabel = new StringBuilder()
  10143. .AppendFormat(" 经济舱:{0:#0.00} 元", _EnterExitCosts.CityTranffic)
  10144. .AppendFormat(" 公务舱:{0:#0.00} 元", _EnterExitCosts.CityTranffic1)
  10145. .AppendFormat(" 头等舱:{0:#0.00} ", _EnterExitCosts.CityTranffic2)
  10146. .ToString();
  10147. dic.Add("CityTranffic", cityTrafficLabel);
  10148. string otherFeeStr = "";
  10149. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  10150. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  10151. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  10152. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  10153. foreach (var otherInfo in dac5)
  10154. {
  10155. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  10156. }
  10157. #endregion
  10158. if (otherFeeStr.Length > 0)
  10159. {
  10160. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  10161. otherFeeStr = $"({otherFeeStr})";
  10162. dic.Add("OtherFeeStr", otherFeeStr);
  10163. }
  10164. //总计
  10165. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  10166. //国际旅费
  10167. string outsideAir = string.Empty;
  10168. string allPriceAir = string.Empty;
  10169. if (_EnterExitCosts.SumJJC == 1)
  10170. {
  10171. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10172. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  10173. }
  10174. if (_EnterExitCosts.SumGWC == 1)
  10175. {
  10176. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  10177. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10178. }
  10179. if (_EnterExitCosts.SumTDC == 1)
  10180. {
  10181. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  10182. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  10183. }
  10184. dic.Add("InTravelPrice", $"({outsideAir})");
  10185. dic.Add("FinalSumPrice", $"({allPriceAir})");
  10186. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  10187. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  10188. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  10189. foreach (var key in dic.Keys)
  10190. {
  10191. builder.MoveToBookmark(key);
  10192. builder.Write(dic[key]);
  10193. }
  10194. //模板文件名
  10195. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10196. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10197. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10198. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10199. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10200. }
  10201. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  10202. {
  10203. //获取模板
  10204. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  10205. //载入模板
  10206. var designer = new WorkbookDesigner
  10207. {
  10208. Workbook = new Workbook(tempPath)
  10209. };
  10210. var dic = new Dictionary<string, string>();
  10211. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  10212. {
  10213. var list = new List<string>();
  10214. try
  10215. {
  10216. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  10217. foreach (var item in spilitArr)
  10218. {
  10219. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  10220. var depCode = spDotandEmpty[2].Substring(0, 3);
  10221. var arrCode = spDotandEmpty[2].Substring(3, 3);
  10222. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  10223. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  10224. list.Add(depName);
  10225. list.Add(arrName);
  10226. }
  10227. list = list.Distinct().ToList();
  10228. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  10229. }
  10230. catch (Exception)
  10231. {
  10232. dic.Add("ReturnCode", "行程录入不正确!");
  10233. }
  10234. }
  10235. else
  10236. {
  10237. dic.Add("ReturnCode", "未录入行程!");
  10238. }
  10239. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  10240. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10241. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10242. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  10243. {
  10244. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10245. dic.Add("Day", sp.Days.ToString());
  10246. }
  10247. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10248. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  10249. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  10250. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  10251. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  10252. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  10253. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  10254. designer.SetDataSource("Name", Names);
  10255. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  10256. designer.SetDataSource("Day", dic["Day"] + "天");
  10257. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  10258. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  10259. int startIndex = 10;
  10260. const int startIndexcopy = 10;
  10261. if (dac2.Count == dac3.Count)//国家 币种 金额
  10262. {
  10263. for (int i = 0; i < dac2.Count; i++)
  10264. {
  10265. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10266. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10267. }
  10268. }
  10269. var dtdac1 = new DataTable();
  10270. var place = new List<string>();
  10271. dtdac1.Columns.AddRange(new DataColumn[] {
  10272. new(){ ColumnName = "city"},
  10273. new(){ ColumnName = "curr"},
  10274. new(){ ColumnName = "criterion"},
  10275. new(){ ColumnName = "number",DataType = typeof(int)},
  10276. new(){ ColumnName = "day",DataType = typeof(int)},
  10277. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  10278. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  10279. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  10280. });
  10281. var dtdac2 = new DataTable();
  10282. dtdac2.Columns.AddRange(new DataColumn[] {
  10283. new(){ ColumnName = "city"},
  10284. new(){ ColumnName = "curr"},
  10285. new(){ ColumnName = "criterion"},
  10286. new(){ ColumnName = "number",DataType = typeof(int)},
  10287. new(){ ColumnName = "day",DataType = typeof(int)},
  10288. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  10289. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  10290. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  10291. });
  10292. dtdac1.TableName = "tb1";
  10293. dtdac2.TableName = "tb2";
  10294. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  10295. foreach (var item in dac1)
  10296. {
  10297. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  10298. if (place.Contains(item.Place))
  10299. {
  10300. continue;
  10301. }
  10302. DataRow row = dtdac1.NewRow();
  10303. row["city"] = item.Place;
  10304. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10305. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10306. row["curr"] = currency;
  10307. row["rate"] = rate.ToString("#0.0000");
  10308. row["criterion"] = item.Cost.ToString("#0.00");
  10309. row["number"] = 1;
  10310. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10311. //row["costRMB"] = rbmPrice;
  10312. dtdac1.Rows.Add(row);
  10313. place.Add(item.Place);
  10314. }
  10315. place = new List<string>();
  10316. foreach (var item in dac2)
  10317. {
  10318. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  10319. if (place.Contains(item.Place))
  10320. {
  10321. continue;
  10322. }
  10323. DataRow row = dtdac2.NewRow();
  10324. row["city"] = item.Place;
  10325. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10326. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10327. row["curr"] = currency;
  10328. row["rate"] = rate.ToString("#0.0000");
  10329. row["criterion"] = item.Cost.ToString("#0.00");
  10330. row["number"] = 1;
  10331. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10332. //row["cost"] = item.SubTotal;
  10333. //row["costRMB"] = rbmPrice;
  10334. dtdac2.Rows.Add(row);
  10335. place.Add(item.Place);
  10336. //dac2totalPrice += rbmPrice;
  10337. }
  10338. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  10339. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  10340. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10341. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  10342. var cityTrafficLabel = new StringBuilder()
  10343. .AppendFormat(" 其中:国外城市间")
  10344. .AppendFormat(" 经济舱费:{0:#0.00} 元、", _EnterExitCosts.CityTranffic)
  10345. .AppendFormat(" 公务舱费:{0:#0.00} 元、", _EnterExitCosts.CityTranffic1)
  10346. .AppendFormat(" 头等舱费:{0:#0.00} 元", _EnterExitCosts.CityTranffic2)
  10347. .ToString();
  10348. //decimal cityTraffic =_EnterExitCosts.CityTranffic + _EnterExitCosts.CityTranffic1 + _EnterExitCosts.CityTranffic2;
  10349. designer.SetDataSource("cityTranffic", cityTrafficLabel);
  10350. // designer.SetDataSource("sumCityTranffic", @$"{cityTraffic:#0.00} ");
  10351. string cell4Str1 = string.Empty;
  10352. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  10353. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  10354. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  10355. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  10356. string cellStr = $" 5.其他费用(";
  10357. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  10358. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  10359. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  10360. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  10361. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  10362. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  10363. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  10364. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  10365. foreach (var otherInfo in dac5)
  10366. {
  10367. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  10368. }
  10369. #endregion
  10370. if (cellStr.Length > 8)
  10371. {
  10372. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  10373. }
  10374. cellStr += ")";
  10375. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  10376. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  10377. decimal pxFee = dac4.Sum(it => it.Cost);
  10378. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  10379. string celllastStr1 = "";
  10380. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  10381. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  10382. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  10383. celllastStr1 += $",国际旅费 元";
  10384. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  10385. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  10386. designer.SetDataSource("cell4Str", cell4Str);
  10387. designer.SetDataSource("cellStr", cellStr);
  10388. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  10389. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10390. designer.SetDataSource("celllastStr", celllastStr);
  10391. Workbook wb = designer.Workbook;
  10392. var sheet = wb.Worksheets[0];
  10393. //绑定datatable数据集
  10394. designer.SetDataSource(dtdac1);
  10395. designer.SetDataSource(dtdac2);
  10396. designer.Process();
  10397. var rowStart = dtdac1.Rows.Count;
  10398. while (rowStart > 0)
  10399. {
  10400. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  10401. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10402. startIndex++;
  10403. rowStart--;
  10404. }
  10405. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  10406. startIndex += 1; //总计行
  10407. rowStart = dtdac2.Rows.Count;
  10408. while (rowStart > 0)
  10409. {
  10410. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  10411. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10412. startIndex++;
  10413. rowStart--;
  10414. }
  10415. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  10416. wb.CalculateFormula(true);
  10417. //模板文件名
  10418. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10419. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10420. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10421. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10422. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10423. }
  10424. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  10425. {
  10426. //获取模板
  10427. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  10428. //载入模板
  10429. var doc = new Document(tempPath);
  10430. var builder = new DocumentBuilder(doc);
  10431. var dic = new Dictionary<string, string>
  10432. {
  10433. { "GroupName", _DelegationInfo.TeamName },
  10434. { "ClientUnit", _DelegationInfo.ClientUnit }
  10435. };
  10436. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  10437. string missionLeaderJob = "";//负责人job
  10438. //int groupNumber = 0; //团人数
  10439. if (DeleClientList.Count > 0)
  10440. {
  10441. missionLeader = DeleClientList[0]?.Name ?? "";
  10442. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  10443. }
  10444. dic.Add("MissionLeader", missionLeader); //团负责人
  10445. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  10446. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  10447. #region MyRegion
  10448. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  10449. //{
  10450. // List<string> list = new List<string>();
  10451. // try
  10452. // {
  10453. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  10454. // foreach (var item in spilitArr)
  10455. // {
  10456. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  10457. // var depCode = spDotandEmpty[2].Substring(0, 3);
  10458. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  10459. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  10460. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  10461. // list.Add(depName);
  10462. // list.Add(arrName);
  10463. // }
  10464. // list = list.Distinct().ToList();
  10465. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  10466. // }
  10467. // catch (Exception)
  10468. // {
  10469. // dic.Add("ReturnCode", "行程录入不正确!");
  10470. // }
  10471. //}
  10472. //else
  10473. //{
  10474. // dic.Add("ReturnCode", "未录入行程!");
  10475. //}
  10476. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  10477. dic.Add("ReturnCode", string.Join("、", countrys));
  10478. #endregion
  10479. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  10480. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10481. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10482. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  10483. //{
  10484. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10485. // dic.Add("Day", sp.Days.ToString());
  10486. //}
  10487. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  10488. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  10489. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10490. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10491. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10492. //培训人员名单
  10493. int cultivateRowIndex = 7;
  10494. foreach (var item in DeleClientList)
  10495. {
  10496. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  10497. builder.Write(item.Name);
  10498. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  10499. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  10500. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  10501. string birthDay = "";
  10502. if (item.Birthday != null)
  10503. {
  10504. DateTime dt = Convert.ToDateTime(item.Birthday);
  10505. birthDay = $"{dt.Year}.{dt.Month}";
  10506. }
  10507. builder.Write(birthDay);
  10508. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  10509. builder.Write(item.Company);
  10510. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  10511. builder.Write(item.Job);
  10512. cultivateRowIndex++;
  10513. }
  10514. //删除多余行
  10515. //cultivateRowIndex -= 2;
  10516. int delRows = 10 + 7 - cultivateRowIndex;
  10517. if (delRows > 0)
  10518. {
  10519. for (int i = 0; i < delRows; i++)
  10520. {
  10521. table1.Rows.RemoveAt(cultivateRowIndex);
  10522. //cultivateRowIndex++;
  10523. }
  10524. }
  10525. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  10526. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  10527. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  10528. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  10529. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  10530. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  10531. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  10532. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  10533. //decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  10534. decimal cityTranfficFeeToatal = 0.00M;
  10535. //dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));
  10536. //其他费用
  10537. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  10538. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  10539. //其他费用合计
  10540. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  10541. decimal _jjcFeeToatal = _EnterExitCosts.OutsideJJPay + _otherFeeTotal; //经济舱
  10542. decimal _gwcFeeToatal = _EnterExitCosts.OutsideGWPay + _otherFeeTotal; //公务舱
  10543. //公务舱合计
  10544. //国际旅费
  10545. //string outsideJJ = "";
  10546. //string allPriceJJ = "";
  10547. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  10548. {
  10549. dic.Add("AirFeeTotal", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  10550. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  10551. }
  10552. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  10553. {
  10554. dic.Add("AirFeeTotal", _EnterExitCosts.OutsideGWPay.ToString("#0.00"));
  10555. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  10556. }
  10557. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  10558. {
  10559. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.OutsideJJPay:#0.00} 公务舱:{_EnterExitCosts.OutsideGWPay:#0.00}");
  10560. dic.Add("AirFeeTotal", airFeeTotalStr);
  10561. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  10562. dic.Add("FeeTotal", feeTotalStr);
  10563. }
  10564. foreach (var key in dic.Keys)
  10565. {
  10566. builder.MoveToBookmark(key);
  10567. builder.Write(dic[key]);
  10568. }
  10569. //模板文件名
  10570. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  10571. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10572. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10573. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10574. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10575. }
  10576. }
  10577. else if (dto.ExportType == 2) //表格
  10578. {
  10579. //利用键值对存放数据
  10580. Dictionary<string, string> dic = new Dictionary<string, string>();
  10581. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10582. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10583. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10584. dic.Add("Day", sp.Days.ToString());
  10585. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10586. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  10587. {
  10588. //获取模板
  10589. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  10590. //载入模板
  10591. var doc = new Document(tempPath);
  10592. var builder = new DocumentBuilder(doc);
  10593. dic.Add("TeamName", _DelegationInfo.TeamName);
  10594. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  10595. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  10596. string missionLeaderName = "",
  10597. missionLeaderJob = "";
  10598. if (DeleClientList.Count > 0)
  10599. {
  10600. missionLeaderName = DeleClientList[0].Name;
  10601. missionLeaderJob = DeleClientList[0].Job;
  10602. }
  10603. dic.Add("MissionLeaderName", missionLeaderName);
  10604. dic.Add("MissionLeaderJob", missionLeaderJob);
  10605. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  10606. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  10607. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10608. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10609. int rowCount = 10;//总人数行
  10610. int startRowIndex = 7; //起始行
  10611. for (int i = 0; i < DeleClientList.Count; i++)
  10612. {
  10613. builder.MoveToCell(0, startRowIndex, 0, 0);
  10614. builder.Write(DeleClientList[i].Name); //出国人员姓名
  10615. builder.MoveToCell(0, startRowIndex, 1, 0);
  10616. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  10617. builder.Write(sex);//性别
  10618. builder.MoveToCell(0, startRowIndex, 2, 0);
  10619. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  10620. builder.MoveToCell(0, startRowIndex, 3, 0);
  10621. builder.Write(DeleClientList[i].Company);//工作单位
  10622. builder.MoveToCell(0, startRowIndex, 4, 0);
  10623. builder.Write(DeleClientList[i].Job);//职务及级别
  10624. builder.MoveToCell(0, startRowIndex, 5, 0);
  10625. builder.Write("");//人员属性
  10626. builder.MoveToCell(0, startRowIndex, 6, 0);
  10627. builder.Write("");//上次出国时间
  10628. startRowIndex++;
  10629. }
  10630. int nullRow = rowCount - DeleClientList.Count;//空行
  10631. for (int i = 0; i < nullRow; i++)
  10632. {
  10633. table1.Rows.Remove(table1.Rows[startRowIndex]);
  10634. }
  10635. foreach (var key in dic.Keys)
  10636. {
  10637. builder.MoveToBookmark(key);
  10638. builder.Write(dic[key]);
  10639. }
  10640. //模板文件名
  10641. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  10642. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10643. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10644. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  10645. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  10646. }
  10647. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  10648. {
  10649. //获取模板
  10650. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  10651. //载入模板
  10652. var doc = new Document(tempPath);
  10653. var builder = new DocumentBuilder(doc);
  10654. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  10655. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  10656. dic.Add("Names", Names);
  10657. int accommodationRows = 12;
  10658. //int foodandotherRows = 12;
  10659. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  10660. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  10661. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10662. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10663. int accommodationStartIndex = 6;
  10664. decimal dac1totalPrice = 0.00M;
  10665. foreach (var dac in dac1)
  10666. {
  10667. if (dac.SubTotal == 0)
  10668. {
  10669. continue;
  10670. }
  10671. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  10672. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  10673. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10674. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  10675. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  10676. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  10677. builder.Write(currency);//币种
  10678. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  10679. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10680. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  10681. builder.Write("");//人数
  10682. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  10683. builder.Write("");//天数
  10684. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  10685. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10686. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  10687. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10688. builder.Write(rate.ToString("#0.0000"));//汇率
  10689. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10690. decimal rbmPrice = rate * dac.SubTotal;
  10691. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10692. accommodationStartIndex++;
  10693. dac1totalPrice += rbmPrice;
  10694. }
  10695. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10696. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10697. builder.Write("小计");
  10698. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10699. builder.Write(dac1totalPrice.ToString("#0.00"));
  10700. accommodationStartIndex++;
  10701. int nullRow = accommodationRows - dac1.Count;
  10702. //删除空行
  10703. //if (nullRow > 0)
  10704. //{
  10705. // int rowIndex = accommodationStartIndex;
  10706. // for (int i = 0; i < nullRow; i++)
  10707. // {
  10708. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  10709. // row.Remove();
  10710. // rowIndex++;
  10711. // }
  10712. //}
  10713. if (dac2.Count == dac3.Count)//国家 币种 金额
  10714. {
  10715. for (int i = 0; i < dac2.Count; i++)
  10716. {
  10717. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10718. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10719. }
  10720. }
  10721. int foodandotherStartIndex = 19;//
  10722. decimal dac2totalPrice = 0.00M;
  10723. foreach (var dac in dac2)
  10724. {
  10725. if (dac.SubTotal == 0)
  10726. {
  10727. continue;
  10728. }
  10729. //foodandotherStartIndex = 12;
  10730. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  10731. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  10732. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  10733. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  10734. builder.Write(currency);//币种
  10735. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  10736. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10737. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  10738. builder.Write("");//人数
  10739. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  10740. builder.Write("");//天数
  10741. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  10742. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10743. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  10744. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10745. builder.Write(rate.ToString("#0.0000"));//汇率
  10746. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  10747. decimal rbmPrice = rate * dac.SubTotal;
  10748. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10749. foodandotherStartIndex++;
  10750. dac2totalPrice += rbmPrice;
  10751. }
  10752. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  10753. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  10754. //删除空行
  10755. //if (dac2.Count < foodandotherRows)
  10756. //{
  10757. // while (table2.Rows.Count > dac2.Count)
  10758. // {
  10759. // table2.Rows.RemoveAt(dac2.Count);
  10760. // }
  10761. //}
  10762. var citytrafficLable = new StringBuilder()
  10763. .AppendFormat($"经济舱费用:{_EnterExitCosts.CityTranffic:#0.00} 元、")
  10764. .AppendFormat($"公务舱费用:{_EnterExitCosts.CityTranffic1:#0.00}元、")
  10765. .AppendFormat($"头等舱费用:{_EnterExitCosts.CityTranffic2:#0.00}")
  10766. .ToString();
  10767. dic.Add("CityTranffic", citytrafficLable);
  10768. string otherFeeStr = "";
  10769. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  10770. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  10771. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  10772. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  10773. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  10774. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  10775. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  10776. foreach (var otherInfo in dac5)
  10777. {
  10778. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  10779. }
  10780. #endregion
  10781. if (otherFeeStr.Length > 0)
  10782. {
  10783. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  10784. otherFeeStr = $"({otherFeeStr})";
  10785. dic.Add("OtherFeeStr", otherFeeStr);
  10786. }
  10787. foreach (var key in dic.Keys)
  10788. {
  10789. builder.MoveToBookmark(key);
  10790. builder.Write(dic[key]);
  10791. }
  10792. //模板文件名
  10793. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10794. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10795. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10796. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10797. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10798. }
  10799. }
  10800. else if (dto.ExportType == 3)
  10801. {
  10802. if (dto.SubTypeId == 1) //团组成员名单
  10803. {
  10804. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  10805. //获取模板
  10806. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  10807. //载入模板
  10808. var doc = new Document(tempPath);
  10809. var builder = new DocumentBuilder(doc);
  10810. //获取word里所有表格
  10811. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10812. //获取所填表格的序数
  10813. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10814. var rowStart = tableOne.Rows[0]; //获取第1行
  10815. //循环赋值
  10816. for (int i = 0; i < DeleClientList.Count; i++)
  10817. {
  10818. builder.MoveToCell(0, i + 1, 0, 0);
  10819. builder.Write(DeleClientList[i].Name);
  10820. builder.MoveToCell(0, i + 1, 1, 0);
  10821. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  10822. builder.Write(sex);
  10823. builder.MoveToCell(0, i + 1, 2, 0);
  10824. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  10825. builder.MoveToCell(0, i + 1, 3, 0);
  10826. builder.Write(DeleClientList[i].Company);
  10827. builder.MoveToCell(0, i + 1, 4, 0);
  10828. builder.Write(DeleClientList[i].Job);
  10829. }
  10830. //删除多余行
  10831. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  10832. {
  10833. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  10834. }
  10835. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  10836. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  10837. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  10838. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10839. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10840. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10841. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10842. }
  10843. }
  10844. return Ok(JsonView(400, "操作失败!", ""));
  10845. }
  10846. catch (Exception ex)
  10847. {
  10848. return Ok(JsonView(400, ex.Message, ""));
  10849. }
  10850. }
  10851. /// <summary>
  10852. /// 获取三公费用标准city
  10853. /// </summary>
  10854. /// <param name="placeData"></param>
  10855. /// <param name="nationalTravelFeeId"></param>
  10856. /// <returns></returns>
  10857. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  10858. {
  10859. string _city = string.Empty;
  10860. if (placeData.Count < 1) return _city;
  10861. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  10862. if (data == null) return _city;
  10863. string country = data.Country;
  10864. string city = data.City;
  10865. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  10866. else _city = city;
  10867. return _city;
  10868. }
  10869. ///// <summary>
  10870. ///// 团组模块 - 出入境费用 - 明细表导出
  10871. ///// </summary>
  10872. ///// <returns></returns>
  10873. //[HttpPost]
  10874. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10875. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  10876. //{
  10877. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  10878. // if (data.Code != 0)
  10879. // {
  10880. // return Ok(JsonView(false, data.Msg));
  10881. // }
  10882. // return Ok(JsonView(true, data.Msg, data.Data));
  10883. //}
  10884. /// <summary>
  10885. /// 团组模块 - 出入境费用 - 一键清空
  10886. /// </summary>
  10887. /// <returns></returns>
  10888. [HttpPost]
  10889. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  10890. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10891. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  10892. {
  10893. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  10894. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  10895. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  10896. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  10897. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  10898. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  10899. .SetColumns(x => new Grp_DayOtherPrice
  10900. {
  10901. IsDel = 1,
  10902. DeleteUserId = dto.UserId,
  10903. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10904. })
  10905. .ExecuteCommandAsync();
  10906. if (_view.Code == 0)
  10907. {
  10908. return Ok(JsonView(true, "操作成功"));
  10909. }
  10910. return Ok(JsonView(false, "操作失败"));
  10911. }
  10912. /// <summary>
  10913. /// 团组模块 - 出入境费用 - 子项删除
  10914. /// </summary>
  10915. /// <returns></returns>
  10916. [HttpPost]
  10917. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  10918. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10919. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  10920. {
  10921. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10922. if (data.Code != 0)
  10923. {
  10924. return Ok(JsonView(false, data.Msg));
  10925. }
  10926. return Ok(JsonView(true, "操作成功!", data.Data));
  10927. }
  10928. /// <summary>
  10929. /// 删除三公其他费用
  10930. /// </summary>
  10931. /// <param name="dto"></param>
  10932. /// <returns></returns>
  10933. [HttpPost]
  10934. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  10935. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  10936. {
  10937. var jw = JsonView(false, "删除失败!");
  10938. var data = new Grp_DayOtherPrice()
  10939. {
  10940. Id = dto.Id,
  10941. IsDel = 1,
  10942. DeleteUserId = dto.DeleteUserId,
  10943. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10944. };
  10945. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10946. if (del > 0)
  10947. {
  10948. jw.Code = 200;
  10949. jw.Msg = "删除成功!";
  10950. }
  10951. return Ok(jw);
  10952. }
  10953. /// <summary>
  10954. /// 团组模块 - 出入境国家费用标准 List
  10955. /// </summary>
  10956. /// <returns></returns>
  10957. [HttpPost]
  10958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10959. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  10960. {
  10961. int provinceId = dto.ProvinceId;
  10962. if (provinceId < 1) provinceId = 122; //默认四川省数据
  10963. var nftData = await _sqlSugar
  10964. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  10965. JoinType.Left, ntf.Currency == sd1.Id,
  10966. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  10967. JoinType.Left, ntf.ProvinceId == c.Id
  10968. ))
  10969. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  10970. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  10971. {
  10972. Id = ntf.Id,
  10973. ProvinceId = ntf.ProvinceId,
  10974. ProvinceName = c.Name_CN,
  10975. Continent = ntf.Continent,
  10976. Country = ntf.Country,
  10977. City = ntf.City,
  10978. Currency = ntf.Currency,
  10979. CurrencyCode = sd1.Name,
  10980. CurrencyName = sd1.Remark,
  10981. RoomCost = ntf.RoomCost,
  10982. FoodCost = ntf.FoodCost,
  10983. PublicCost = ntf.PublicCost,
  10984. LastUpdateUserId = ntf.LastUpdateUserId,
  10985. LastUpdateUserName = u.CnName,
  10986. LastUpdateTime = ntf.LastUpdateTime
  10987. })
  10988. .ToListAsync();
  10989. return Ok(JsonView(true, "查询成功!", nftData));
  10990. }
  10991. /// <summary>
  10992. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  10993. /// </summary>
  10994. /// <returns></returns>
  10995. [HttpPost]
  10996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10997. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  10998. {
  10999. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  11000. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  11001. List<string> countryData = new List<string>();
  11002. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  11003. countryData = countryData.Distinct().ToList();
  11004. List<dynamic> dataSource = new List<dynamic>();
  11005. foreach (var item in countryData)
  11006. {
  11007. var cityData1 = new List<string>();
  11008. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  11009. var countryData2 = new
  11010. {
  11011. CountryName = item,
  11012. CityData = cityData1
  11013. };
  11014. if (!dataSource.Contains(countryData2))
  11015. {
  11016. dataSource.Add(countryData2);
  11017. }
  11018. }
  11019. return Ok(JsonView(true, "查询成功!", dataSource));
  11020. }
  11021. /// <summary>
  11022. /// 团组模块 - 出入境国家费用标准 Page List
  11023. /// </summary>
  11024. /// <returns></returns>
  11025. [HttpPost]
  11026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11027. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  11028. {
  11029. int portId = dto.PortType,
  11030. pageIndex = dto.PageIndex,
  11031. pageSize = dto.PageSize;
  11032. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  11033. if (pageIndex == 0) pageIndex = 1;
  11034. if (pageSize == 0) pageSize = 10;
  11035. RefAsync<int> total = 0;
  11036. var nationalTravelFeeData = await _sqlSugar
  11037. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  11038. JoinType.Left, ntf.Currency == sd1.Id,
  11039. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  11040. JoinType.Left, ntf.ProvinceId == sd2.Id
  11041. ))
  11042. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  11043. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  11044. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  11045. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  11046. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  11047. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  11048. {
  11049. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  11050. Id = ntf.Id,
  11051. ProvinceId = ntf.ProvinceId,
  11052. ProvinceName = sd2.Name_CN,
  11053. Continent = ntf.Continent,
  11054. Country = ntf.Country,
  11055. City = ntf.City,
  11056. Currency = ntf.Currency,
  11057. CurrencyCode = sd1.Name,
  11058. CurrencyName = sd1.Remark,
  11059. RoomCost = ntf.RoomCost,
  11060. FoodCost = ntf.FoodCost,
  11061. PublicCost = ntf.PublicCost,
  11062. LastUpdateUserId = ntf.LastUpdateUserId,
  11063. LastUpdateUserName = u.CnName,
  11064. LastUpdateTime = ntf.LastUpdateTime,
  11065. Remark = ntf.Remark
  11066. })
  11067. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11068. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  11069. }
  11070. /// <summary>
  11071. /// 团组模块 - 出入境国家费用标准 根据城市查询
  11072. /// </summary>
  11073. /// <returns></returns>
  11074. [HttpPost]
  11075. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11076. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  11077. {
  11078. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  11079. int portId = dto.PortType;
  11080. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  11081. string whereSql = string.Empty;
  11082. if (!string.IsNullOrEmpty(dto.Country))
  11083. {
  11084. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  11085. }
  11086. if (!string.IsNullOrEmpty(dto.City))
  11087. {
  11088. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  11089. }
  11090. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  11091. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  11092. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  11093. From Grp_NationalTravelFee gntf
  11094. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  11095. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  11096. Where gntf.Isdel = 0 {0} ", whereSql);
  11097. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  11098. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  11099. }
  11100. /// <summary>
  11101. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  11102. /// </summary>
  11103. /// <returns></returns>
  11104. [HttpPost]
  11105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11106. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  11107. {
  11108. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  11109. }
  11110. /// <summary>
  11111. /// 团组模块 - 出入境国家费用标准 - Del
  11112. /// </summary>
  11113. /// <returns></returns>
  11114. [HttpPost]
  11115. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11116. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  11117. {
  11118. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  11119. {
  11120. Id = dto.Id,
  11121. DeleteUserId = dto.DeleteUserId,
  11122. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11123. IsDel = 1
  11124. };
  11125. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  11126. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  11127. .WhereColumns(it => new { it.Id })
  11128. .ExecuteCommandAsync();
  11129. if (delStatus <= 0)
  11130. {
  11131. return Ok(JsonView(false, "删除失败!"));
  11132. }
  11133. return Ok(JsonView(true, "操作成功!"));
  11134. }
  11135. /// <summary>
  11136. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  11137. /// 注:Get 请求Headers 加 Token
  11138. /// </summary>
  11139. /// <param name="groupId"></param>
  11140. /// <returns></returns>
  11141. [HttpGet("{groupId}")]
  11142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11143. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  11144. {
  11145. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  11146. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  11147. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  11148. data.ForEach(x =>
  11149. {
  11150. x.CreateUserId = _currUserInfo.UserId;
  11151. });
  11152. if (data.Any())
  11153. {
  11154. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  11155. if (add > 0)
  11156. {
  11157. return Ok(JsonView(true, "操作成功!"));
  11158. }
  11159. }
  11160. return Ok(JsonView(false, "未操作!"));
  11161. }
  11162. #endregion
  11163. #region 团组经理模块 出入境费用-草稿
  11164. /// <summary>
  11165. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  11166. /// </summary>
  11167. /// <returns></returns>
  11168. [HttpGet]
  11169. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11170. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  11171. {
  11172. var provData = await _groupRepository.ProvinceBasicSource();
  11173. return Ok(JsonView(true, "查询成功!", provData));
  11174. }
  11175. /// <summary>
  11176. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  11177. /// </summary>
  11178. /// <returns></returns>
  11179. [HttpGet("{provinceId}")]
  11180. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11181. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  11182. {
  11183. //验证城市归属并给默认值
  11184. if (provinceId < 1) provinceId = 122;
  11185. /*
  11186. * 122 四川
  11187. * 108 贵州
  11188. * 103 重庆
  11189. * 132 云南
  11190. */
  11191. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  11192. return Ok(JsonView(true, "查询成功!", new
  11193. {
  11194. WordTypeData = wordTypeData,
  11195. ExcelTypeData = excelTypeData,
  11196. }));
  11197. }
  11198. /// <summary>
  11199. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  11200. /// </summary>
  11201. /// <returns></returns>
  11202. [HttpPost]
  11203. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11204. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  11205. {
  11206. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11207. .Where(x => x.IsDel == 0)
  11208. .OrderByDescending(x => x.CreateTime)
  11209. .Select(x => new { x.Id, x.DraftName })
  11210. .ToListAsync();
  11211. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  11212. //SetDataInfoView
  11213. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11214. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  11215. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  11216. int provinceId = dto.ProvinceId;
  11217. if (provinceId < 1) provinceId = 122;
  11218. /*
  11219. * 122 四川
  11220. * 108 贵州
  11221. * 103 重庆
  11222. * 132 云南
  11223. */
  11224. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  11225. //默认币种显示
  11226. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  11227. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11228. return Ok(JsonView(true, "查询成功!", new
  11229. {
  11230. DraftNameDatas = draftNameDatas,
  11231. CurrencyData = _CurrencyData,
  11232. WordTypeData = wordTypeData,
  11233. ExcelTypeData = excelTypeData,
  11234. CurrencyInit = _currencyInfos,
  11235. ViewPermissionData = viewPermissionData
  11236. }));
  11237. }
  11238. /// <summary>
  11239. /// 团组模块 - 出入境费用-草稿
  11240. /// 实时汇率 tips
  11241. /// 机票费用 tips
  11242. /// </summary>
  11243. /// <returns></returns>
  11244. [HttpPost]
  11245. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11246. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  11247. {
  11248. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  11249. return Ok(JsonView(true, "查询成功!", new
  11250. {
  11251. //GroupNameData = groupNameData.Data,
  11252. //visaData = visaData.Data,
  11253. //airData = airData.Data,
  11254. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  11255. }));
  11256. }
  11257. /// <summary>
  11258. /// 团组模块 - 出入境费用-草稿
  11259. /// 签证费用 tips
  11260. /// </summary>
  11261. /// <returns></returns>
  11262. [HttpPost]
  11263. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11264. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  11265. {
  11266. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  11267. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11268. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11269. .Select(x => x.NationalTravelFeeId)
  11270. .Distinct()
  11271. .ToListAsync();
  11272. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11273. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11274. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11275. .Select(x => x.Country)
  11276. .Distinct()
  11277. .ToArrayAsync();
  11278. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11279. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11280. return Ok(JsonView(true, "查询成功!", new
  11281. {
  11282. totalAmt,
  11283. remark
  11284. }));
  11285. }
  11286. /// <summary>
  11287. /// 团组模块 - 出入境费用-草稿 - Info
  11288. /// </summary>
  11289. /// <returns></returns>
  11290. [HttpPost]
  11291. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  11292. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11293. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  11294. {
  11295. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  11296. }
  11297. /// <summary>
  11298. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  11299. /// </summary>
  11300. /// <returns></returns>
  11301. [HttpPost]
  11302. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11303. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  11304. {
  11305. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11306. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  11307. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11308. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  11309. foreach (var userId in dto.UserIds)
  11310. {
  11311. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11312. }
  11313. if (permissions.Any())
  11314. {
  11315. _sqlSugar.BeginTran();
  11316. try
  11317. {
  11318. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11319. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11320. if (result < 1)
  11321. {
  11322. _sqlSugar.RollbackTran();
  11323. return Ok(JsonView(false));
  11324. }
  11325. }
  11326. catch (Exception ex)
  11327. {
  11328. _sqlSugar.RollbackTran();
  11329. return Ok(JsonView(false, ex.Message));
  11330. }
  11331. _sqlSugar.CommitTran();
  11332. return Ok(JsonView(true));
  11333. }
  11334. return Ok(JsonView(false));
  11335. }
  11336. /// <summary>
  11337. /// 团组模块 - 出入境费用-草稿 - Add And Update
  11338. /// </summary>
  11339. /// <returns></returns>
  11340. [HttpPost]
  11341. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  11342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11343. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  11344. {
  11345. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  11346. if (data.Code != 0)
  11347. {
  11348. return Ok(JsonView(false, data.Msg));
  11349. }
  11350. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  11351. //汇率信息记录
  11352. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  11353. return Ok(JsonView(true, data.Msg, data.Data));
  11354. }
  11355. /// <summary>
  11356. /// 团组模块 - 出入境费用-草稿 - File downlaod
  11357. /// </summary>
  11358. /// <param name="dto"></param>
  11359. /// <returns></returns>
  11360. [HttpPost]
  11361. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  11362. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11363. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  11364. {
  11365. try
  11366. {
  11367. var id = dto.Id;
  11368. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  11369. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  11370. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  11371. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  11372. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  11373. 3 团组成员名单 1 团组成员名单", ""));
  11374. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  11375. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  11376. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  11377. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  11378. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  11379. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  11380. //数据源
  11381. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  11382. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  11383. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  11384. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  11385. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11386. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  11387. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  11388. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  11389. .Select((x, a, b) => new
  11390. {
  11391. x.Index,
  11392. itemName = a.Name,
  11393. CurrencyStr = b.Name,
  11394. x.Cost,
  11395. x.SubTotal,
  11396. x.Remark
  11397. })
  11398. .OrderBy((x) => x.Index)
  11399. .ToList(); //其他款项费用
  11400. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  11401. var peiceItemCurrencys = new List<string>();
  11402. if (_DayAndCosts.Any())
  11403. {
  11404. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  11405. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  11406. }
  11407. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  11408. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  11409. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  11410. {
  11411. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  11412. }
  11413. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  11414. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  11415. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  11416. if (dto.ExportType == 1) //明细表
  11417. {
  11418. if (dto.SubTypeId == 1005) //1005(默认明细表)
  11419. {
  11420. //获取模板
  11421. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  11422. //载入模板
  11423. Document doc = new Document(tempPath);
  11424. DocumentBuilder builder = new DocumentBuilder(doc);
  11425. //利用键值对存放数据
  11426. Dictionary<string, string> dic = new Dictionary<string, string>();
  11427. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  11428. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  11429. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  11430. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  11431. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  11432. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  11433. //境内费用(其他费用)
  11434. if (_EnterExitCosts.ChoiceOne == 1)
  11435. {
  11436. string row1_1 = "";
  11437. if (_EnterExitCosts.Visa > 0)
  11438. {
  11439. //insidePayTotal += _EnterExitCosts.Visa;
  11440. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  11441. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  11442. //{
  11443. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  11444. //}
  11445. }
  11446. string row1_2 = "";
  11447. if (_EnterExitCosts.YiMiao > 0)
  11448. {
  11449. //insidePayTotal += _EnterExitCosts.YiMiao;
  11450. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  11451. }
  11452. if (_EnterExitCosts.HeSuan > 0)
  11453. {
  11454. //insidePayTotal += _EnterExitCosts.HeSuan;
  11455. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  11456. }
  11457. if (_EnterExitCosts.Service > 0)
  11458. {
  11459. //insidePayTotal += _EnterExitCosts.Service;
  11460. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  11461. }
  11462. string row1_3 = "";
  11463. if (_EnterExitCosts.Safe > 0)
  11464. {
  11465. //insidePayTotal += _EnterExitCosts.Safe;
  11466. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  11467. }
  11468. if (_EnterExitCosts.Ticket > 0)
  11469. {
  11470. //insidePayTotal += _EnterExitCosts.Ticket;
  11471. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  11472. }
  11473. string row1 = "";
  11474. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  11475. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  11476. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  11477. row1 += $"备注:{_EnterExitCosts.Remark}";
  11478. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  11479. dic.Add("Row1Str", row1);
  11480. }
  11481. string airTotalStr = string.Empty,
  11482. airPriceStr = string.Empty;
  11483. //经济舱
  11484. if (_EnterExitCosts.SumJJC == 1)
  11485. {
  11486. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  11487. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  11488. }
  11489. //公务舱
  11490. if (_EnterExitCosts.SumGWC == 1)
  11491. {
  11492. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  11493. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  11494. }
  11495. //头等舱
  11496. if (_EnterExitCosts.SumTDC == 1)
  11497. {
  11498. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  11499. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  11500. }
  11501. //汇率描述
  11502. string rateStr = "";
  11503. if (peiceItemCurrencyInfos.Any())
  11504. {
  11505. rateStr = "\r\n汇率描述:";
  11506. foreach (var item in peiceItemCurrencyInfos)
  11507. {
  11508. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  11509. }
  11510. }
  11511. string twoItemRemark = "备注:";
  11512. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  11513. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  11514. dic.Add("AirTotalStr", airTotalStr);
  11515. dic.Add("AirPriceStr", airPriceStr);
  11516. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  11517. dic.Add("TwoItemRemark", twoItemRemark);
  11518. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11519. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  11520. int table1Row = 0,
  11521. table2Row = 0,
  11522. table3Row = 0,
  11523. table4Row = 0,
  11524. table5Row = 0;
  11525. //住宿费
  11526. if (_EnterExitCosts.ChoiceThree == 1)
  11527. {
  11528. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  11529. table1Row = dac1.Count;
  11530. #region 填充word表格内容
  11531. for (int i = 0; i < dac1.Count; i++)
  11532. {
  11533. var dac = dac1[i];
  11534. if (dac == null) continue;
  11535. builder.MoveToCell(0, i, 0, 0);
  11536. builder.Write("第" + dac.Days.ToString() + "晚:");
  11537. builder.MoveToCell(0, i, 1, 0);
  11538. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  11539. //builder.Write(dac.Place == null ? "" : dac.Place);
  11540. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11541. builder.MoveToCell(0, i, 2, 0);
  11542. builder.Write("费用标准:");
  11543. string curr = "";
  11544. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11545. if (currData != null)
  11546. {
  11547. curr = currData.Name;
  11548. }
  11549. builder.MoveToCell(0, i, 3, 0);
  11550. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11551. builder.MoveToCell(0, i, 4, 0);
  11552. builder.Write("费用小计:");
  11553. builder.MoveToCell(0, i, 5, 0);
  11554. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11555. }
  11556. #endregion
  11557. }
  11558. else dic.Add("SubZS", "0.00");
  11559. //删除多余行
  11560. while (table1.Rows.Count > table1Row)
  11561. {
  11562. table1.Rows.RemoveAt(table1Row);
  11563. }
  11564. //伙食费
  11565. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  11566. if (_EnterExitCosts.ChoiceFour == 1)
  11567. {
  11568. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  11569. table2Row = dac2.Count;
  11570. #region 填充word表格内容
  11571. for (int i = 0; i < dac2.Count; i++)
  11572. {
  11573. var dac = dac2[i];
  11574. if (dac == null) continue;
  11575. builder.MoveToCell(1, i, 0, 0);
  11576. builder.Write("第" + dac.Days.ToString() + "天:");
  11577. builder.MoveToCell(1, i, 1, 0);
  11578. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11579. builder.MoveToCell(1, i, 2, 0);
  11580. builder.Write("费用标准:");
  11581. string curr = "";
  11582. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11583. if (currData != null)
  11584. {
  11585. curr = currData.Name;
  11586. }
  11587. builder.MoveToCell(1, i, 3, 0);
  11588. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11589. builder.MoveToCell(1, i, 4, 0);
  11590. builder.Write("费用小计:");
  11591. builder.MoveToCell(1, i, 5, 0);
  11592. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11593. }
  11594. #endregion
  11595. }
  11596. else dic.Add("SubHS", "0.00");
  11597. //删除多余行
  11598. while (table2.Rows.Count > table2Row)
  11599. {
  11600. table2.Rows.RemoveAt(table2Row);
  11601. }
  11602. //公杂费
  11603. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  11604. if (_EnterExitCosts.ChoiceFive == 1)
  11605. {
  11606. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  11607. table3Row = dac3.Count;
  11608. #region 填充word表格内容
  11609. for (int i = 0; i < dac3.Count; i++)
  11610. {
  11611. var dac = dac3[i];
  11612. if (dac == null) continue;
  11613. builder.MoveToCell(2, i, 0, 0);
  11614. builder.Write("第" + dac.Days.ToString() + "天:");
  11615. builder.MoveToCell(2, i, 1, 0);
  11616. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11617. builder.MoveToCell(2, i, 2, 0);
  11618. builder.Write("费用标准:");
  11619. string curr = "";
  11620. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11621. if (currData != null)
  11622. {
  11623. curr = currData.Name;
  11624. }
  11625. builder.MoveToCell(2, i, 3, 0);
  11626. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11627. builder.MoveToCell(2, i, 4, 0);
  11628. builder.Write("费用小计:");
  11629. builder.MoveToCell(2, i, 5, 0);
  11630. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11631. }
  11632. //删除多余行
  11633. while (table3.Rows.Count > table3Row)
  11634. {
  11635. table3.Rows.RemoveAt(table3Row);
  11636. }
  11637. #endregion
  11638. }
  11639. else dic.Add("SubGZF", "0.00");
  11640. //删除多余行
  11641. while (table3.Rows.Count > table3Row)
  11642. {
  11643. table3.Rows.RemoveAt(table3Row);
  11644. }
  11645. //培训费
  11646. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  11647. if (_EnterExitCosts.ChoiceSix == 1)
  11648. {
  11649. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  11650. dic.Add("SubPX", pxStr);
  11651. table4Row = dac4.Count;
  11652. #region 填充word表格内容
  11653. for (int i = 0; i < dac4.Count; i++)
  11654. {
  11655. var dac = dac4[i];
  11656. if (dac == null) continue;
  11657. builder.MoveToCell(3, i, 0, 0);
  11658. builder.Write("第" + dac.Days.ToString() + "天:");
  11659. builder.MoveToCell(3, i, 1, 0);
  11660. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11661. builder.MoveToCell(3, i, 2, 0);
  11662. builder.Write("费用标准:");
  11663. string curr = "";
  11664. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11665. if (currData != null)
  11666. {
  11667. curr = currData.Name;
  11668. }
  11669. builder.MoveToCell(3, i, 3, 0);
  11670. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11671. builder.MoveToCell(3, i, 4, 0);
  11672. builder.Write("费用小计:");
  11673. builder.MoveToCell(3, i, 5, 0);
  11674. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11675. }
  11676. #endregion
  11677. }
  11678. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  11679. //删除多余行
  11680. while (table4.Rows.Count > table4Row)
  11681. {
  11682. table4.Rows.RemoveAt(table4Row);
  11683. }
  11684. //其他费用
  11685. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  11686. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  11687. {
  11688. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  11689. dic.Add("titleQi", qtStr);
  11690. table5Row = dac5.Count;
  11691. #region 填充word表格内容
  11692. for (int i = 0; i < dac5.Count; i++)
  11693. {
  11694. var dac = dac5[i];
  11695. if (dac == null) continue;
  11696. builder.MoveToCell(4, i, 0, 0);
  11697. builder.Write("第" + dac.Index.ToString() + "项:");
  11698. builder.MoveToCell(4, i, 1, 0);
  11699. builder.Write(dac.itemName);
  11700. builder.MoveToCell(4, i, 2, 0);
  11701. builder.Write("费用标准:");
  11702. builder.MoveToCell(4, i, 3, 0);
  11703. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  11704. builder.MoveToCell(4, i, 4, 0);
  11705. builder.Write("费用小计:");
  11706. builder.MoveToCell(4, i, 5, 0);
  11707. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11708. builder.MoveToCell(4, i, 6, 0);
  11709. builder.Write("备注:");
  11710. builder.MoveToCell(4, i, 7, 0);
  11711. builder.Write(dac.Remark);
  11712. }
  11713. #endregion
  11714. }
  11715. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  11716. //删除多余行
  11717. while (table5.Rows.Count > table5Row)
  11718. {
  11719. table5.Rows.RemoveAt(table5Row);
  11720. }
  11721. //加上其他费用
  11722. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  11723. decimal subJJC = 0.00M,
  11724. subGWC = 0.00M,
  11725. subTDC = 0.00M;
  11726. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  11727. string totalLabel = string.Format("全部费用总计:");
  11728. //经济舱
  11729. if (_EnterExitCosts.SumJJC == 1)
  11730. {
  11731. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  11732. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  11733. }
  11734. //公务舱
  11735. if (_EnterExitCosts.SumGWC == 1)
  11736. {
  11737. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  11738. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  11739. }
  11740. //头等舱
  11741. if (_EnterExitCosts.SumTDC == 1)
  11742. {
  11743. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  11744. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  11745. }
  11746. //TotalLabel
  11747. dic.Add("TotalLabel", totalLabel);
  11748. #region 填充word模板书签内容
  11749. foreach (var key in dic.Keys)
  11750. {
  11751. Bookmark bookmark = doc.Range.Bookmarks[key];
  11752. if (bookmark != null)
  11753. {
  11754. builder.MoveToBookmark(key);
  11755. builder.Write(dic[key]);
  11756. }
  11757. }
  11758. #endregion
  11759. //文件名
  11760. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  11761. strFileName = CommonFun.ValidFileName(strFileName);
  11762. AsposeHelper.removewatermark_v2180();
  11763. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  11764. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  11765. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  11766. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  11767. }
  11768. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  11769. {
  11770. //获取模板
  11771. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  11772. //载入模板
  11773. Document doc = new Document(tempPath);
  11774. DocumentBuilder builder = new DocumentBuilder(doc);
  11775. Dictionary<string, string> dic = new Dictionary<string, string>();
  11776. string returnCodeLabel = string.Empty;
  11777. if (nationalTravelFeeData.Any())
  11778. {
  11779. List<string> list = new List<string>();
  11780. foreach (var item in nationalTravelFeeData)
  11781. {
  11782. list.Add($"{item.Country}({item.City})");
  11783. }
  11784. list = list.Distinct().ToList();
  11785. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  11786. }
  11787. var countryLabel = string.Empty;
  11788. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  11789. if (countryData.Any())
  11790. {
  11791. countryLabel = string.Join("、", countryData);
  11792. }
  11793. dic.Add("ReturnCodeAir", returnCodeLabel);
  11794. dic.Add("VisitStartDate", "-");
  11795. dic.Add("VisitEndDate", "-");
  11796. dic.Add("Day", "-");
  11797. dic.Add("VisitCountry", countryLabel);
  11798. dic.Add("ClientUnit", "-");
  11799. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  11800. //dic.Add("Names", Names);
  11801. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11802. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  11803. decimal dac1totalPrice = 0.00M;
  11804. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  11805. foreach (var dac in dac1)
  11806. {
  11807. if (dac.SubTotal == 0.00M)
  11808. {
  11809. continue;
  11810. }
  11811. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  11812. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  11813. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  11814. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  11815. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  11816. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  11817. builder.Write(currency);//币种
  11818. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  11819. builder.Write(dac.Cost.ToString("#0.00"));//标准
  11820. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  11821. builder.Write("");//人数
  11822. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  11823. builder.Write("");//天数
  11824. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  11825. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  11826. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  11827. decimal rate = 0.00M;
  11828. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  11829. builder.Write(rate.ToString("#0.0000"));//汇率
  11830. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  11831. decimal rbmPrice = dac.SubTotal;
  11832. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  11833. accommodationStartIndex++;
  11834. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  11835. }
  11836. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  11837. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  11838. {
  11839. table1.Rows.RemoveAt(i - 1);
  11840. foodandotherStartIndex--;
  11841. }
  11842. if (dac2.Count == dac3.Count)//国家 币种 金额
  11843. {
  11844. for (int i = 0; i < dac2.Count; i++)
  11845. {
  11846. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  11847. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  11848. }
  11849. }
  11850. decimal dac2totalPrice = 0.00M;
  11851. foreach (var dac in dac2)
  11852. {
  11853. if (dac.SubTotal == 0)
  11854. {
  11855. continue;
  11856. }
  11857. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  11858. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  11859. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  11860. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  11861. builder.Write(currency);//币种
  11862. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  11863. builder.Write(dac.Cost.ToString("#0.00"));//标准
  11864. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  11865. builder.Write("");//人数
  11866. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  11867. builder.Write("");//天数
  11868. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  11869. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  11870. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  11871. decimal rate = 0.00M;
  11872. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  11873. builder.Write(rate.ToString("#0.0000"));//汇率
  11874. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  11875. decimal rbmPrice = dac.SubTotal;
  11876. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  11877. foodandotherStartIndex++;
  11878. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  11879. }
  11880. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  11881. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  11882. {
  11883. table1.Rows.RemoveAt(i - 1);
  11884. }
  11885. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  11886. string otherFeeStr = "";
  11887. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  11888. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  11889. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  11890. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  11891. foreach (var otherInfo in dac5)
  11892. {
  11893. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  11894. }
  11895. #endregion
  11896. if (otherFeeStr.Length > 0)
  11897. {
  11898. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  11899. otherFeeStr = $"({otherFeeStr})";
  11900. dic.Add("OtherFeeStr", otherFeeStr);
  11901. }
  11902. //总计
  11903. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  11904. //国际旅费
  11905. string outsideAir = string.Empty;
  11906. string allPriceAir = string.Empty;
  11907. if (_EnterExitCosts.SumJJC == 1)
  11908. {
  11909. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  11910. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  11911. }
  11912. if (_EnterExitCosts.SumGWC == 1)
  11913. {
  11914. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  11915. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  11916. }
  11917. if (_EnterExitCosts.SumTDC == 1)
  11918. {
  11919. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  11920. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  11921. }
  11922. dic.Add("InTravelPrice", $"({outsideAir})");
  11923. dic.Add("FinalSumPrice", $"({allPriceAir})");
  11924. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  11925. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  11926. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  11927. foreach (var key in dic.Keys)
  11928. {
  11929. builder.MoveToBookmark(key);
  11930. builder.Write(dic[key]);
  11931. }
  11932. //模板文件名
  11933. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  11934. strFileName = CommonFun.ValidFileName(strFileName);
  11935. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  11936. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  11937. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  11938. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  11939. }
  11940. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  11941. {
  11942. //获取模板
  11943. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  11944. //载入模板
  11945. WorkbookDesigner designer = new WorkbookDesigner();
  11946. designer.Workbook = new Workbook(tempPath);
  11947. Dictionary<string, string> dic = new Dictionary<string, string>();
  11948. string returnCodeLabel = string.Empty;
  11949. if (nationalTravelFeeData.Any())
  11950. {
  11951. List<string> list = new List<string>();
  11952. foreach (var item in nationalTravelFeeData)
  11953. {
  11954. list.Add($"{item.Country}({item.City})");
  11955. }
  11956. list = list.Distinct().ToList();
  11957. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  11958. }
  11959. var countryLabel = string.Empty;
  11960. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  11961. if (countryData.Any())
  11962. {
  11963. countryLabel = string.Join("、", countryData);
  11964. }
  11965. dic.Add("ReturnCodeAir", returnCodeLabel);
  11966. dic.Add("VisitStartDate", "-");
  11967. dic.Add("VisitEndDate", "-");
  11968. dic.Add("Day", "0");
  11969. dic.Add("VisitCountry", countryLabel);
  11970. dic.Add("ClientUnit", "-");
  11971. designer.SetDataSource("ClientUnit", "-");
  11972. designer.SetDataSource("VisitCountry", countryLabel);
  11973. designer.SetDataSource("Group", "-");
  11974. designer.SetDataSource("ClientUnitTitle", "-");
  11975. designer.SetDataSource("Name", "-");
  11976. designer.SetDataSource("VisitStartDate", "-");
  11977. designer.SetDataSource("Day", "0");
  11978. designer.SetDataSource("ReturnCode", returnCodeLabel);
  11979. designer.SetDataSource("ReturnCodeAir", "-");
  11980. int startIndex = 10;
  11981. const int startIndexcopy = 10;
  11982. if (dac2.Count == dac3.Count)//国家 币种 金额
  11983. {
  11984. for (int i = 0; i < dac2.Count; i++)
  11985. {
  11986. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  11987. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  11988. }
  11989. }
  11990. DataTable dtdac1 = new DataTable();
  11991. List<string> place = new List<string>();
  11992. dtdac1.Columns.AddRange(new DataColumn[] {
  11993. new DataColumn(){ ColumnName = "city"},
  11994. new DataColumn(){ ColumnName = "curr"},
  11995. new DataColumn(){ ColumnName = "criterion"},
  11996. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  11997. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  11998. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  11999. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  12000. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  12001. });
  12002. DataTable dtdac2 = new DataTable();
  12003. dtdac2.Columns.AddRange(new DataColumn[] {
  12004. new DataColumn(){ ColumnName = "city"},
  12005. new DataColumn(){ ColumnName = "curr"},
  12006. new DataColumn(){ ColumnName = "criterion"},
  12007. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  12008. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  12009. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  12010. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  12011. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  12012. });
  12013. dtdac1.TableName = "tb1";
  12014. dtdac2.TableName = "tb2";
  12015. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  12016. foreach (var item in dac1)
  12017. {
  12018. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  12019. if (place.Contains(item.Place))
  12020. {
  12021. continue;
  12022. }
  12023. DataRow row = dtdac1.NewRow();
  12024. row["city"] = item.Place;
  12025. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  12026. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  12027. row["curr"] = currency;
  12028. row["rate"] = rate.ToString("#0.0000");
  12029. row["criterion"] = item.Cost.ToString("#0.00");
  12030. row["number"] = 1;
  12031. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  12032. //row["costRMB"] = rbmPrice;
  12033. dtdac1.Rows.Add(row);
  12034. place.Add(item.Place);
  12035. }
  12036. place = new List<string>();
  12037. foreach (var item in dac2)
  12038. {
  12039. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  12040. if (place.Contains(item.Place))
  12041. {
  12042. continue;
  12043. }
  12044. DataRow row = dtdac2.NewRow();
  12045. row["city"] = item.Place;
  12046. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  12047. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  12048. row["curr"] = currency;
  12049. row["rate"] = rate.ToString("#0.0000");
  12050. row["criterion"] = item.Cost.ToString("#0.00");
  12051. row["number"] = 1;
  12052. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  12053. //row["cost"] = item.SubTotal;
  12054. //row["costRMB"] = rbmPrice;
  12055. dtdac2.Rows.Add(row);
  12056. place.Add(item.Place);
  12057. //dac2totalPrice += rbmPrice;
  12058. }
  12059. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  12060. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  12061. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  12062. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  12063. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  12064. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  12065. string cell4Str1 = string.Empty;
  12066. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  12067. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  12068. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  12069. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  12070. string cellStr = $" 5.其他费用(";
  12071. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  12072. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  12073. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  12074. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  12075. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  12076. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  12077. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  12078. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  12079. foreach (var otherInfo in dac5)
  12080. {
  12081. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  12082. }
  12083. #endregion
  12084. if (cellStr.Length > 8)
  12085. {
  12086. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  12087. }
  12088. cellStr += ")";
  12089. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  12090. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  12091. decimal pxFee = dac4.Sum(it => it.Cost);
  12092. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  12093. string celllastStr1 = "";
  12094. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  12095. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  12096. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  12097. celllastStr1 += $",国际旅费 元";
  12098. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  12099. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  12100. designer.SetDataSource("cell4Str", cell4Str);
  12101. designer.SetDataSource("cellStr", cellStr);
  12102. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  12103. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  12104. designer.SetDataSource("celllastStr", celllastStr);
  12105. Workbook wb = designer.Workbook;
  12106. var sheet = wb.Worksheets[0];
  12107. //绑定datatable数据集
  12108. designer.SetDataSource(dtdac1);
  12109. designer.SetDataSource(dtdac2);
  12110. designer.Process();
  12111. var rowStart = dtdac1.Rows.Count;
  12112. while (rowStart > 0)
  12113. {
  12114. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  12115. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  12116. startIndex++;
  12117. rowStart--;
  12118. }
  12119. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  12120. startIndex += 1; //总计行
  12121. rowStart = dtdac2.Rows.Count;
  12122. while (rowStart > 0)
  12123. {
  12124. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  12125. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  12126. startIndex++;
  12127. rowStart--;
  12128. }
  12129. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  12130. wb.CalculateFormula(true);
  12131. //模板文件名
  12132. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12133. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  12134. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  12135. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  12136. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  12137. }
  12138. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  12139. {
  12140. //获取模板
  12141. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  12142. //载入模板
  12143. Document doc = new Document(tempPath);
  12144. DocumentBuilder builder = new DocumentBuilder(doc);
  12145. Dictionary<string, string> dic = new Dictionary<string, string>();
  12146. dic.Add("GroupName", "-");
  12147. dic.Add("ClientUnit", "-");
  12148. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  12149. //string missionLeaderJob = "";//负责人job
  12150. //int groupNumber = 0; //团人数
  12151. dic.Add("MissionLeader", "-"); //团负责人
  12152. dic.Add("MissionLeaderJob", "-"); //团负责人job
  12153. dic.Add("GroupNumber", "0"); //团人数
  12154. dic.Add("Day", "0");
  12155. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  12156. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  12157. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12158. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  12159. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  12160. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  12161. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  12162. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  12163. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  12164. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  12165. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  12166. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  12167. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  12168. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  12169. //其他费用
  12170. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  12171. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  12172. //其他费用合计
  12173. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  12174. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  12175. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  12176. //公务舱合计
  12177. //国际旅费
  12178. //string outsideJJ = "";
  12179. //string allPriceJJ = "";
  12180. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  12181. {
  12182. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  12183. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  12184. }
  12185. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  12186. {
  12187. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  12188. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  12189. }
  12190. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  12191. {
  12192. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  12193. dic.Add("AirFeeTotal", airFeeTotalStr);
  12194. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  12195. dic.Add("FeeTotal", feeTotalStr);
  12196. }
  12197. foreach (var key in dic.Keys)
  12198. {
  12199. builder.MoveToBookmark(key);
  12200. builder.Write(dic[key]);
  12201. }
  12202. //模板文件名
  12203. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  12204. strFileName = CommonFun.ValidFileName(strFileName);
  12205. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  12206. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  12207. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  12208. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  12209. }
  12210. }
  12211. else if (dto.ExportType == 2) //表格
  12212. {
  12213. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  12214. }
  12215. else if (dto.ExportType == 3)
  12216. {
  12217. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  12218. }
  12219. return Ok(JsonView(400, "只可导出明细表!", ""));
  12220. }
  12221. catch (Exception ex)
  12222. {
  12223. return Ok(JsonView(400, ex.Message, ""));
  12224. }
  12225. }
  12226. /// <summary>
  12227. /// 获取三公费用标准city
  12228. /// </summary>
  12229. /// <param name="placeData"></param>
  12230. /// <param name="nationalTravelFeeId"></param>
  12231. /// <returns></returns>
  12232. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  12233. {
  12234. string _city = string.Empty;
  12235. if (!placeData.Any()) return _city;
  12236. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  12237. if (data == null) return _city;
  12238. string country = data.Country;
  12239. string city = data.City;
  12240. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  12241. else _city = city;
  12242. return _city;
  12243. }
  12244. /// <summary>
  12245. /// 团组模块 - 出入境费用-草稿 - 一键清空
  12246. /// </summary>
  12247. /// <returns></returns>
  12248. [HttpPost]
  12249. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  12250. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12251. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  12252. {
  12253. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  12254. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  12255. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  12256. if (_view.Code == 0)
  12257. {
  12258. return Ok(JsonView(true, "操作成功"));
  12259. }
  12260. return Ok(JsonView(false, "操作失败"));
  12261. }
  12262. /// <summary>
  12263. /// 团组模块 - 出入境费用-草稿 - 子项删除
  12264. /// </summary>
  12265. /// <returns></returns>
  12266. [HttpPost]
  12267. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  12268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12269. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12270. {
  12271. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12272. if (data.Code != 0)
  12273. {
  12274. return Ok(JsonView(false, data.Msg));
  12275. }
  12276. return Ok(JsonView(true, "操作成功!", data.Data));
  12277. }
  12278. /// <summary>
  12279. /// 三公其他费用草稿 删除
  12280. /// </summary>
  12281. /// <param name="dto"></param>
  12282. /// <returns></returns>
  12283. [HttpPost]
  12284. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  12285. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  12286. {
  12287. var jw = JsonView(false, "删除失败!");
  12288. var data = new Grp_DayOtherPriceDraft()
  12289. {
  12290. Id = dto.Id,
  12291. IsDel = 1,
  12292. DeleteUserId = dto.DeleteUserId,
  12293. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12294. };
  12295. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12296. if (del > 0)
  12297. {
  12298. jw.Code = 200;
  12299. jw.Msg = "删除成功!";
  12300. }
  12301. return Ok(jw);
  12302. }
  12303. /// <summary>
  12304. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  12305. /// </summary>
  12306. /// <returns></returns>
  12307. [HttpPost]
  12308. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  12309. {
  12310. var jw = JsonView(false);
  12311. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  12312. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  12313. jw.Code = StatusCodes.Status200OK;
  12314. jw.Msg = "操作成功!";
  12315. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  12316. return Ok(jw);
  12317. }
  12318. /// <summary>
  12319. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  12320. /// </summary>
  12321. /// <param name="dto"></param>
  12322. /// <returns></returns>
  12323. [HttpPost]
  12324. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  12325. {
  12326. int userId = dto.UserId,
  12327. portId = dto.PortType,
  12328. groupId = dto.GroupId,
  12329. draftId = dto.DraftId;
  12330. _portTypeData.Add(1);
  12331. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12332. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  12333. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  12334. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  12335. _sqlSugar.BeginTran();
  12336. try
  12337. {
  12338. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  12339. if (draftDatas == null)
  12340. {
  12341. _sqlSugar.RollbackTran();
  12342. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  12343. }
  12344. //验证可覆盖已有数据 两边创建人需为同一人;
  12345. int draftCreateUserId = draftDatas.CreateUserId,
  12346. formalCreateUserId = 0;
  12347. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  12348. if (formalData != null)
  12349. {
  12350. formalCreateUserId = formalData.CreateUserId;
  12351. if (draftCreateUserId != formalCreateUserId)
  12352. {
  12353. _sqlSugar.RollbackTran();
  12354. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  12355. }
  12356. }
  12357. //默认添加查看、编辑权限(创建人、自己)
  12358. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  12359. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  12360. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  12361. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  12362. newExterData.DiId = groupId;
  12363. newExterData.CreateUserId = userId;
  12364. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  12365. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  12366. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  12367. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  12368. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  12369. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  12370. //数据如果存在执行删除
  12371. if (enterExitCostInfo != null)
  12372. {
  12373. _sqlSugar.Updateable<Grp_EnterExitCost>()
  12374. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  12375. .Where(x => x.Id == enterExitCostInfo.Id)
  12376. .ExecuteCommand();
  12377. _sqlSugar.Updateable<Grp_DayAndCost>()
  12378. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  12379. .Where(x => x.DiId == groupId)
  12380. .ExecuteCommand();
  12381. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  12382. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  12383. .Where(x => x.Diid == groupId)
  12384. .ExecuteCommand();
  12385. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  12386. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  12387. .Where(x => x.GroupId == groupId)
  12388. .ExecuteCommand();
  12389. }
  12390. //执行insert
  12391. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  12392. if (insertId < 1)
  12393. {
  12394. _sqlSugar.RollbackTran();
  12395. return Ok(JsonView(false, "草稿数据导入失败!"));
  12396. }
  12397. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  12398. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  12399. #region 默认添加权限
  12400. #endregion
  12401. _sqlSugar.CommitTran();
  12402. //执行操作之后
  12403. //生成默认文件pdf并且通知人员
  12404. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12405. {
  12406. DiId = groupId,
  12407. ExportType = 1,
  12408. SubTypeId = 1005
  12409. }, "pdf");
  12410. //发送通知
  12411. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  12412. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  12413. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  12414. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  12415. //汇率信息记录
  12416. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  12417. return Ok(JsonView(true));
  12418. }
  12419. catch (Exception ex)
  12420. {
  12421. _sqlSugar.RollbackTran();
  12422. return Ok(JsonView(false, ex.Message));
  12423. }
  12424. }
  12425. #endregion
  12426. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  12427. /// <summary>
  12428. /// 获取币种基础数据(含逻辑处理)
  12429. /// </summary>
  12430. /// <returns></returns>
  12431. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  12432. {
  12433. return await GeneralMethod.EnterExitCostInitRate();
  12434. }
  12435. /// <summary>
  12436. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  12437. /// </summary>
  12438. /// <returns></returns>
  12439. [HttpPost]
  12440. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12441. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  12442. {
  12443. //验证城市归属并给默认值
  12444. int provinceId = dto.ProvinceId;
  12445. if (provinceId < 1) provinceId = 122;
  12446. var dataSource = await _sqlSugar
  12447. .Queryable<Sys_SetData>()
  12448. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  12449. .ToListAsync();
  12450. var fileTypes = new List<EecSetDataInfoView>();
  12451. //三公费用-Word明细类型
  12452. var wordTypeData = dataSource
  12453. .Where(it => it.STid == 72)
  12454. .Select(x => new EecSetDataInfoView
  12455. {
  12456. ParentId = 1,
  12457. Id = x.Id,
  12458. Name = x.Name
  12459. })
  12460. .ToArray();
  12461. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  12462. var excelTypeData = dataSource
  12463. .Where(it => it.STid == 73)
  12464. .Select(x => new EecSetDataInfoView
  12465. {
  12466. ParentId = 2,
  12467. Id = x.Id,
  12468. Name = x.Name
  12469. })
  12470. .ToArray();
  12471. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  12472. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  12473. fileTypes.Add(groupNameList);
  12474. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  12475. //默认币种显示
  12476. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  12477. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  12478. return Ok(JsonView(true, "查询成功!", new
  12479. {
  12480. FileTypeData = fileTypes,
  12481. CurrencyInit = _currencyInfos,
  12482. viewPermissionData = viewPermissionData
  12483. }));
  12484. }
  12485. /// <summary>
  12486. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  12487. /// </summary>
  12488. /// <returns></returns>
  12489. [HttpPost]
  12490. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12491. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  12492. {
  12493. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12494. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12495. RefAsync<int> total = 0;
  12496. int diId = 0;
  12497. var status = int.TryParse(dto.GroupName, out diId);
  12498. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  12499. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  12500. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  12501. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  12502. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  12503. .OrderByDescending(x => x.VisitStartDate)
  12504. .Select(x => new EnterExitCostMobileGroupView()
  12505. {
  12506. Id = x.Id,
  12507. GroupName = x.TeamName,
  12508. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  12509. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  12510. ProvinceId = x.CityId
  12511. })
  12512. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12513. //处理省份Id
  12514. if (data.Any())
  12515. {
  12516. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  12517. if (provCityDatas.Any())
  12518. {
  12519. foreach (var item in data)
  12520. {
  12521. var provinceId = item.ProvinceId;
  12522. var isDefualtVal = true;
  12523. if (provinceId > 0)
  12524. {
  12525. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  12526. if (parentId != null)
  12527. {
  12528. isDefualtVal = false;
  12529. item.ProvinceId = (int)parentId;
  12530. }
  12531. }
  12532. if (isDefualtVal)
  12533. {
  12534. item.ProvinceId = 122; //默认四川
  12535. }
  12536. }
  12537. }
  12538. }
  12539. //处理是否显示
  12540. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  12541. {
  12542. foreach (var item in data)
  12543. {
  12544. item.IsView = true;
  12545. }
  12546. }
  12547. return Ok(JsonView(true, "查询成功!", data, total));
  12548. }
  12549. /// <summary>
  12550. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  12551. /// </summary>
  12552. /// <returns></returns>
  12553. [HttpPost]
  12554. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12555. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  12556. {
  12557. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12558. RefAsync<int> total = 0;
  12559. var data = await _sqlSugar.Queryable<Sys_SetData>()
  12560. .Where(x => x.IsDel == 0 && x.STid == 66)
  12561. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  12562. .Select(x => new
  12563. {
  12564. id = x.Id,
  12565. name = x.Name,
  12566. remark = x.Remark,
  12567. })
  12568. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12569. return Ok(JsonView(true, "查询成功!", data, total));
  12570. }
  12571. /// <summary>
  12572. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  12573. /// </summary>
  12574. /// <returns></returns>
  12575. [HttpPost]
  12576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12577. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  12578. {
  12579. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12580. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12581. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  12582. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  12583. var groupOtherRateData = groupRateData.TeamRates;
  12584. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  12585. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  12586. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  12587. groupOtherRateData = groupOtherRateData
  12588. .Select(x => new TeamRateDescAddCurrencyIdView
  12589. {
  12590. CurrencyId = x.CurrencyId,
  12591. CurrencyName = x.CurrencyName,
  12592. CurrencyCode = x.CurrencyCode,
  12593. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  12594. }).ToList();
  12595. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  12596. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  12597. }
  12598. /// <summary>
  12599. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  12600. /// </summary>
  12601. /// <returns></returns>
  12602. [HttpPost]
  12603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12604. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  12605. {
  12606. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12607. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12608. var tipsData = new List<int>() { 1, 2, 3 };
  12609. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  12610. if (dto.TipsType == 1)
  12611. {
  12612. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  12613. }
  12614. else if (dto.TipsType == 2)
  12615. {
  12616. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  12617. return Ok(JsonView(true, "查询成功!", visaData.Data));
  12618. }
  12619. else if (dto.TipsType == 3)
  12620. {
  12621. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  12622. return Ok(JsonView(true, "查询成功!", airData));
  12623. }
  12624. return Ok(JsonView(false));
  12625. }
  12626. /// <summary>
  12627. /// 团组模块 - 出入境国家费用标准-移动端 List
  12628. /// </summary>
  12629. /// <returns></returns>
  12630. [HttpPost]
  12631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12632. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  12633. {
  12634. Stopwatch sw = new Stopwatch();
  12635. sw.Start();
  12636. int provinceId = dto.ProvinceId;
  12637. if (provinceId < 1) provinceId = 122; // 默认四川
  12638. RefAsync<int> total = 0;
  12639. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  12640. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  12641. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  12642. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  12643. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  12644. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  12645. .Select((ntf, sd, u, sd1) => new
  12646. {
  12647. Id = ntf.Id,
  12648. Area = $"{ntf.Country}-{ntf.City}",
  12649. Currency = ntf.Currency,
  12650. CurrencyCode = sd.Name,
  12651. CurrencyName = sd.Remark,
  12652. RoomCost = ntf.RoomCost,
  12653. FoodCost = ntf.FoodCost,
  12654. PublicCost = ntf.PublicCost,
  12655. TrainCost = ntf.TrainCost,
  12656. LastUpdateUserId = ntf.LastUpdateUserId,
  12657. LastUpdateUserName = u.CnName,
  12658. LastUpdateTime = ntf.LastUpdateTime
  12659. })
  12660. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12661. sw.Stop();
  12662. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  12663. }
  12664. /// <summary>
  12665. /// 团组模块 - 出入境费用-移动端 - Info
  12666. /// </summary>
  12667. /// <returns></returns>
  12668. [HttpPost]
  12669. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12670. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  12671. {
  12672. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12673. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12674. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12675. return Ok(data);
  12676. }
  12677. /// <summary>
  12678. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  12679. /// </summary>
  12680. /// <returns></returns>
  12681. [HttpPost]
  12682. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12683. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  12684. {
  12685. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12686. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12687. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12688. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  12689. var mobileInfo = new EnterExitCostMobileParentInfoView();
  12690. mobileInfo.DiId = dto.DiId;
  12691. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  12692. if (eecInfo == null) return Ok(mobileInfo);
  12693. //验证查看权限
  12694. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  12695. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  12696. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  12697. mobileInfo.IsAssignPerm = isSet;
  12698. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  12699. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12700. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12701. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  12702. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12703. {
  12704. SubId = dac.Id,
  12705. DiId = dac.DiId,
  12706. Type = dac.Type,
  12707. Days = dac.Days,
  12708. NationalTravelFeeId = dac.NationalTravelFeeId,
  12709. Arae = $"{ntf.Country}-{ntf.City}",
  12710. Cost = dac.Cost,
  12711. Currency = dac.Currency,
  12712. CurrencyName = sd.Name,
  12713. SubTotal = dac.SubTotal,
  12714. })
  12715. .ToList();
  12716. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  12717. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  12718. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  12719. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  12720. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  12721. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  12722. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  12723. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  12724. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  12725. //其他款项
  12726. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  12727. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12728. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12729. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  12730. .OrderBy((dop, sd1, sd2) => dop.Index)
  12731. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  12732. {
  12733. SubId = dop.Id,
  12734. DiId = dop.Diid,
  12735. Index = dop.Index,
  12736. SetDataId = dop.SetDataId,
  12737. SetDataName = sd1.Name,
  12738. Cost = dop.Cost,
  12739. Currency = dop.Currency,
  12740. CurrencyName = sd2.Remark,
  12741. SubTotal = dop.SubTotal,
  12742. Remark = dop.Remark,
  12743. })
  12744. .ToArray();
  12745. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  12746. return Ok(mobileInfo);
  12747. }
  12748. /// <summary>
  12749. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  12750. /// </summary>
  12751. /// <returns></returns>
  12752. [HttpPost]
  12753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12754. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  12755. {
  12756. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12757. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12758. //验证查看权限
  12759. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  12760. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  12761. var userIds = await _sqlSugar
  12762. .Queryable<Grp_EnterExitCostPermission>()
  12763. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  12764. .Select(x => x.UserId)
  12765. .ToArrayAsync();
  12766. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  12767. var perUsersView = new List<dynamic>();
  12768. foreach (var item in perUsers)
  12769. {
  12770. bool isView1 = false;
  12771. if (userIds.Any(x => x == item.Id)) isView1 = true;
  12772. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  12773. }
  12774. return Ok(JsonView(perUsersView));
  12775. }
  12776. /// <summary>
  12777. /// 团组模块 - 出入境费用-移动端 - SubInfo
  12778. /// </summary>
  12779. /// <returns></returns>
  12780. [HttpPost]
  12781. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12782. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  12783. {
  12784. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12785. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12786. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12787. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  12788. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  12789. //验证查看权限
  12790. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  12791. //if (!isView) return Ok(JsonView(false, msg));
  12792. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  12793. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  12794. var subType = dto.SubType;
  12795. if (subType == 1) //1:境内费用
  12796. {
  12797. var oneData = new ChoiceOneMobileSubInfoView()
  12798. {
  12799. Id = eecInfo.Id,
  12800. ChoiceOne = eecInfo.ChoiceOne,
  12801. ChoiceOneTotalCost = eecInfo.InsidePay,
  12802. Visa = eecInfo.Visa,
  12803. VisaRemark = eecInfo.VisaRemark,
  12804. YiMiao = eecInfo.YiMiao,
  12805. HeSuan = eecInfo.HeSuan,
  12806. Service = eecInfo.Service,
  12807. Ticket = eecInfo.Ticket,
  12808. Safe = eecInfo.Safe,
  12809. FirstItemRemark = eecInfo.FirstItemRemark
  12810. };
  12811. return Ok(JsonView(oneData));
  12812. }
  12813. else if (subType == 2) //2:国际旅费
  12814. {
  12815. var twoData = new ChoiceTwoMobileSubInfoView()
  12816. {
  12817. Id = eecInfo.Id,
  12818. ChoiceTwoJJ = eecInfo.SumJJC,
  12819. OutsideJJPay = eecInfo.OutsideJJPay,
  12820. ChoiceTwoGW = eecInfo.SumGWC,
  12821. OutsideGWPay = eecInfo.OutsideGWPay,
  12822. ChoiceTwoTD = eecInfo.SumTDC,
  12823. OutsideTDPay = eecInfo.OutsideTDPay,
  12824. AirJJ = eecInfo.AirJJ,
  12825. AirGW = eecInfo.AirGW,
  12826. AirTD = eecInfo.AirTD,
  12827. CityTranffic = eecInfo.CityTranffic,
  12828. CityTranffic1 = eecInfo.CityTranffic1,
  12829. CityTranffic2 = eecInfo.CityTranffic2,
  12830. TwoItemRemark = eecInfo.TwoItemRemark
  12831. };
  12832. return Ok(JsonView(twoData));
  12833. }
  12834. else if (subType == 3) //3:住宿费
  12835. {
  12836. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12837. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12838. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12839. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  12840. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12841. {
  12842. SubId = dac.Id,
  12843. DiId = dac.DiId,
  12844. Type = dac.Type,
  12845. Days = dac.Days,
  12846. NationalTravelFeeId = dac.NationalTravelFeeId,
  12847. Arae = $"{ntf.Country}-{ntf.City}",
  12848. Cost = dac.Cost,
  12849. Currency = dac.Currency,
  12850. CurrencyName = sd.Name,
  12851. SubTotal = dac.SubTotal,
  12852. })
  12853. .ToArray();
  12854. var data = new ChoiceMobileSubInfo3To6View()
  12855. {
  12856. ParentId = eecInfo.Id,
  12857. Choice = eecInfo.ChoiceThree,
  12858. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12859. Details = dayAndCostDatas
  12860. };
  12861. return Ok(JsonView(data));
  12862. }
  12863. else if (subType == 4) //4:伙食费
  12864. {
  12865. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12866. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12867. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12868. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  12869. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12870. {
  12871. SubId = dac.Id,
  12872. DiId = dac.DiId,
  12873. Type = dac.Type,
  12874. Days = dac.Days,
  12875. NationalTravelFeeId = dac.NationalTravelFeeId,
  12876. Arae = $"{ntf.Country}-{ntf.City}",
  12877. Cost = dac.Cost,
  12878. Currency = dac.Currency,
  12879. CurrencyName = sd.Name,
  12880. SubTotal = dac.SubTotal,
  12881. })
  12882. .ToArray();
  12883. var data = new ChoiceMobileSubInfo3To6View()
  12884. {
  12885. ParentId = eecInfo.Id,
  12886. Choice = eecInfo.ChoiceFour,
  12887. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12888. Details = dayAndCostDatas
  12889. };
  12890. return Ok(JsonView(data));
  12891. }
  12892. else if (subType == 5) //5:公杂费
  12893. {
  12894. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12895. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12896. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12897. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  12898. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12899. {
  12900. SubId = dac.Id,
  12901. DiId = dac.DiId,
  12902. Type = dac.Type,
  12903. Days = dac.Days,
  12904. NationalTravelFeeId = dac.NationalTravelFeeId,
  12905. Arae = $"{ntf.Country}-{ntf.City}",
  12906. Cost = dac.Cost,
  12907. Currency = dac.Currency,
  12908. CurrencyName = sd.Name,
  12909. SubTotal = dac.SubTotal,
  12910. })
  12911. .ToArray();
  12912. var data = new ChoiceMobileSubInfo3To6View()
  12913. {
  12914. ParentId = eecInfo.Id,
  12915. Choice = eecInfo.ChoiceFive,
  12916. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12917. Details = dayAndCostDatas
  12918. };
  12919. return Ok(JsonView(data));
  12920. }
  12921. else if (subType == 6) //6:培训费
  12922. {
  12923. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12924. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12925. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12926. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  12927. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12928. {
  12929. SubId = dac.Id,
  12930. DiId = dac.DiId,
  12931. Type = dac.Type,
  12932. Days = dac.Days,
  12933. NationalTravelFeeId = dac.NationalTravelFeeId,
  12934. Arae = $"{ntf.Country}-{ntf.City}",
  12935. Cost = dac.Cost,
  12936. Currency = dac.Currency,
  12937. CurrencyName = sd.Name,
  12938. SubTotal = dac.SubTotal,
  12939. })
  12940. .ToArray();
  12941. var data = new ChoiceMobileSubInfo3To6View()
  12942. {
  12943. ParentId = eecInfo.Id,
  12944. Choice = eecInfo.ChoiceSix,
  12945. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12946. Details = dayAndCostDatas
  12947. };
  12948. return Ok(JsonView(data));
  12949. }
  12950. else if (subType == 7) //7:其他
  12951. {
  12952. //其他款项
  12953. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  12954. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12955. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12956. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  12957. .OrderBy((dop, sd1, sd2) => dop.Index)
  12958. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  12959. {
  12960. SubId = dop.Id,
  12961. DiId = dop.Diid,
  12962. Index = dop.Index,
  12963. SetDataId = dop.SetDataId,
  12964. SetDataName = sd1.Name,
  12965. Cost = dop.Cost,
  12966. Currency = dop.Currency,
  12967. CurrencyName = sd2.Name,
  12968. SubTotal = dop.SubTotal,
  12969. Remark = dop.Remark,
  12970. })
  12971. .ToArray();
  12972. var data = new ChoiceSevenMobileSubInfoView()
  12973. {
  12974. ParentId = eecInfo.Id,
  12975. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  12976. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  12977. Details = otherData
  12978. };
  12979. return Ok(JsonView(data));
  12980. }
  12981. return Ok(JsonView(false));
  12982. }
  12983. #region op
  12984. ///// <summary>
  12985. ///// 移动端更新费用消息通知
  12986. ///// </summary>
  12987. ///// <param name="diid"></param>
  12988. ///// <param name="id"></param>
  12989. ///// <param name="currUserId"></param>
  12990. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  12991. //{
  12992. // try
  12993. // {
  12994. // ////生成默认文件pdf并且通知人员
  12995. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12996. // //{
  12997. // // DiId = diid,
  12998. // // ExportType = 1,
  12999. // // SubTypeId = 1005
  13000. // //}, "pdf");
  13001. // ////发送通知
  13002. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  13003. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  13004. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  13005. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  13006. // ////汇率信息记录
  13007. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  13008. // }
  13009. // catch (Exception ex)
  13010. // {
  13011. // //记录日志
  13012. // throw;
  13013. // }
  13014. //}
  13015. /// <summary>
  13016. /// 验证出入境费用数据是否存在
  13017. /// 不存在添加
  13018. /// </summary>
  13019. /// <param name="diId"></param>
  13020. /// <param name="currUserId"></param>
  13021. /// <returns></returns>
  13022. /// <exception cref="CustomException"></exception>
  13023. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  13024. {
  13025. var parentId = 0;
  13026. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  13027. if (info != null)
  13028. {
  13029. parentId = info.Id;
  13030. }
  13031. else
  13032. {
  13033. var currencys = await EnterExitCostMobileGetCurrencyInit();
  13034. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  13035. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  13036. parentId = addId;
  13037. }
  13038. return parentId;
  13039. }
  13040. /// <summary>
  13041. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  13042. /// </summary>
  13043. /// <returns></returns>
  13044. [HttpPost]
  13045. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13046. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  13047. {
  13048. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13049. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13050. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  13051. //验证编辑权限
  13052. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13053. //if (!isEdit) return Ok(JsonView(false, msg));
  13054. var permissions = new List<Grp_EnterExitCostPermission>();
  13055. foreach (var userId in dto.UserIds)
  13056. {
  13057. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  13058. }
  13059. if (permissions.Any())
  13060. {
  13061. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  13062. {
  13063. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  13064. }
  13065. _sqlSugar.BeginTran();
  13066. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  13067. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  13068. if (result < 1)
  13069. {
  13070. _sqlSugar.RollbackTran();
  13071. return Ok(JsonView(false));
  13072. }
  13073. _sqlSugar.CommitTran();
  13074. return Ok(JsonView(true));
  13075. }
  13076. return Ok(JsonView(false));
  13077. }
  13078. /// <summary>
  13079. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  13080. /// </summary>
  13081. /// <returns></returns>
  13082. [HttpPost]
  13083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13084. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  13085. {
  13086. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13087. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13088. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13089. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  13090. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  13091. int id = dto.Id;
  13092. if (id <= 0) //add
  13093. {
  13094. //int provinceId = dto.ProvinceId;
  13095. int groupId = dto.DiId;
  13096. //if (provinceId < 1) provinceId = 122;
  13097. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  13098. info.LastUpdateUserId = dto.CurrUserId;
  13099. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13100. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  13101. if (add < 1) return Ok(JsonView(false));
  13102. id = add;
  13103. }
  13104. else //update
  13105. {
  13106. ////验证编辑权限
  13107. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13108. //if (!isEdit) return Ok(JsonView(false, msg));
  13109. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  13110. {
  13111. CurrencyRemark = currencyStr,
  13112. LastUpdateUserId = dto.CurrUserId,
  13113. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13114. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  13115. if (upd < 1) return Ok(JsonView(false));
  13116. }
  13117. #region 汇率变更时更改币种相关费用
  13118. var opDayCosts = new List<Grp_DayAndCost>();
  13119. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  13120. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  13121. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  13122. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  13123. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  13124. .Select((dac, sd) => new
  13125. {
  13126. dac.Id,
  13127. dac.DiId,
  13128. CurrencyCode = sd.Name,
  13129. dac.Cost
  13130. })
  13131. .ToList();
  13132. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  13133. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  13134. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  13135. .Select((dop, sd) => new
  13136. {
  13137. dop.Id,
  13138. dop.Diid,
  13139. CurrencyCode = sd.Name,
  13140. dop.Cost
  13141. })
  13142. .ToList();
  13143. if (dayCosts.Count > 0)
  13144. {
  13145. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  13146. foreach (var dc in new_dayCosts)
  13147. {
  13148. var thisCurrency = dc.Key.ToUpper();
  13149. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  13150. if (thisRate == 0.00M) continue;
  13151. foreach (var dcSub in dc)
  13152. {
  13153. opDayCosts.Add(new Grp_DayAndCost()
  13154. {
  13155. Id = dcSub.Id,
  13156. DiId = dcSub.DiId,
  13157. Cost = dcSub.Cost,
  13158. SubTotal = dcSub.Cost * thisRate,
  13159. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  13160. });
  13161. }
  13162. }
  13163. if (opDayCosts.Count > 0)
  13164. {
  13165. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  13166. }
  13167. }
  13168. if (dayOtherCosts.Count > 0)
  13169. {
  13170. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  13171. foreach (var dc in new_dayOtherCosts)
  13172. {
  13173. var thisCurrency = dc.Key.ToUpper();
  13174. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  13175. if (thisRate == 0.00M) continue;
  13176. foreach (var dcSub in dc)
  13177. {
  13178. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  13179. {
  13180. Id = dcSub.Id,
  13181. Diid = dcSub.Diid,
  13182. Cost = dcSub.Cost,
  13183. SubTotal = dcSub.Cost * thisRate,
  13184. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  13185. });
  13186. }
  13187. }
  13188. if (opDayOtherCosts.Count > 0)
  13189. {
  13190. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  13191. }
  13192. }
  13193. #endregion
  13194. //消息通知
  13195. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13196. //汇率信息记录
  13197. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  13198. return Ok(JsonView(new { parentId = id }));
  13199. }
  13200. /// <summary>
  13201. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  13202. /// </summary>
  13203. /// <returns></returns>
  13204. [HttpPost]
  13205. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13206. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  13207. {
  13208. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13209. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13210. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13211. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13212. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  13213. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  13214. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13215. int id = dto.Id;
  13216. if (id <= 0) //add
  13217. {
  13218. checkboxInfo.CreateUserId = dto.CurrUserId;
  13219. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13220. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  13221. if (add < 1) return Ok(JsonView(false));
  13222. }
  13223. else //update
  13224. {
  13225. ////验证编辑权限
  13226. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13227. //if (!isEdit) return Ok(JsonView(false, msg));
  13228. var upd = await _sqlSugar.Updateable(checkboxInfo)
  13229. .UpdateColumns(x => new
  13230. {
  13231. x.ChoiceOne,
  13232. x.ChoiceTwo,
  13233. x.SumJJC,
  13234. x.SumGWC,
  13235. x.SumTDC,
  13236. x.ChoiceThree,
  13237. x.ChoiceFour,
  13238. x.ChoiceFive,
  13239. x.ChoiceSix,
  13240. x.OtherExpenses_Checked
  13241. })
  13242. .Where(x => x.Id == id)
  13243. .ExecuteCommandAsync();
  13244. if (upd < 1) return Ok(JsonView(false));
  13245. }
  13246. return Ok(JsonView(new { parentId = id }));
  13247. }
  13248. /// <summary>
  13249. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  13250. /// </summary>
  13251. /// <returns></returns>
  13252. [HttpPost]
  13253. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13254. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  13255. {
  13256. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  13257. // if (provinceId < 1) provinceId = 122;
  13258. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  13259. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13260. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13261. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13262. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  13263. var checkboxInfo = new Grp_EnterExitCost()
  13264. {
  13265. Id = id,
  13266. //ProvinceId = provinceId,
  13267. DiId = diId,
  13268. CreateUserId = currUserId,
  13269. LastUpdateUserId = dto.CurrUserId,
  13270. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13271. };
  13272. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  13273. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  13274. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  13275. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  13276. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  13277. if (id <= 0) //add
  13278. {
  13279. checkboxInfo.CreateUserId = dto.CurrUserId;
  13280. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13281. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  13282. if (add < 1) return Ok(JsonView(false));
  13283. }
  13284. else //update
  13285. {
  13286. ////验证编辑权限
  13287. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13288. //if (!isEdit) return Ok(JsonView(false, msg));
  13289. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  13290. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  13291. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  13292. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  13293. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  13294. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  13295. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  13296. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  13297. .Where(x => x.Id == id)
  13298. .ExecuteCommandAsync();
  13299. if (upd < 1) return Ok(JsonView(false));
  13300. }
  13301. return Ok(JsonView(new { parentId = id }));
  13302. }
  13303. /// <summary>
  13304. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  13305. /// </summary>
  13306. /// <returns></returns>
  13307. [HttpPost]
  13308. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13309. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  13310. {
  13311. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13312. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13313. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13314. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13315. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  13316. info.FirstItemRemark = dto.FirstItemRemark;
  13317. info.LastUpdateUserId = dto.CurrUserId;
  13318. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13319. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  13320. int id = dto.Id;
  13321. if (id <= 0) //add
  13322. {
  13323. info.CreateUserId = dto.CurrUserId;
  13324. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13325. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  13326. if (add < 1) return Ok(JsonView(false));
  13327. id = add;
  13328. }
  13329. else //update
  13330. {
  13331. ////验证编辑权限
  13332. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13333. //if (!isEdit) return Ok(JsonView(false, msg));
  13334. var upd = await _sqlSugar.Updateable(info)
  13335. .UpdateColumns(x => new
  13336. {
  13337. x.ChoiceOne,
  13338. x.InsidePay,
  13339. x.VisaRemark,
  13340. x.Visa,
  13341. x.Service,
  13342. x.Safe,
  13343. x.Ticket,
  13344. x.HeSuan,
  13345. x.YiMiao,
  13346. x.FirstItemRemark,
  13347. x.LastUpdateUserId,
  13348. x.LastUpdateTime
  13349. })
  13350. .Where(x => x.Id == id)
  13351. .ExecuteCommandAsync();
  13352. if (upd < 1) return Ok(JsonView(false));
  13353. }
  13354. //消息通知
  13355. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13356. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  13357. }
  13358. /// <summary>
  13359. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  13360. /// </summary>
  13361. /// <returns></returns>
  13362. [HttpPost]
  13363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13364. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  13365. {
  13366. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13367. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13368. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13369. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13370. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  13371. info.DiId = dto.DiId;
  13372. //info.ProvinceId = dto.ProvinceId;
  13373. info.OutsideJJPay = dto.OutsideJJPay;
  13374. info.OutsideGWPay = dto.OutsideGWPay;
  13375. info.OutsideTDPay = dto.OutsideTDPay;
  13376. info.AirJJ = dto.AirJJ;
  13377. info.AirGW = dto.AirGW;
  13378. info.AirTD = dto.AirTD;
  13379. info.CityTranffic = dto.CityTranffic;
  13380. info.CityTranffic1 = dto.CityTranffic1;
  13381. info.CityTranffic2 = dto.CityTranffic2;
  13382. info.TwoItemRemark = dto.TwoItemRemark;
  13383. info.SumJJC = dto.ChoiceTwoJJ;
  13384. info.SumGWC = dto.ChoiceTwoGW;
  13385. info.SumTDC = dto.ChoiceTwoTD;
  13386. info.LastUpdateUserId = dto.CurrUserId;
  13387. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13388. int id = dto.Id;
  13389. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  13390. if (id <= 0) //add i
  13391. {
  13392. info.CreateUserId = dto.CurrUserId;
  13393. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13394. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  13395. if (addId <= 0) return Ok(JsonView(false));
  13396. id = addId;
  13397. }
  13398. else //update
  13399. {
  13400. ////验证编辑权限
  13401. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13402. //if (!isEdit) return Ok(JsonView(false, msg));
  13403. var upd = await _sqlSugar.Updateable(info)
  13404. .UpdateColumns(x => new
  13405. {
  13406. x.SumJJC,
  13407. x.OutsideJJPay,
  13408. x.SumGWC,
  13409. x.OutsideGWPay,
  13410. x.SumTDC,
  13411. x.OutsideTDPay,
  13412. x.AirJJ,
  13413. x.AirGW,
  13414. x.AirTD,
  13415. x.CityTranffic,
  13416. x.CityTranffic1,
  13417. x.CityTranffic2,
  13418. x.TwoItemRemark,
  13419. x.LastUpdateTime,
  13420. x.LastUpdateUserId
  13421. })
  13422. .Where(x => x.Id == id)
  13423. .ExecuteCommandAsync();
  13424. if (upd < 1) return Ok(JsonView(false));
  13425. }
  13426. jjcItemTotal = info.AirJJ + info.CityTranffic;
  13427. gwcItemTotal = info.AirGW + info.CityTranffic1;
  13428. tdcItemTotal = info.AirTD + info.CityTranffic2;
  13429. //消息通知
  13430. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13431. return Ok(JsonView(new
  13432. {
  13433. parentId = id,
  13434. choiceTwoJJ = dto.ChoiceTwoJJ,
  13435. jjcItemTotal = jjcItemTotal,
  13436. choiceTwoGW = dto.ChoiceTwoGW,
  13437. gwcItemTotal = gwcItemTotal,
  13438. choiceTwoTD = dto.ChoiceTwoTD,
  13439. tdcItemTotal = tdcItemTotal
  13440. }));
  13441. }
  13442. /// <summary>
  13443. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  13444. /// </summary>
  13445. /// <returns></returns>
  13446. [HttpPost]
  13447. [ApiExplorerSettings(IgnoreApi = true)]
  13448. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13449. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  13450. {
  13451. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13452. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13453. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13454. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  13455. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  13456. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  13457. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  13458. var infos = infos1.Select(x => new Grp_DayAndCost
  13459. {
  13460. Id = x.Id,
  13461. DiId = dto.DiId,
  13462. Type = dto.FeeType,
  13463. Days = x.Days,
  13464. NationalTravelFeeId = x.NationalTravelFeeId,
  13465. Cost = x.Cost,
  13466. Currency = x.Currency,
  13467. SubTotal = x.SubTotal,
  13468. CreateUserId = dto.CurrUserId
  13469. })
  13470. .ToList();
  13471. var adds = infos.Where(x => x.Id <= 0).ToList();
  13472. var upds = infos.Where(x => x.Id > 0).ToList();
  13473. if (adds.Count > 0)
  13474. {
  13475. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  13476. if (add < 1) return Ok(JsonView(false));
  13477. }
  13478. if (upds.Count > 0)
  13479. {
  13480. var upd = await _sqlSugar.Updateable(adds)
  13481. .UpdateColumns(x => new
  13482. {
  13483. x.Days,
  13484. x.NationalTravelFeeId,
  13485. x.Cost,
  13486. x.Currency,
  13487. x.SubTotal
  13488. })
  13489. .WhereColumns(x => new { x.Id })
  13490. .ExecuteCommandAsync();
  13491. if (upd < 1) return Ok(JsonView(false));
  13492. }
  13493. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  13494. //消息通知
  13495. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  13496. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13497. return Ok(JsonView(new { itemTotal = itemTotal }));
  13498. }
  13499. /// <summary>
  13500. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  13501. /// </summary>
  13502. /// <returns></returns>
  13503. [HttpPost]
  13504. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13505. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  13506. {
  13507. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  13508. int subId = dto.SubId, feeType = dto.FeeType;
  13509. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13510. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13511. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13512. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  13513. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  13514. subInfo.Id = subId;
  13515. subInfo.DiId = dto.DiId;
  13516. if (feeType == 3) subInfo.Type = 1;
  13517. else if (feeType == 4) subInfo.Type = 2;
  13518. else if (feeType == 5) subInfo.Type = 3;
  13519. else if (feeType == 6) subInfo.Type = 4;
  13520. subInfo.CreateUserId = dto.CurrUserId;
  13521. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  13522. if (parentId < 1) return Ok(JsonView(false));
  13523. //子表op
  13524. if (subId < 1)
  13525. {
  13526. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  13527. if (subAdd < 1) return Ok(JsonView(false));
  13528. }
  13529. else
  13530. {
  13531. ////验证编辑权限
  13532. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13533. //if (!isEdit) return Ok(JsonView(false, msg));
  13534. var subUpd = await _sqlSugar.Updateable(subInfo)
  13535. .UpdateColumns(x => new
  13536. {
  13537. x.Days,
  13538. x.NationalTravelFeeId,
  13539. x.Cost,
  13540. x.Currency,
  13541. x.SubTotal
  13542. })
  13543. .WhereColumns(x => new { x.Id })
  13544. .ExecuteCommandAsync();
  13545. if (subUpd < 1) return Ok(JsonView(false));
  13546. }
  13547. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  13548. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  13549. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  13550. }
  13551. /// <summary>
  13552. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  13553. /// </summary>
  13554. /// <returns></returns>
  13555. [HttpPost]
  13556. [ApiExplorerSettings(IgnoreApi = true)]
  13557. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13558. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  13559. {
  13560. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13561. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13562. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13563. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  13564. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  13565. {
  13566. Id = x.Id,
  13567. Diid = dto.DiId,
  13568. SetDataId = x.SetDataId,
  13569. Index = x.Index,
  13570. Cost = x.Cost,
  13571. Currency = x.Currency,
  13572. SubTotal = x.SubTotal,
  13573. CreateUserId = dto.CurrUserId,
  13574. Remark = x.Remark
  13575. }).ToList();
  13576. var adds = infos.Where(x => x.Id <= 0).ToList();
  13577. var upds = infos.Where(x => x.Id > 0).ToList();
  13578. if (adds.Count > 0)
  13579. {
  13580. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  13581. if (add < 1) return Ok(JsonView(false));
  13582. }
  13583. if (upds.Count > 0)
  13584. {
  13585. var upd = await _sqlSugar.Updateable(adds)
  13586. .UpdateColumns(x => new
  13587. {
  13588. x.Index,
  13589. x.SetDataId,
  13590. x.Cost,
  13591. x.Currency,
  13592. x.SubTotal,
  13593. x.Remark
  13594. })
  13595. .WhereColumns(x => new { x.Id })
  13596. .ExecuteCommandAsync();
  13597. if (upd < 1) return Ok(JsonView(false));
  13598. }
  13599. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  13600. //消息通知
  13601. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  13602. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13603. return Ok(JsonView(new { itemTotal = itemTotal }));
  13604. }
  13605. /// <summary>
  13606. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  13607. /// </summary>
  13608. /// <returns></returns>
  13609. [HttpPost]
  13610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13611. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  13612. {
  13613. int subId = dto.SubId;
  13614. int diId = dto.Diid;
  13615. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13616. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13617. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13618. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  13619. subInfo.Id = subId;
  13620. subInfo.Diid = dto.Diid;
  13621. subInfo.CreateUserId = dto.CurrUserId;
  13622. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  13623. if (parentId < 1) return Ok(JsonView(false));
  13624. #region 子表op
  13625. if (subId < 1)//add
  13626. {
  13627. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  13628. if (subAdd < 1) return Ok(JsonView(false));
  13629. }
  13630. else //upd
  13631. {
  13632. ////验证编辑权限
  13633. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  13634. //if (!isEdit) return Ok(JsonView(false, msg));
  13635. var subUpd = await _sqlSugar.Updateable(subInfo)
  13636. .UpdateColumns(x => new
  13637. {
  13638. x.Index,
  13639. x.SetDataId,
  13640. x.Cost,
  13641. x.Currency,
  13642. x.SubTotal,
  13643. x.Remark
  13644. })
  13645. .WhereColumns(x => new { x.Id })
  13646. .ExecuteCommandAsync();
  13647. if (subUpd < 1) return Ok(JsonView(false));
  13648. }
  13649. #endregion
  13650. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  13651. //消息通知
  13652. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  13653. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  13654. }
  13655. /// <summary>
  13656. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  13657. /// </summary>
  13658. /// <returns></returns>
  13659. [HttpPost]
  13660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13661. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  13662. {
  13663. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  13664. if (data.Code != 0)
  13665. {
  13666. return Ok(JsonView(false, data.Msg));
  13667. }
  13668. return Ok(JsonView(true, "操作成功!", data.Data));
  13669. }
  13670. /// <summary>
  13671. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  13672. /// </summary>
  13673. /// <param name="dto"></param>
  13674. /// <returns></returns>
  13675. [HttpPost]
  13676. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  13677. {
  13678. var data = new Grp_DayOtherPrice()
  13679. {
  13680. Id = dto.Id,
  13681. IsDel = 1,
  13682. DeleteUserId = dto.DeleteUserId,
  13683. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  13684. };
  13685. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  13686. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  13687. return Ok(JsonView(false, "删除失败!"));
  13688. }
  13689. #endregion
  13690. #endregion
  13691. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  13692. /// <summary>
  13693. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  13694. /// </summary>
  13695. /// <returns></returns>
  13696. [HttpGet]
  13697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13698. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  13699. {
  13700. var provData = await _groupRepository.ProvinceBasicSource();
  13701. return Ok(JsonView(true, "查询成功!", provData));
  13702. }
  13703. /// <summary>
  13704. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  13705. /// </summary>
  13706. /// <returns></returns>
  13707. [HttpPost]
  13708. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13709. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  13710. {
  13711. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13712. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13713. RefAsync<int> total = 0;
  13714. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  13715. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  13716. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  13717. .Select(x => new
  13718. {
  13719. Id = x.Id,
  13720. DraftName = x.DraftName,
  13721. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  13722. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  13723. .Any()
  13724. })
  13725. .OrderByDescending(x => x.Id)
  13726. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13727. return Ok(JsonView(true, "查询成功!", data, total));
  13728. }
  13729. /// <summary>
  13730. /// 出入境费用-草稿 移动端
  13731. /// 获取币种基础数据(含逻辑处理)
  13732. /// </summary>
  13733. /// <returns></returns>
  13734. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  13735. {
  13736. return await GeneralMethod.EnterExitCostInitRate();
  13737. }
  13738. /// <summary>
  13739. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  13740. /// </summary>
  13741. /// <returns></returns>
  13742. [HttpPost]
  13743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13744. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  13745. {
  13746. //验证城市归属并给默认值
  13747. int provinceId = dto.ProvinceId;
  13748. if (provinceId < 1) provinceId = 122;
  13749. var dataSource = await _sqlSugar
  13750. .Queryable<Sys_SetData>()
  13751. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  13752. .ToListAsync();
  13753. //三公费用-Word明细类型
  13754. var wordTypeData = dataSource.Where(it => it.STid == 72)
  13755. .Select(x => new SetDataInfoView
  13756. {
  13757. Id = x.Id,
  13758. Name = x.Name,
  13759. Remark = x.Remark
  13760. })
  13761. .ToList();
  13762. //三公费用-Excel明细类型
  13763. var excelTypeData = dataSource.Where(it => it.STid == 73)
  13764. .Select(x => new SetDataInfoView
  13765. {
  13766. Id = x.Id,
  13767. Name = x.Name,
  13768. Remark = x.Remark
  13769. })
  13770. .ToList();
  13771. //默认币种显示
  13772. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  13773. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  13774. return Ok(JsonView(true, "查询成功!", new
  13775. {
  13776. WordTypeData = wordTypeData,
  13777. ExcelTypeData = excelTypeData,
  13778. CurrencyInit = _currencyInfos,
  13779. viewPermissionData = viewPermissionData
  13780. }));
  13781. }
  13782. /// <summary>
  13783. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  13784. /// </summary>
  13785. /// <returns></returns>
  13786. [HttpPost]
  13787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13788. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  13789. {
  13790. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13791. RefAsync<int> total = 0;
  13792. int diId = 0;
  13793. var status = int.TryParse(dto.GroupName, out diId);
  13794. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  13795. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  13796. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  13797. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  13798. .OrderByDescending(x => x.VisitStartDate)
  13799. .Select(x => new
  13800. {
  13801. Id = x.Id,
  13802. GroupName = x.TeamName
  13803. })
  13804. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13805. return Ok(JsonView(true, "查询成功!", data, total));
  13806. }
  13807. /// <summary>
  13808. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  13809. /// </summary>
  13810. /// <returns></returns>
  13811. [HttpPost]
  13812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13813. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  13814. {
  13815. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13816. RefAsync<int> total = 0;
  13817. var data = await _sqlSugar.Queryable<Sys_SetData>()
  13818. .Where(x => x.IsDel == 0 && x.STid == 66)
  13819. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  13820. .Select(x => new
  13821. {
  13822. id = x.Id,
  13823. name = x.Name,
  13824. remark = x.Remark,
  13825. })
  13826. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13827. return Ok(JsonView(true, "查询成功!", data, total));
  13828. }
  13829. /// <summary>
  13830. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  13831. /// </summary>
  13832. /// <returns></returns>
  13833. [HttpPost]
  13834. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13835. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  13836. {
  13837. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13838. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  13839. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  13840. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  13841. var groupOtherRateData = groupRateData.TeamRates;
  13842. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  13843. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  13844. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  13845. groupOtherRateData = groupOtherRateData
  13846. .Select(x => new TeamRateDescAddCurrencyIdView
  13847. {
  13848. CurrencyId = x.CurrencyId,
  13849. CurrencyName = x.CurrencyName,
  13850. CurrencyCode = x.CurrencyCode,
  13851. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  13852. }).ToList();
  13853. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  13854. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  13855. }
  13856. /// <summary>
  13857. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  13858. /// </summary>
  13859. /// <returns></returns>
  13860. [HttpPost]
  13861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13862. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  13863. {
  13864. int portType = dto.PortType;
  13865. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13866. var tipsData = new List<int>() { 1, 2, 3 };
  13867. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  13868. if (dto.TipsType == 1)
  13869. {
  13870. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  13871. }
  13872. else if (dto.TipsType == 2)
  13873. {
  13874. if (portType == 2)
  13875. {
  13876. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  13877. }
  13878. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  13879. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  13880. .Select(x => x.NationalTravelFeeId)
  13881. .Distinct()
  13882. .ToListAsync();
  13883. if (portType == 2)
  13884. {
  13885. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  13886. }
  13887. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  13888. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  13889. .Select(x => x.Country)
  13890. .Distinct()
  13891. .ToArrayAsync();
  13892. if (portType == 2)
  13893. {
  13894. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  13895. }
  13896. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  13897. return Ok(JsonView(true, "查询成功!", new
  13898. {
  13899. totalAmt = totalAmt,
  13900. remark = remark
  13901. }));
  13902. }
  13903. else if (dto.TipsType == 3)
  13904. {
  13905. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  13906. }
  13907. return Ok(JsonView(false));
  13908. }
  13909. /// <summary>
  13910. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  13911. /// </summary>
  13912. /// <returns></returns>
  13913. [HttpPost]
  13914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13915. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  13916. {
  13917. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  13918. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13919. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13920. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  13921. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  13922. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  13923. var info = new Grp_EnterExitCostDraft()
  13924. {
  13925. ProvinceId = dto.ProvinceId,
  13926. DraftName = dto.DraftName,
  13927. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  13928. CreateUserId = dto.CurrUserId
  13929. };
  13930. _sqlSugar.BeginTran();
  13931. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  13932. if (draftId < 1)
  13933. {
  13934. _sqlSugar.RollbackTran();
  13935. return Ok(JsonView(false, "草稿创建失败!"));
  13936. }
  13937. //添加默认权限
  13938. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  13939. _sqlSugar.CommitTran();
  13940. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  13941. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  13942. mobileInfo.Id = draftId;
  13943. mobileInfo.DraftName = dto.DraftName;
  13944. mobileInfo.Currencys = rateInfos;
  13945. mobileInfo.IsAssignPerm = assignPerm;
  13946. return Ok(JsonView(mobileInfo));
  13947. }
  13948. /// <summary>
  13949. /// 出入境费用-草稿-移动端 查看编辑提示消息
  13950. /// </summary>
  13951. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  13952. /// <summary>
  13953. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  13954. /// </summary>
  13955. /// <returns></returns>
  13956. [HttpPost]
  13957. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13958. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  13959. {
  13960. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13961. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13962. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  13963. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  13964. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  13965. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  13966. //验证查看编辑权限
  13967. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  13968. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  13969. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  13970. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  13971. mobileInfo.IsAssignPerm = assignPerm;
  13972. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  13973. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  13974. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  13975. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  13976. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  13977. {
  13978. ParentId = dac.ParentId,
  13979. SubId = dac.Id,
  13980. Type = dac.Type,
  13981. Days = dac.Days,
  13982. NationalTravelFeeId = dac.NationalTravelFeeId,
  13983. Arae = $"{ntf.Country}-{ntf.City}",
  13984. Cost = dac.Cost,
  13985. Currency = dac.Currency,
  13986. CurrencyName = sd.Name,
  13987. SubTotal = dac.SubTotal,
  13988. })
  13989. .ToList();
  13990. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  13991. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  13992. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  13993. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  13994. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  13995. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  13996. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  13997. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  13998. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  13999. //其他款项
  14000. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  14001. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  14002. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  14003. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  14004. .OrderBy((dop, sd1, sd2) => dop.Index)
  14005. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  14006. {
  14007. ParentId = dop.ParentId,
  14008. SubId = dop.Id,
  14009. Index = dop.Index,
  14010. SetDataId = dop.SetDataId,
  14011. SetDataName = sd1.Name,
  14012. Cost = dop.Cost,
  14013. Currency = dop.Currency,
  14014. CurrencyName = sd2.Remark,
  14015. SubTotal = dop.SubTotal,
  14016. Remark = dop.Remark,
  14017. })
  14018. .ToArray();
  14019. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  14020. return Ok(mobileInfo);
  14021. }
  14022. /// <summary>
  14023. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  14024. /// </summary>
  14025. /// <returns></returns>
  14026. [HttpPost]
  14027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14028. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  14029. {
  14030. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14031. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14032. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14033. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  14034. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  14035. //验证查看编辑权限
  14036. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14037. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14038. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  14039. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  14040. var subType = dto.SubType;
  14041. if (subType == 1) //1:境内费用
  14042. {
  14043. var oneData = new ChoiceOneMobileSubInfoView()
  14044. {
  14045. Id = eecInfo.Id,
  14046. ChoiceOne = eecInfo.ChoiceOne,
  14047. ChoiceOneTotalCost = eecInfo.InsidePay,
  14048. Visa = eecInfo.Visa,
  14049. VisaRemark = eecInfo.VisaRemark,
  14050. YiMiao = eecInfo.YiMiao,
  14051. HeSuan = eecInfo.HeSuan,
  14052. Service = eecInfo.Service,
  14053. Ticket = eecInfo.Ticket,
  14054. Safe = eecInfo.Safe,
  14055. FirstItemRemark = eecInfo.FirstItemRemark
  14056. };
  14057. return Ok(JsonView(oneData));
  14058. }
  14059. else if (subType == 2) //2:国际旅费
  14060. {
  14061. var twoData = new ChoiceTwoMobileSubInfoView()
  14062. {
  14063. Id = eecInfo.Id,
  14064. ChoiceTwoJJ = eecInfo.SumJJC,
  14065. OutsideJJPay = eecInfo.OutsideJJPay,
  14066. ChoiceTwoGW = eecInfo.SumGWC,
  14067. OutsideGWPay = eecInfo.OutsideGWPay,
  14068. ChoiceTwoTD = eecInfo.SumTDC,
  14069. OutsideTDPay = eecInfo.OutsideTDPay,
  14070. AirJJ = eecInfo.AirJJ,
  14071. AirGW = eecInfo.AirGW,
  14072. AirTD = eecInfo.AirTD,
  14073. CityTranffic = eecInfo.CityTranffic,
  14074. TwoItemRemark = eecInfo.TwoItemRemark
  14075. };
  14076. return Ok(JsonView(twoData));
  14077. }
  14078. else if (subType == 3) //3:住宿费
  14079. {
  14080. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14081. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14082. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14083. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  14084. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14085. {
  14086. ParentId = dac.ParentId,
  14087. SubId = dac.Id,
  14088. Type = dac.Type,
  14089. Days = dac.Days,
  14090. NationalTravelFeeId = dac.NationalTravelFeeId,
  14091. Arae = $"{ntf.Country}-{ntf.City}",
  14092. Cost = dac.Cost,
  14093. Currency = dac.Currency,
  14094. CurrencyName = sd.Name,
  14095. SubTotal = dac.SubTotal,
  14096. })
  14097. .ToArray();
  14098. var data = new ChoiceDraftMobileSubInfo3To6View()
  14099. {
  14100. ParentId = eecInfo.Id,
  14101. Choice = eecInfo.ChoiceThree,
  14102. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14103. Details = dayAndCostDatas
  14104. };
  14105. return Ok(JsonView(data));
  14106. }
  14107. else if (subType == 4) //4:伙食费
  14108. {
  14109. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14110. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14111. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14112. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  14113. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14114. {
  14115. ParentId = dac.ParentId,
  14116. SubId = dac.Id,
  14117. Type = dac.Type,
  14118. Days = dac.Days,
  14119. NationalTravelFeeId = dac.NationalTravelFeeId,
  14120. Arae = $"{ntf.Country}-{ntf.City}",
  14121. Cost = dac.Cost,
  14122. Currency = dac.Currency,
  14123. CurrencyName = sd.Name,
  14124. SubTotal = dac.SubTotal,
  14125. })
  14126. .ToArray();
  14127. var data = new ChoiceDraftMobileSubInfo3To6View()
  14128. {
  14129. ParentId = eecInfo.Id,
  14130. Choice = eecInfo.ChoiceFour,
  14131. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14132. Details = dayAndCostDatas
  14133. };
  14134. return Ok(JsonView(data));
  14135. }
  14136. else if (subType == 5) //5:公杂费
  14137. {
  14138. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14139. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14140. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14141. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  14142. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14143. {
  14144. ParentId = dac.ParentId,
  14145. SubId = dac.Id,
  14146. Type = dac.Type,
  14147. Days = dac.Days,
  14148. NationalTravelFeeId = dac.NationalTravelFeeId,
  14149. Arae = $"{ntf.Country}-{ntf.City}",
  14150. Cost = dac.Cost,
  14151. Currency = dac.Currency,
  14152. CurrencyName = sd.Name,
  14153. SubTotal = dac.SubTotal,
  14154. })
  14155. .ToArray();
  14156. var data = new ChoiceDraftMobileSubInfo3To6View()
  14157. {
  14158. ParentId = eecInfo.Id,
  14159. Choice = eecInfo.ChoiceFive,
  14160. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14161. Details = dayAndCostDatas
  14162. };
  14163. return Ok(JsonView(data));
  14164. }
  14165. else if (subType == 6) //6:培训费
  14166. {
  14167. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14168. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14169. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14170. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  14171. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14172. {
  14173. ParentId = dac.ParentId,
  14174. SubId = dac.Id,
  14175. Type = dac.Type,
  14176. Days = dac.Days,
  14177. NationalTravelFeeId = dac.NationalTravelFeeId,
  14178. Arae = $"{ntf.Country}-{ntf.City}",
  14179. Cost = dac.Cost,
  14180. Currency = dac.Currency,
  14181. CurrencyName = sd.Name,
  14182. SubTotal = dac.SubTotal,
  14183. })
  14184. .ToArray();
  14185. var data = new ChoiceDraftMobileSubInfo3To6View()
  14186. {
  14187. ParentId = eecInfo.Id,
  14188. Choice = eecInfo.ChoiceSix,
  14189. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14190. Details = dayAndCostDatas
  14191. };
  14192. return Ok(JsonView(data));
  14193. }
  14194. else if (subType == 7) //7:其他
  14195. {
  14196. //其他款项
  14197. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  14198. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  14199. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  14200. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  14201. .OrderBy((dop, sd1, sd2) => dop.Index)
  14202. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  14203. {
  14204. ParentId = dop.ParentId,
  14205. SubId = dop.Id,
  14206. Index = dop.Index,
  14207. SetDataId = dop.SetDataId,
  14208. SetDataName = sd1.Name,
  14209. Cost = dop.Cost,
  14210. Currency = dop.Currency,
  14211. CurrencyName = sd2.Name,
  14212. SubTotal = dop.SubTotal,
  14213. Remark = dop.Remark,
  14214. })
  14215. .ToArray();
  14216. var data = new ChoiceSevenDraftMobileSubInfoView()
  14217. {
  14218. ParentId = eecInfo.Id,
  14219. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  14220. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  14221. Details = otherData
  14222. };
  14223. return Ok(JsonView(data));
  14224. }
  14225. return Ok(JsonView(false));
  14226. }
  14227. #region op
  14228. ///// <summary>
  14229. ///// 移动端更新费用消息通知
  14230. ///// </summary>
  14231. ///// <param name="draftId"></param>
  14232. ///// <param name="id"></param>
  14233. ///// <param name="currUserId"></param>
  14234. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  14235. //{
  14236. // try
  14237. // {
  14238. // ////生成默认文件pdf并且通知人员
  14239. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  14240. // //{
  14241. // // DiId = draftId,
  14242. // // ExportType = 1,
  14243. // // SubTypeId = 1005
  14244. // //}, "pdf");
  14245. // ////发送通知
  14246. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  14247. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  14248. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  14249. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  14250. // ////汇率信息记录
  14251. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  14252. // }
  14253. // catch (Exception ex)
  14254. // {
  14255. // //记录日志
  14256. // throw;
  14257. // }
  14258. //}
  14259. /// <summary>
  14260. /// 验证出入境费用数据是否存在
  14261. /// 不存在添加
  14262. /// </summary>
  14263. /// <param name="draftId"></param>
  14264. /// <param name="currUserId"></param>
  14265. /// <returns></returns>
  14266. /// <exception cref="CustomException"></exception>
  14267. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  14268. {
  14269. var parentId = 0;
  14270. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  14271. if (info != null) parentId = info.Id;
  14272. else
  14273. {
  14274. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  14275. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  14276. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  14277. parentId = addId;
  14278. }
  14279. return parentId;
  14280. }
  14281. /// <summary>
  14282. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  14283. /// </summary>
  14284. /// <returns></returns>
  14285. [HttpPost]
  14286. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14287. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  14288. {
  14289. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14290. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14291. //验证查看权限
  14292. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14293. if (!isView) return Ok(JsonView(false, _viewPermStr));
  14294. var userIds = await _sqlSugar
  14295. .Queryable<Grp_EnterExitCostDraftPermission>()
  14296. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  14297. .Select(x => x.UserId)
  14298. .ToArrayAsync();
  14299. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  14300. var perUsersView = new List<dynamic>();
  14301. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  14302. var viewPermissionData = new List<PermissionViewUserview>();
  14303. if (feeBasePerm.Any())
  14304. {
  14305. foreach (var item in feeBasePerm)
  14306. {
  14307. if (item.Users.Any())
  14308. {
  14309. viewPermissionData.AddRange(item.Users);
  14310. }
  14311. }
  14312. }
  14313. foreach (var item in perUsers)
  14314. {
  14315. bool isView1 = false;
  14316. if (userIds.Any(x => x == item.Id)) isView1 = true;
  14317. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  14318. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  14319. }
  14320. return Ok(JsonView(perUsersView));
  14321. }
  14322. /// <summary>
  14323. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  14324. /// </summary>
  14325. /// <returns></returns>
  14326. [HttpPost]
  14327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14328. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  14329. {
  14330. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14331. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14332. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  14333. //验证查看编辑权限
  14334. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14335. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14336. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  14337. foreach (var userId in dto.UserIds)
  14338. {
  14339. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  14340. }
  14341. if (permissions.Any())
  14342. {
  14343. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  14344. {
  14345. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  14346. }
  14347. _sqlSugar.BeginTran();
  14348. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  14349. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  14350. if (result < 1)
  14351. {
  14352. _sqlSugar.RollbackTran();
  14353. return Ok(JsonView(false));
  14354. }
  14355. _sqlSugar.CommitTran();
  14356. return Ok(JsonView(true));
  14357. }
  14358. return Ok(JsonView(false));
  14359. }
  14360. /// <summary>
  14361. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  14362. /// </summary>
  14363. /// <returns></returns>
  14364. [HttpPost]
  14365. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14366. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  14367. {
  14368. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14369. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14370. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14371. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  14372. int id = dto.DraftId;
  14373. if (id <= 0) //add
  14374. {
  14375. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14376. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  14377. if (add < 1) return Ok(JsonView(false));
  14378. id = add;
  14379. }
  14380. else //update
  14381. {
  14382. //验证查看编辑权限
  14383. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14384. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14385. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  14386. if (upd < 1) return Ok(JsonView(false));
  14387. }
  14388. return Ok(JsonView(new { parentId = id }));
  14389. }
  14390. /// <summary>
  14391. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  14392. /// </summary>
  14393. /// <returns></returns>
  14394. [HttpPost]
  14395. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14396. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  14397. {
  14398. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14399. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14400. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14401. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  14402. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  14403. int id = dto.DraftId;
  14404. if (id <= 0) //add
  14405. {
  14406. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14407. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  14408. if (add < 1) return Ok(JsonView(false));
  14409. id = add;
  14410. }
  14411. else //update
  14412. {
  14413. //验证查看编辑权限
  14414. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14415. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14416. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  14417. if (upd < 1) return Ok(JsonView(false));
  14418. }
  14419. #region 汇率变更时更改币种相关费用
  14420. var opDayCosts = new List<Grp_DayAndCostDraft>();
  14421. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  14422. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  14423. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14424. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  14425. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  14426. .Select((dac, sd) => new
  14427. {
  14428. dac.Id,
  14429. dac.ParentId,
  14430. CurrencyCode = sd.Name,
  14431. dac.Cost
  14432. })
  14433. .ToList();
  14434. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  14435. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  14436. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  14437. .Select((dop, sd) => new
  14438. {
  14439. dop.Id,
  14440. dop.ParentId,
  14441. CurrencyCode = sd.Name,
  14442. dop.Cost
  14443. })
  14444. .ToList();
  14445. if (dayCosts.Count > 0)
  14446. {
  14447. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  14448. foreach (var dc in new_dayCosts)
  14449. {
  14450. var thisCurrency = dc.Key.ToUpper();
  14451. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  14452. if (thisRate == 0.00M) continue;
  14453. foreach (var dcSub in dc)
  14454. {
  14455. opDayCosts.Add(new Grp_DayAndCostDraft()
  14456. {
  14457. Id = dcSub.Id,
  14458. ParentId = dcSub.ParentId,
  14459. Cost = dcSub.Cost,
  14460. SubTotal = dcSub.Cost * thisRate,
  14461. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  14462. });
  14463. }
  14464. }
  14465. if (opDayCosts.Count > 0)
  14466. {
  14467. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  14468. }
  14469. }
  14470. if (dayOtherCosts.Count > 0)
  14471. {
  14472. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  14473. foreach (var dc in new_dayOtherCosts)
  14474. {
  14475. var thisCurrency = dc.Key.ToUpper();
  14476. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  14477. if (thisRate == 0.00M) continue;
  14478. foreach (var dcSub in dc)
  14479. {
  14480. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  14481. {
  14482. Id = dcSub.Id,
  14483. ParentId = dcSub.ParentId,
  14484. Cost = dcSub.Cost,
  14485. SubTotal = dcSub.Cost * thisRate,
  14486. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  14487. });
  14488. }
  14489. }
  14490. if (opDayOtherCosts.Count > 0)
  14491. {
  14492. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  14493. }
  14494. }
  14495. #endregion
  14496. ////消息通知
  14497. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14498. ////汇率信息记录
  14499. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  14500. return Ok(JsonView(new { parentId = id }));
  14501. }
  14502. /// <summary>
  14503. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  14504. /// </summary>
  14505. /// <returns></returns>
  14506. [HttpPost]
  14507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14508. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  14509. {
  14510. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14511. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14512. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14513. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  14514. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14515. int id = dto.DraftId;
  14516. if (id <= 0) //add
  14517. {
  14518. checkboxInfo.ProvinceId = dto.ProvinceId;
  14519. checkboxInfo.CreateUserId = dto.CurrUserId;
  14520. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  14521. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  14522. if (add < 1) return Ok(JsonView(false));
  14523. }
  14524. else //update
  14525. {
  14526. var upd = await _sqlSugar.Updateable(checkboxInfo)
  14527. .UpdateColumns(x => new
  14528. {
  14529. x.ChoiceOne,
  14530. x.ChoiceTwo,
  14531. x.SumJJC,
  14532. x.SumGWC,
  14533. x.SumTDC,
  14534. x.ChoiceThree,
  14535. x.ChoiceFour,
  14536. x.ChoiceFive,
  14537. x.ChoiceSix,
  14538. x.OtherExpenses_Checked
  14539. })
  14540. .Where(x => x.Id == id)
  14541. .ExecuteCommandAsync();
  14542. if (upd < 1) return Ok(JsonView(false));
  14543. }
  14544. return Ok(JsonView(new { parentId = id }));
  14545. }
  14546. /// <summary>
  14547. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  14548. /// </summary>
  14549. /// <returns></returns>
  14550. [HttpPost]
  14551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14552. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  14553. {
  14554. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  14555. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  14556. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14557. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14558. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14559. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  14560. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14561. var checkboxInfo = new Grp_EnterExitCostDraft()
  14562. {
  14563. Id = draftId,
  14564. ProvinceId = dto.ProvinceId,
  14565. CreateUserId = currUserId
  14566. };
  14567. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  14568. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  14569. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  14570. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  14571. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  14572. if (draftId <= 0) //add
  14573. {
  14574. checkboxInfo.CreateUserId = dto.CurrUserId;
  14575. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  14576. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  14577. if (add < 1) return Ok(JsonView(false));
  14578. }
  14579. else //update
  14580. {
  14581. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  14582. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  14583. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  14584. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  14585. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  14586. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  14587. .Where(x => x.Id == draftId)
  14588. .ExecuteCommandAsync();
  14589. if (upd < 1) return Ok(JsonView(false));
  14590. }
  14591. return Ok(JsonView(new { parentId = draftId }));
  14592. }
  14593. /// <summary>
  14594. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  14595. /// </summary>
  14596. /// <returns></returns>
  14597. [HttpPost]
  14598. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14599. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  14600. {
  14601. int id = dto.DraftId, currUserId = dto.CurrUserId;
  14602. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14603. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  14604. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14605. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14606. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  14607. info.ProvinceId = dto.ProvinceId;
  14608. info.FirstItemRemark = dto.FirstItemRemark;
  14609. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  14610. if (id <= 0) //add
  14611. {
  14612. info.CreateUserId = dto.CurrUserId;
  14613. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  14614. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  14615. if (add < 1) return Ok(JsonView(false));
  14616. id = add;
  14617. }
  14618. else //update
  14619. {
  14620. var upd = await _sqlSugar.Updateable(info)
  14621. .UpdateColumns(x => new
  14622. {
  14623. x.ChoiceOne,
  14624. x.InsidePay,
  14625. x.VisaRemark,
  14626. x.Visa,
  14627. x.Service,
  14628. x.Safe,
  14629. x.Ticket,
  14630. x.HeSuan,
  14631. x.YiMiao,
  14632. x.FirstItemRemark
  14633. })
  14634. .Where(x => x.Id == id)
  14635. .ExecuteCommandAsync();
  14636. if (upd < 1) return Ok(JsonView(false));
  14637. }
  14638. ////消息通知
  14639. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14640. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  14641. }
  14642. /// <summary>
  14643. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  14644. /// </summary>
  14645. /// <returns></returns>
  14646. [HttpPost]
  14647. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14648. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  14649. {
  14650. int id = dto.DraftId;
  14651. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14652. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  14653. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14654. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14655. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  14656. info.ProvinceId = dto.ProvinceId;
  14657. info.OutsideJJPay = dto.OutsideJJPay;
  14658. info.OutsideGWPay = dto.OutsideGWPay;
  14659. info.OutsideTDPay = dto.OutsideTDPay;
  14660. info.AirJJ = dto.AirJJ;
  14661. info.AirGW = dto.AirGW;
  14662. info.AirTD = dto.AirTD;
  14663. info.CityTranffic = dto.CityTranffic;
  14664. info.TwoItemRemark = dto.TwoItemRemark;
  14665. info.SumJJC = dto.ChoiceTwoJJ;
  14666. info.SumGWC = dto.ChoiceTwoGW;
  14667. info.SumTDC = dto.ChoiceTwoTD;
  14668. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  14669. if (id <= 0) //add
  14670. {
  14671. info.CreateUserId = dto.CurrUserId;
  14672. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  14673. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  14674. if (addId <= 0) return Ok(JsonView(false));
  14675. id = addId;
  14676. }
  14677. else //update
  14678. {
  14679. var upd = await _sqlSugar.Updateable(info)
  14680. .UpdateColumns(x => new
  14681. {
  14682. x.SumJJC,
  14683. x.OutsideJJPay,
  14684. x.SumGWC,
  14685. x.OutsideGWPay,
  14686. x.SumTDC,
  14687. x.OutsideTDPay,
  14688. x.AirJJ,
  14689. x.AirGW,
  14690. x.AirTD,
  14691. x.CityTranffic,
  14692. x.TwoItemRemark
  14693. })
  14694. .Where(x => x.Id == id)
  14695. .ExecuteCommandAsync();
  14696. if (upd < 1) return Ok(JsonView(false));
  14697. }
  14698. jjcItemTotal = info.AirJJ + info.CityTranffic;
  14699. gwcItemTotal = info.AirGW + info.CityTranffic;
  14700. tdcItemTotal = info.AirTD + info.CityTranffic;
  14701. ////消息通知
  14702. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14703. return Ok(JsonView(new
  14704. {
  14705. parentId = id,
  14706. choiceTwoJJ = dto.ChoiceTwoJJ,
  14707. jjcItemTotal = jjcItemTotal,
  14708. choiceTwoGW = dto.ChoiceTwoGW,
  14709. gwcItemTotal = gwcItemTotal,
  14710. choiceTwoTD = dto.ChoiceTwoTD,
  14711. tdcItemTotal = tdcItemTotal
  14712. }));
  14713. }
  14714. /// <summary>
  14715. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  14716. /// </summary>
  14717. /// <returns></returns>
  14718. [HttpPost]
  14719. [ApiExplorerSettings(IgnoreApi = true)]
  14720. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14721. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  14722. {
  14723. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14724. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14725. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14726. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  14727. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  14728. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  14729. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  14730. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  14731. {
  14732. Id = x.Id,
  14733. ParentId = dto.DraftId,
  14734. Type = dto.FeeType,
  14735. Days = x.Days,
  14736. NationalTravelFeeId = x.NationalTravelFeeId,
  14737. Cost = x.Cost,
  14738. Currency = x.Currency,
  14739. SubTotal = x.SubTotal,
  14740. CreateUserId = dto.CurrUserId
  14741. })
  14742. .ToList();
  14743. var adds = infos.Where(x => x.Id <= 0).ToList();
  14744. var upds = infos.Where(x => x.Id > 0).ToList();
  14745. if (adds.Count > 0)
  14746. {
  14747. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  14748. if (add < 1) return Ok(JsonView(false));
  14749. }
  14750. if (upds.Count > 0)
  14751. {
  14752. var upd = await _sqlSugar.Updateable(adds)
  14753. .UpdateColumns(x => new
  14754. {
  14755. x.Days,
  14756. x.NationalTravelFeeId,
  14757. x.Cost,
  14758. x.Currency,
  14759. x.SubTotal
  14760. })
  14761. .WhereColumns(x => new { x.Id })
  14762. .ExecuteCommandAsync();
  14763. if (upd < 1) return Ok(JsonView(false));
  14764. }
  14765. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  14766. ////消息通知
  14767. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  14768. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14769. return Ok(JsonView(new { itemTotal = itemTotal }));
  14770. }
  14771. /// <summary>
  14772. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  14773. /// </summary>
  14774. /// <returns></returns>
  14775. [HttpPost]
  14776. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14777. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  14778. {
  14779. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  14780. int subId = dto.SubId, feeType = dto.FeeType;
  14781. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14782. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14783. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14784. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  14785. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  14786. subInfo.Id = subId;
  14787. subInfo.ParentId = dto.DraftId;
  14788. if (feeType == 3) subInfo.Type = 1;
  14789. else if (feeType == 4) subInfo.Type = 2;
  14790. else if (feeType == 5) subInfo.Type = 3;
  14791. else if (feeType == 6) subInfo.Type = 4;
  14792. subInfo.CreateUserId = dto.CurrUserId;
  14793. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  14794. if (parentId < 1) return Ok(JsonView(false));
  14795. //子表op
  14796. if (subId < 1)
  14797. {
  14798. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  14799. if (subAdd < 1) return Ok(JsonView(false));
  14800. }
  14801. else
  14802. {
  14803. var subUpd = await _sqlSugar.Updateable(subInfo)
  14804. .UpdateColumns(x => new
  14805. {
  14806. x.Days,
  14807. x.NationalTravelFeeId,
  14808. x.Cost,
  14809. x.Currency,
  14810. x.SubTotal
  14811. })
  14812. .WhereColumns(x => new { x.Id })
  14813. .ExecuteCommandAsync();
  14814. if (subUpd < 1) return Ok(JsonView(false));
  14815. }
  14816. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  14817. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  14818. }
  14819. /// <summary>
  14820. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  14821. /// </summary>
  14822. /// <returns></returns>
  14823. [HttpPost]
  14824. [ApiExplorerSettings(IgnoreApi = true)]
  14825. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14826. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  14827. {
  14828. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14829. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14830. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14831. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  14832. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  14833. {
  14834. Id = x.Id,
  14835. ParentId = dto.DraftId,
  14836. SetDataId = x.SetDataId,
  14837. Index = x.Index,
  14838. Cost = x.Cost,
  14839. Currency = x.Currency,
  14840. SubTotal = x.SubTotal,
  14841. CreateUserId = dto.CurrUserId,
  14842. Remark = x.Remark
  14843. }).ToList();
  14844. var adds = infos.Where(x => x.Id <= 0).ToList();
  14845. var upds = infos.Where(x => x.Id > 0).ToList();
  14846. if (adds.Count > 0)
  14847. {
  14848. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  14849. if (add < 1) return Ok(JsonView(false));
  14850. }
  14851. if (upds.Count > 0)
  14852. {
  14853. var upd = await _sqlSugar.Updateable(adds)
  14854. .UpdateColumns(x => new
  14855. {
  14856. x.Index,
  14857. x.SetDataId,
  14858. x.Cost,
  14859. x.Currency,
  14860. x.SubTotal,
  14861. x.Remark
  14862. })
  14863. .WhereColumns(x => new { x.Id })
  14864. .ExecuteCommandAsync();
  14865. if (upd < 1) return Ok(JsonView(false));
  14866. }
  14867. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  14868. //消息通知
  14869. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  14870. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14871. return Ok(JsonView(new { itemTotal = itemTotal }));
  14872. }
  14873. /// <summary>
  14874. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  14875. /// </summary>
  14876. /// <returns></returns>
  14877. [HttpPost]
  14878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14879. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  14880. {
  14881. int subId = dto.SubId, id = dto.DraftId;
  14882. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14883. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  14884. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14885. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  14886. subInfo.Id = subId;
  14887. subInfo.ParentId = id;
  14888. subInfo.CreateUserId = dto.CurrUserId;
  14889. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  14890. if (parentId < 1) return Ok(JsonView(false));
  14891. #region 子表op
  14892. if (subId < 1)//add
  14893. {
  14894. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  14895. if (subAdd < 1) return Ok(JsonView(false));
  14896. }
  14897. else //upd
  14898. {
  14899. var subUpd = await _sqlSugar.Updateable(subInfo)
  14900. .UpdateColumns(x => new
  14901. {
  14902. x.Index,
  14903. x.SetDataId,
  14904. x.Cost,
  14905. x.Currency,
  14906. x.SubTotal,
  14907. x.Remark
  14908. })
  14909. .WhereColumns(x => new { x.Id })
  14910. .ExecuteCommandAsync();
  14911. if (subUpd < 1) return Ok(JsonView(false));
  14912. }
  14913. #endregion
  14914. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  14915. ////消息通知
  14916. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  14917. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  14918. }
  14919. /// <summary>
  14920. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  14921. /// </summary>
  14922. /// <returns></returns>
  14923. [HttpPost]
  14924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14925. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  14926. {
  14927. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  14928. if (data.Code != 0)
  14929. {
  14930. return Ok(JsonView(false, data.Msg));
  14931. }
  14932. return Ok(JsonView(true, "操作成功!", data.Data));
  14933. }
  14934. /// <summary>
  14935. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  14936. /// </summary>
  14937. /// <param name="dto"></param>
  14938. /// <returns></returns>
  14939. [HttpPost]
  14940. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  14941. {
  14942. var data = new Grp_DayOtherPriceDraft()
  14943. {
  14944. Id = dto.Id,
  14945. IsDel = 1,
  14946. DeleteUserId = dto.DeleteUserId,
  14947. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  14948. };
  14949. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  14950. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  14951. return Ok(JsonView(false, "删除失败!"));
  14952. }
  14953. #endregion
  14954. #endregion
  14955. #region 团组经理模块 出入境费用报价表
  14956. /// <summary>
  14957. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  14958. /// </summary>
  14959. /// <returns></returns>
  14960. [HttpPost]
  14961. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14962. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  14963. {
  14964. var initRates = await GeneralMethod.EnterExitCostInitRate();
  14965. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  14966. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  14967. initRates.Insert(0, cnyInfo);
  14968. liveRates.Insert(0, cnyInfo);
  14969. return Ok(JsonView(true, "查询成功!", new
  14970. {
  14971. InitRates = initRates,
  14972. LiveRates = liveRates
  14973. }));
  14974. }
  14975. /// <summary>
  14976. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  14977. /// </summary>
  14978. /// <returns></returns>
  14979. [HttpPost]
  14980. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14981. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  14982. {
  14983. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  14984. }
  14985. /// <summary>
  14986. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  14987. /// </summary>
  14988. /// <returns></returns>
  14989. [HttpPost]
  14990. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14991. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  14992. {
  14993. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  14994. }
  14995. /// <summary>
  14996. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  14997. /// </summary>
  14998. /// <returns></returns>
  14999. [HttpPost]
  15000. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15001. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  15002. {
  15003. int groupId = dto.DiId,
  15004. currUserId = dto.CurrUserId;
  15005. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  15006. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  15007. //验证报价数据是否存在
  15008. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  15009. if (isNull != null)
  15010. {
  15011. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  15012. if (!info1.Rates.Any())
  15013. {
  15014. var rates = await GeneralMethod.EnterExitCostInitRate();
  15015. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15016. info1.Rates = rates.ToArray();
  15017. }
  15018. return Ok(JsonView(info1));
  15019. }
  15020. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  15021. result.GroupId = groupId;
  15022. //处理报价名称
  15023. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  15024. if (groupInfo != null)
  15025. {
  15026. var visitCountry = groupInfo.VisitCountry;
  15027. if (!string.IsNullOrEmpty(visitCountry))
  15028. {
  15029. string quoteName = string.Empty;
  15030. if (visitCountry.Contains("|"))
  15031. {
  15032. var countrys = visitCountry.Split("|");
  15033. quoteName = string.Join("、", countrys);
  15034. }
  15035. else quoteName = visitCountry;
  15036. quoteName += $"团组报价表";
  15037. result.Name = quoteName;
  15038. }
  15039. }
  15040. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  15041. if (info.Code != StatusCodes.Status200OK)
  15042. {
  15043. if (!result.Rates.Any())
  15044. {
  15045. var rates = await GeneralMethod.EnterExitCostInitRate();
  15046. result.Rates = rates.ToArray();
  15047. }
  15048. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  15049. }
  15050. var infoView = info.Data as EnterExitCostInfoView;
  15051. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  15052. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  15053. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  15054. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  15055. var eecRates = infoView.Currencys;
  15056. //默认添加人名币
  15057. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  15058. {
  15059. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15060. }
  15061. //处理团组人数
  15062. int pplNum = 1;
  15063. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  15064. var views = new List<QuoteSubItemInfo>();
  15065. #region 数据填充
  15066. var intTravelCosts = new List<QuoteSubItemInfo>();
  15067. #region 机票费用 1354
  15068. int intTravelIndex = 1;
  15069. if (infoView.SumJJC == 1)
  15070. {
  15071. intTravelCosts.Add(new QuoteSubItemInfo
  15072. {
  15073. ItemId = 1354,
  15074. Index = intTravelIndex,
  15075. FeeName = "经济舱",
  15076. UnitPrice = infoView.AirJJ,
  15077. Currency = "CNY",
  15078. Quantity = 1,
  15079. PplNum = 1,
  15080. TotalAmt = infoView.AirJJ,
  15081. Remark = "",
  15082. });
  15083. intTravelIndex++;
  15084. }
  15085. if (infoView.SumGWC == 1)
  15086. {
  15087. intTravelCosts.Add(new QuoteSubItemInfo
  15088. {
  15089. ItemId = 1354,
  15090. Index = intTravelIndex,
  15091. FeeName = "公务舱",
  15092. UnitPrice = infoView.AirGW,
  15093. Currency = "CNY",
  15094. Quantity = 1,
  15095. PplNum = 1,
  15096. TotalAmt = infoView.AirGW,
  15097. Remark = "",
  15098. });
  15099. intTravelIndex++;
  15100. }
  15101. if (infoView.SumTDC == 1)
  15102. {
  15103. intTravelCosts.Add(new QuoteSubItemInfo
  15104. {
  15105. ItemId = 1354,
  15106. Index = intTravelIndex,
  15107. FeeName = "头等舱",
  15108. UnitPrice = infoView.AirTD,
  15109. Currency = "CNY",
  15110. Quantity = 1,
  15111. PplNum = 1,
  15112. TotalAmt = infoView.AirTD,
  15113. Remark = "",
  15114. });
  15115. intTravelIndex++;
  15116. }
  15117. intTravelCosts.Add(new QuoteSubItemInfo
  15118. {
  15119. ItemId = 1354,
  15120. Index = intTravelIndex,
  15121. FeeName = "城市间交通费用(经济舱)",
  15122. UnitPrice = infoView.CityTranffic,
  15123. Currency = "CNY",
  15124. Quantity = 1,
  15125. PplNum = pplNum,
  15126. TotalAmt = infoView.CityTranffic * pplNum,
  15127. Remark = "",
  15128. });
  15129. intTravelCosts.Add(new QuoteSubItemInfo
  15130. {
  15131. ItemId = 1354,
  15132. Index = intTravelIndex,
  15133. FeeName = "城市间交通费用(公务舱)",
  15134. UnitPrice = infoView.CityTranffic1,
  15135. Currency = "CNY",
  15136. Quantity = 1,
  15137. PplNum = pplNum,
  15138. TotalAmt = infoView.CityTranffic1 * pplNum,
  15139. Remark = "",
  15140. });
  15141. intTravelCosts.Add(new QuoteSubItemInfo
  15142. {
  15143. ItemId = 1354,
  15144. Index = intTravelIndex,
  15145. FeeName = "城市间交通费用(头等舱)",
  15146. UnitPrice = infoView.CityTranffic2,
  15147. Currency = "CNY",
  15148. Quantity = 1,
  15149. PplNum = pplNum,
  15150. TotalAmt = infoView.CityTranffic2 * pplNum,
  15151. Remark = "",
  15152. });
  15153. views.AddRange(intTravelCosts);
  15154. #endregion
  15155. var accomCosts = new List<QuoteSubItemInfo>();
  15156. #region 住宿费 1355
  15157. if (infoView.QuarterageData.Any())
  15158. {
  15159. int accomIndex = 1;
  15160. int accomItemTypeId = 1355;
  15161. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  15162. foreach (var item in groupData)
  15163. {
  15164. string feeName = string.Empty;
  15165. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  15166. if (countryInfo != null)
  15167. {
  15168. feeName = countryInfo.Country;
  15169. var city = countryInfo.City;
  15170. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  15171. {
  15172. feeName += $"-{city}";
  15173. }
  15174. }
  15175. var hotelInfo = item.FirstOrDefault();
  15176. if (hotelInfo == null) continue;
  15177. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  15178. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  15179. int quantity = item.ToList().Count;
  15180. accomCosts.Add(new QuoteSubItemInfo
  15181. {
  15182. ItemId = accomItemTypeId,
  15183. Index = accomIndex,
  15184. FeeName = feeName,
  15185. UnitPrice = hotelInfo.Cost,
  15186. Currency = thisCurrency,
  15187. Quantity = quantity,
  15188. PplNum = pplNum,
  15189. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  15190. Remark = "",
  15191. });
  15192. accomIndex++;
  15193. }
  15194. views.AddRange(accomCosts);
  15195. }
  15196. #endregion
  15197. var mealCosts = new List<QuoteSubItemInfo>();
  15198. #region 餐饮费 1356
  15199. if (infoView.BoardWagesData.Any())
  15200. {
  15201. var mealIndex = 1;
  15202. int mealItemTypeId = 1356;
  15203. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  15204. foreach (var item in groupData)
  15205. {
  15206. string feeName = string.Empty;
  15207. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  15208. if (countryInfo != null)
  15209. {
  15210. feeName = countryInfo.Country;
  15211. var city = countryInfo.City;
  15212. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  15213. {
  15214. feeName += $"-{city}";
  15215. }
  15216. }
  15217. var mealInfo = item.FirstOrDefault();
  15218. if (mealInfo == null) continue;
  15219. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  15220. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  15221. int quantity = item.ToList().Count;
  15222. mealCosts.Add(new QuoteSubItemInfo
  15223. {
  15224. ItemId = mealItemTypeId,
  15225. Index = mealIndex,
  15226. FeeName = feeName,
  15227. UnitPrice = mealInfo.Cost,
  15228. Currency = thisCurrency,
  15229. Quantity = quantity,
  15230. PplNum = pplNum,
  15231. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  15232. Remark = "",
  15233. });
  15234. mealIndex++;
  15235. }
  15236. views.AddRange(mealCosts);
  15237. }
  15238. #endregion
  15239. var miscCosts = new List<QuoteSubItemInfo>();
  15240. #region 公杂费 1364
  15241. if (infoView.MiscellaneousFeeData.Any())
  15242. {
  15243. var miscIndex = 1;
  15244. int miscItemTypeId = 1364;
  15245. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  15246. foreach (var item in groupData)
  15247. {
  15248. string feeName = string.Empty;
  15249. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  15250. if (countryInfo != null)
  15251. {
  15252. feeName = countryInfo.Country;
  15253. var city = countryInfo.City;
  15254. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  15255. {
  15256. feeName += $"-{city}";
  15257. }
  15258. }
  15259. var miscInfo = item.FirstOrDefault();
  15260. if (miscInfo == null) continue;
  15261. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  15262. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  15263. int quantity = item.ToList().Count;
  15264. miscCosts.Add(new QuoteSubItemInfo
  15265. {
  15266. ItemId = miscItemTypeId,
  15267. Index = miscIndex,
  15268. FeeName = feeName,
  15269. UnitPrice = miscInfo.Cost,
  15270. Currency = thisCurrency,
  15271. Quantity = quantity,
  15272. PplNum = pplNum,
  15273. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  15274. Remark = "",
  15275. });
  15276. miscIndex++;
  15277. }
  15278. views.AddRange(miscCosts);
  15279. }
  15280. #endregion
  15281. #region 签证+保险 1362
  15282. int visaInsIndex = 1;
  15283. int visaInsItemTypeId = 1362;
  15284. if (infoView.Visa > 0)
  15285. {
  15286. views.Add(new QuoteSubItemInfo()
  15287. {
  15288. ItemId = visaInsItemTypeId,
  15289. Index = visaInsIndex,
  15290. FeeName = $"签证",
  15291. UnitPrice = infoView.Visa,
  15292. Currency = $"CNY",
  15293. Quantity = 1,
  15294. PplNum = pplNum,
  15295. TotalAmt = infoView.Visa * pplNum,
  15296. Remark = "",
  15297. });
  15298. visaInsIndex++;
  15299. }
  15300. if (infoView.Safe > 0)
  15301. {
  15302. views.Add(new QuoteSubItemInfo()
  15303. {
  15304. ItemId = visaInsItemTypeId,
  15305. Index = visaInsIndex,
  15306. FeeName = $"保险",
  15307. UnitPrice = infoView.Safe,
  15308. Currency = $"CNY",
  15309. Quantity = 1,
  15310. PplNum = pplNum,
  15311. TotalAmt = infoView.Safe * pplNum,
  15312. Remark = "",
  15313. });
  15314. }
  15315. #endregion
  15316. #region 服务费 1363
  15317. int serviceFeeIndex = 1;
  15318. int serviceFeeItemTypeId = 1363;
  15319. if (infoView.Service > 0)
  15320. {
  15321. views.Add(new QuoteSubItemInfo()
  15322. {
  15323. ItemId = serviceFeeItemTypeId,
  15324. Index = serviceFeeIndex,
  15325. FeeName = $"服务费",
  15326. UnitPrice = infoView.Service,
  15327. Currency = $"CNY",
  15328. Quantity = 1,
  15329. PplNum = pplNum,
  15330. TotalAmt = infoView.Service * pplNum,
  15331. Remark = "",
  15332. });
  15333. }
  15334. #endregion
  15335. #endregion
  15336. if (result.FeeItems.Any())
  15337. {
  15338. result.FeeItems.Select(x =>
  15339. {
  15340. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  15341. if (feeInfos.Any()) x.Infos = feeInfos;
  15342. return x;
  15343. }
  15344. ).OrderBy(x => x.Index)
  15345. .ToList();
  15346. if (!result.Rates.Any())
  15347. {
  15348. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  15349. else
  15350. {
  15351. var rates = await GeneralMethod.EnterExitCostInitRate();
  15352. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15353. result.Rates = rates.ToArray();
  15354. }
  15355. }
  15356. }
  15357. return Ok(JsonView(result));
  15358. }
  15359. /// <summary>
  15360. /// 团组模块 - 出入境费用报价表 - Info
  15361. /// </summary>
  15362. /// <returns></returns>
  15363. [HttpPost]
  15364. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15365. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  15366. {
  15367. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  15368. if (!info.Rates.Any())
  15369. {
  15370. var rates = await GeneralMethod.EnterExitCostInitRate();
  15371. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15372. info.Rates = rates.ToArray();
  15373. }
  15374. return Ok(JsonView(info));
  15375. }
  15376. /// <summary>
  15377. /// 团组模块 - 出入境费用报价表 - OP
  15378. /// </summary>
  15379. /// <returns></returns>
  15380. [HttpPost]
  15381. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15382. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  15383. {
  15384. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  15385. }
  15386. /// <summary>
  15387. /// 团组模块 - 出入境费用报价表 - 删除 项
  15388. /// </summary>
  15389. /// <returns></returns>
  15390. [HttpPost]
  15391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15392. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  15393. {
  15394. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  15395. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15396. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  15397. }
  15398. /// <summary>
  15399. /// 团组模块 - 出入境费用报价表 - 导出
  15400. /// </summary>
  15401. /// <returns></returns>
  15402. [HttpPost]
  15403. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15404. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  15405. {
  15406. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  15407. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15408. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  15409. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  15410. var rates = info.Rates;
  15411. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  15412. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  15413. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  15414. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  15415. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  15416. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  15417. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  15418. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  15419. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  15420. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  15421. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  15422. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  15423. //获取模板
  15424. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  15425. var designer = new WorkbookDesigner();
  15426. designer.Workbook = new Workbook(tempPath);
  15427. designer.SetDataSource("QuoteName", info.Name);
  15428. designer.SetDataSource("CompanyTitle", "公司名称");
  15429. designer.SetDataSource("CompanyLabel", "");
  15430. #region 国际旅费
  15431. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  15432. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  15433. {
  15434. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  15435. var label = new StringBuilder();
  15436. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  15437. if (infos.Any())
  15438. {
  15439. label.Append(infos.Sum(x => x.PplNum));
  15440. label.Append("人全程机票:");
  15441. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  15442. label.AppendLine("元");
  15443. }
  15444. foreach (var item in intTravelCosts.Infos)
  15445. {
  15446. label.Append(item.FeeName);
  15447. label.Append(":");
  15448. label.Append(item.UnitPrice.TruncDecimals(2));
  15449. label.Append("元/人*");
  15450. label.Append(item.PplNum);
  15451. label.AppendLine("人");
  15452. }
  15453. if (label.HasValue())
  15454. {
  15455. label.Append("\r\n以上小计:");
  15456. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  15457. label.Append("元");
  15458. }
  15459. designer.SetDataSource("IntTravelLabel", label.ToString());
  15460. }
  15461. #endregion
  15462. #region 住宿费
  15463. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  15464. if (accomCosts != null && accomCosts.Infos.Any())
  15465. {
  15466. string currencyName = string.Empty,
  15467. countryName = string.Empty;
  15468. decimal rate = 1.0000M;
  15469. var label = new StringBuilder();
  15470. label.AppendLine("全程五星酒店,每人1间房");
  15471. foreach (var item in accomCosts.Infos)
  15472. {
  15473. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  15474. string name = string.Empty, thisCountryName = string.Empty;
  15475. if (item.FeeName.Contains('-'))
  15476. {
  15477. var feeName = item.FeeName.Split('-');
  15478. thisCountryName = feeName[0];
  15479. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  15480. name = feeName[1];
  15481. }
  15482. else name = item.FeeName;
  15483. string thisFeeName = string.Empty;
  15484. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  15485. else thisFeeName = $"\r\n{name}:";
  15486. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  15487. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  15488. rate = rateInfo?.Rate ?? 1.0000M;
  15489. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  15490. label.AppendLine(subLabel);
  15491. }
  15492. if (label.HasValue())
  15493. {
  15494. //以上小计:52440元(美金汇率:7.5 )
  15495. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  15496. label.AppendLine(subLabel);
  15497. }
  15498. designer.SetDataSource("AccomLabel", label.ToString());
  15499. }
  15500. #endregion
  15501. #region 餐饮费
  15502. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  15503. if (mealCosts != null && mealCosts.Infos.Any())
  15504. {
  15505. string currencyName = string.Empty;
  15506. decimal rate = 1.0000M;
  15507. var label = new StringBuilder();
  15508. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  15509. foreach (var item in mealCosts.Infos)
  15510. {
  15511. string name = string.Empty;
  15512. if (item.FeeName.Contains('-'))
  15513. {
  15514. var feeName = item.FeeName.Split('-');
  15515. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  15516. }
  15517. else name = $"\r\n{item.FeeName}:";
  15518. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  15519. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  15520. rate = rateInfo?.Rate ?? 1.0000M;
  15521. label.Append(name);
  15522. label.Append(item.UnitPrice.TruncDecimals(2));
  15523. label.Append(currencyName);
  15524. label.Append("/天*");
  15525. label.Append(item.Quantity.ToString("#0"));
  15526. label.Append('*');
  15527. label.Append(item.PplNum);
  15528. label.Append("人\r\n");
  15529. }
  15530. if (label.HasValue())
  15531. {
  15532. label.Append("\r\n以上小计:");
  15533. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  15534. label.Append("元\r\n(");
  15535. label.Append("汇率:");
  15536. label.Append(rate.TruncDecimals(4));
  15537. label.Append(')');
  15538. }
  15539. designer.SetDataSource("MealLabel", label.ToString());
  15540. }
  15541. #endregion
  15542. #region 车辆安排
  15543. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  15544. if (vehArranges != null && vehArranges.Infos.Any())
  15545. {
  15546. string currencyName = string.Empty;
  15547. //decimal rate = 1.0000M;
  15548. var label = new StringBuilder();
  15549. foreach (var item in vehArranges.Infos)
  15550. {
  15551. label.AppendLine();
  15552. label.AppendLine();
  15553. label.Append(item.FeeName);
  15554. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  15555. }
  15556. designer.SetDataSource("VehArrangeLabel", label.ToString());
  15557. }
  15558. #endregion
  15559. #region 邀请函发放对象
  15560. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  15561. designer.SetDataSource("InviteToContent", "");
  15562. #endregion
  15563. #region 邀请函费
  15564. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  15565. var is_label = new StringBuilder();
  15566. if (inviteCosts != null && inviteCosts.Infos.Any())
  15567. {
  15568. string currencyName = string.Empty;
  15569. decimal rate = 1.0000M;
  15570. foreach (var item in inviteCosts.Infos)
  15571. {
  15572. //乌兹别克斯坦:2000美金
  15573. currencyName = item.Currency;
  15574. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  15575. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  15576. is_label.AppendLine(label);
  15577. }
  15578. if (is_label.HasValue())
  15579. {
  15580. //以上小计:28500元(美金汇率:7.5)
  15581. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  15582. is_label.AppendLine(label);
  15583. }
  15584. }
  15585. designer.SetDataSource("InviteCostContent", is_label.ToString());
  15586. #endregion
  15587. #region 邀请函发放时间
  15588. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  15589. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  15590. #endregion
  15591. #region 公务活动(含翻译)
  15592. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  15593. var oa_label = new StringBuilder();
  15594. if (officialActs != null && officialActs.Infos.Any())
  15595. {
  15596. string currencyName = string.Empty;
  15597. decimal rate = 1.0000M;
  15598. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  15599. foreach (var item in officialActs.Infos)
  15600. {
  15601. //乌兹别克斯坦:1000美金/场
  15602. currencyName = item.Currency;
  15603. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  15604. string label_remark = string.Empty;
  15605. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  15606. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  15607. }
  15608. label_content += "*总费用中未含超出公务活动价格";
  15609. //8场公务活动(以上小计:60000元)
  15610. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  15611. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  15612. oa_label.AppendLine(label_title);
  15613. oa_label.AppendLine(label_content);
  15614. }
  15615. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  15616. #endregion
  15617. #region 签证+保险
  15618. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  15619. var vi_label = new StringBuilder();
  15620. if (visaIns != null && visaIns.Infos.Any())
  15621. {
  15622. foreach (var item in visaIns.Infos)
  15623. {
  15624. //签证:500元/人
  15625. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  15626. vi_label.AppendLine(label);
  15627. }
  15628. if (vi_label.HasValue())
  15629. {
  15630. //以上小计:6000元
  15631. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  15632. vi_label.AppendLine(label);
  15633. }
  15634. }
  15635. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  15636. #endregion
  15637. #region 服务费
  15638. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  15639. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  15640. #endregion
  15641. #region 公杂费
  15642. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  15643. var pm_label = new StringBuilder();
  15644. if (pubMiscs != null && pubMiscs.Infos.Any())
  15645. {
  15646. string currencyName = string.Empty,
  15647. countryName = string.Empty;
  15648. decimal rate = 1.0000M;
  15649. foreach (var item in pubMiscs.Infos)
  15650. {
  15651. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  15652. string name = string.Empty, thisCountryName = string.Empty;
  15653. if (item.FeeName.Contains('-'))
  15654. {
  15655. var feeName = item.FeeName.Split('-');
  15656. thisCountryName = feeName[0];
  15657. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  15658. name = feeName[1];
  15659. }
  15660. else name = item.FeeName;
  15661. string thisFeeName = string.Empty;
  15662. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  15663. else thisFeeName = $"\r\n{name}:";
  15664. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  15665. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  15666. rate = rateInfo?.Rate ?? 1.0000M;
  15667. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  15668. pm_label.AppendLine(label);
  15669. }
  15670. if (pm_label.HasValue())
  15671. {
  15672. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  15673. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  15674. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  15675. pm_label.AppendLine(string.Format("部分发放成员"));
  15676. }
  15677. }
  15678. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  15679. #endregion
  15680. #region 税费
  15681. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  15682. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  15683. #endregion
  15684. #region 合计(单位:元)
  15685. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  15686. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  15687. #endregion
  15688. #region 汇率 Remark
  15689. var rate_label = new StringBuilder();
  15690. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  15691. foreach (var item in rateGroups)
  15692. {
  15693. //美元汇率按\r\n1:7.5
  15694. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  15695. rate_label.AppendLine(label);
  15696. }
  15697. designer.SetDataSource("RateLabel", rate_label.ToString());
  15698. #endregion
  15699. designer.Process();
  15700. //文件名
  15701. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  15702. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  15703. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  15704. return Ok(JsonView(true, "成功", url));
  15705. }
  15706. #endregion
  15707. #region 签证费用录入
  15708. /// <summary>
  15709. /// 根据diid查询签证费用列表
  15710. /// </summary>
  15711. /// <param name="dto"></param>
  15712. /// <returns></returns>
  15713. [HttpPost]
  15714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15715. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  15716. {
  15717. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  15718. if (groupData.Code != 0)
  15719. {
  15720. return Ok(JsonView(false, groupData.Msg));
  15721. }
  15722. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15723. }
  15724. /// <summary>
  15725. /// 根据签证费用Id查询单条数据及c表数据
  15726. /// </summary>
  15727. /// <param name="dto"></param>
  15728. /// <returns></returns>
  15729. [HttpPost]
  15730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15731. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  15732. {
  15733. Result groupData = await _visaPriceRep.PostVisaById(dto);
  15734. if (groupData.Code != 0)
  15735. {
  15736. return Ok(JsonView(false, groupData.Msg));
  15737. }
  15738. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15739. }
  15740. /// <summary>
  15741. /// 签证费用删除
  15742. /// </summary>
  15743. /// <param name="dto"></param>
  15744. /// <returns></returns>
  15745. [HttpPost]
  15746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15747. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  15748. {
  15749. _sqlSugar.BeginTran();
  15750. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  15751. if (!res)
  15752. {
  15753. _sqlSugar.RollbackTran();
  15754. return Ok(JsonView(false, "删除失败"));
  15755. }
  15756. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  15757. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  15758. .SetColumns(a => new Grp_CreditCardPayment()
  15759. {
  15760. IsDel = 1,
  15761. DeleteUserId = dto.DeleteUserId,
  15762. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15763. })
  15764. .ExecuteCommand();
  15765. if (resSub < 1)
  15766. {
  15767. _sqlSugar.RollbackTran();
  15768. return Ok(JsonView(false, "删除失败"));
  15769. }
  15770. _sqlSugar.CommitTran();
  15771. return Ok(JsonView(true, "删除成功!"));
  15772. }
  15773. /// <summary>
  15774. /// 签证费用录入下拉框初始化
  15775. /// </summary>
  15776. /// <returns></returns>
  15777. [HttpPost]
  15778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15779. public async Task<IActionResult> VisaPriceAddSelect()
  15780. {
  15781. //支付方式
  15782. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  15783. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  15784. //币种
  15785. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  15786. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  15787. //乘客类型
  15788. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  15789. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  15790. //卡类型
  15791. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  15792. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  15793. //代办费类型
  15794. var agencyFeeTypeData = new List<dynamic>() {
  15795. new { id = 0 , Text = "未选择" },
  15796. new { id = 1 , Text = "小公务" },
  15797. new { id = 2 , Text = "大公务" },
  15798. };
  15799. //签证费用标准国家Data
  15800. var visaSql = string.Format(@"select
  15801. id,
  15802. case
  15803. when FeeType = 0 then Country+'(因公)'
  15804. when FeeType = 1 then Country+'(因私)'
  15805. else Country+'(未设置)'
  15806. end as 'country'
  15807. from Res_VisaFeeStandard where isdel = 0");
  15808. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  15809. var data = new
  15810. {
  15811. Payment = _Payment,
  15812. CurrencyList = _CurrencyList,
  15813. PassengerType = _PassengerType,
  15814. BankCard = _BankCard,
  15815. AgencyFeeType = agencyFeeTypeData,
  15816. CountryFeeData = visaCountryFeeData
  15817. };
  15818. return Ok(JsonView(true, "查询成功!", data));
  15819. }
  15820. /// <summary>
  15821. /// 签证费用录入操作(Status:1.新增,2.修改)
  15822. /// </summary>
  15823. /// <param name="dto"></param>
  15824. /// <returns></returns>
  15825. [HttpPost]
  15826. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15827. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  15828. {
  15829. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  15830. if (groupData.Code != 0)
  15831. {
  15832. return Ok(JsonView(false, groupData.Msg));
  15833. }
  15834. #region 应用推送
  15835. try
  15836. {
  15837. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15838. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15839. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15840. //2024-10-21 新增LZ UID
  15841. var userIds = new List<int>() { 21 };
  15842. string title = $"系统通知";
  15843. string content = "";
  15844. var diId = dto.DiId;
  15845. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15846. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15847. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  15848. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  15849. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15850. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  15851. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15852. }
  15853. catch (Exception ex)
  15854. {
  15855. }
  15856. #endregion
  15857. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15858. }
  15859. #endregion
  15860. #region 签证提成录入
  15861. /// <summary>
  15862. /// 签证提成录入
  15863. /// 基础数据
  15864. /// </summary>
  15865. /// <returns></returns>
  15866. [HttpGet]
  15867. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15868. public async Task<IActionResult> VisaCommissionInit()
  15869. {
  15870. return Ok(await _visaCommissionRep.Init());
  15871. }
  15872. /// <summary>
  15873. /// 签证提成录入
  15874. /// Item
  15875. /// </summary>
  15876. /// <param name="_dto"></param>
  15877. /// <returns></returns>
  15878. [HttpPost]
  15879. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15880. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  15881. {
  15882. var validator = new VisaCommissionItemDtoValidator();
  15883. var validatorRes = await validator.ValidateAsync(_dto);
  15884. if (!validatorRes.IsValid)
  15885. {
  15886. var sb = new StringBuilder();
  15887. foreach (var item in validatorRes.Errors)
  15888. {
  15889. sb.AppendLine(item.ErrorMessage);
  15890. }
  15891. return Ok(JsonView(false, sb.ToString()));
  15892. }
  15893. return Ok(await _visaCommissionRep.Item(_dto));
  15894. }
  15895. /// <summary>
  15896. /// 签证提成录入
  15897. /// Save
  15898. /// </summary>
  15899. /// <param name="_dto"></param>
  15900. /// <returns></returns>
  15901. [HttpPost]
  15902. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15903. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  15904. {
  15905. //参数验证
  15906. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  15907. foreach (var item in _dto.Items)
  15908. {
  15909. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  15910. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  15911. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  15912. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  15913. }
  15914. return Ok(await _visaCommissionRep.Save(_dto));
  15915. }
  15916. /// <summary>
  15917. /// 签证提成录入
  15918. /// Create
  15919. /// </summary>
  15920. /// <param name="_dto"></param>
  15921. /// <returns></returns>
  15922. [HttpPost]
  15923. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15924. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  15925. {
  15926. var validator = new VisaCommissionCreateDtoValidator();
  15927. var validatorRes = await validator.ValidateAsync(_dto);
  15928. if (!validatorRes.IsValid)
  15929. {
  15930. var sb = new StringBuilder();
  15931. foreach (var item in validatorRes.Errors)
  15932. {
  15933. sb.AppendLine(item.ErrorMessage);
  15934. }
  15935. return Ok(JsonView(false, sb.ToString()));
  15936. }
  15937. return Ok(await _visaCommissionRep.Create(_dto));
  15938. }
  15939. /// <summary>
  15940. /// 签证提成录入
  15941. /// Put(编辑)
  15942. /// </summary>
  15943. /// <param name="id"></param>
  15944. /// <param name="_dto"></param>
  15945. /// <returns></returns>
  15946. [HttpPut]
  15947. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15948. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  15949. {
  15950. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  15951. var validator = new VisaCommissionCreateDtoValidator();
  15952. var validatorRes = await validator.ValidateAsync(_dto);
  15953. if (!validatorRes.IsValid)
  15954. {
  15955. var sb = new StringBuilder();
  15956. foreach (var item in validatorRes.Errors)
  15957. {
  15958. sb.AppendLine(item.ErrorMessage);
  15959. }
  15960. return Ok(JsonView(false, sb.ToString()));
  15961. }
  15962. return Ok(await _visaCommissionRep.Edit(id, _dto));
  15963. }
  15964. /// <summary>
  15965. /// 签证提成录入
  15966. /// Del
  15967. /// </summary>
  15968. /// <param name="id"></param>
  15969. /// <param name="currUserId"></param>
  15970. /// <returns></returns>
  15971. [HttpPost]
  15972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15973. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  15974. {
  15975. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  15976. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  15977. return Ok(await _visaCommissionRep.Del(id, currUserId));
  15978. }
  15979. #endregion
  15980. #region op费用录入
  15981. /// <summary>
  15982. /// 根据diid查询op费用列表
  15983. /// </summary>
  15984. /// <param name="dto"></param>
  15985. /// <returns></returns>
  15986. [HttpPost]
  15987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15988. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  15989. {
  15990. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  15991. if (groupData.Code != 0)
  15992. {
  15993. return Ok(JsonView(false, groupData.Msg));
  15994. }
  15995. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15996. }
  15997. /// <summary>
  15998. /// 根据op费用Id查询单条数据及c表数据
  15999. /// </summary>
  16000. /// <param name="dto"></param>
  16001. /// <returns></returns>
  16002. [HttpPost]
  16003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16004. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  16005. {
  16006. try
  16007. {
  16008. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  16009. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  16010. var data = new
  16011. {
  16012. CarTouristGuideGround = _groupData,
  16013. CreditCardPayment = _creditCardPayment
  16014. };
  16015. return Ok(JsonView(true, "查询成功!", data));
  16016. }
  16017. catch (Exception ex)
  16018. {
  16019. return Ok(JsonView(false, "程序错误!"));
  16020. }
  16021. }
  16022. /// <summary>
  16023. /// op费用删除
  16024. /// </summary>
  16025. /// <param name="dto"></param>
  16026. /// <returns></returns>
  16027. [HttpPost]
  16028. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16029. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  16030. {
  16031. try
  16032. {
  16033. _sqlSugar.BeginTran();
  16034. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  16035. if (!res)
  16036. {
  16037. return Ok(JsonView(false, "删除失败"));
  16038. }
  16039. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  16040. {
  16041. IsDel = 1,
  16042. DeleteUserId = dto.DeleteUserId,
  16043. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16044. }).ExecuteCommandAsync();
  16045. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  16046. {
  16047. IsDel = 1,
  16048. DeleteUserId = dto.DeleteUserId,
  16049. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16050. }).ExecuteCommandAsync();
  16051. #region 删除超支相关数据
  16052. //删除导入的超支数据
  16053. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  16054. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  16055. {
  16056. IsDel = 1,
  16057. DeleteUserId = dto.DeleteUserId,
  16058. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16059. }).ExecuteCommand();
  16060. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  16061. {
  16062. IsDel = 1,
  16063. DeleteUserId = dto.DeleteUserId,
  16064. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16065. }).ExecuteCommand();
  16066. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  16067. {
  16068. IsDel = 1,
  16069. DeleteUserId = dto.DeleteUserId,
  16070. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16071. }).ExecuteCommand();
  16072. #endregion
  16073. _sqlSugar.CommitTran();
  16074. return Ok(JsonView(true, "删除成功!"));
  16075. }
  16076. catch (Exception ex)
  16077. {
  16078. _sqlSugar.RollbackTran();
  16079. return Ok(JsonView(false, "程序错误!" + ex.Message));
  16080. }
  16081. }
  16082. /// <summary>
  16083. /// op费用录入操作(Status:1.新增,2.修改)
  16084. /// </summary>
  16085. /// <param name="dto"></param>
  16086. /// <returns></returns>
  16087. [HttpPost]
  16088. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16089. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  16090. {
  16091. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  16092. if (groupData.Code != 0)
  16093. {
  16094. return Ok(JsonView(false, groupData.Msg));
  16095. }
  16096. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16097. }
  16098. /// <summary>
  16099. /// 填写费用详细页面初始化绑定
  16100. /// </summary>
  16101. /// <param name="dto"></param>
  16102. /// <returns></returns>
  16103. [HttpPost]
  16104. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16105. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  16106. {
  16107. try
  16108. {
  16109. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  16110. if (groupData.Code != 0)
  16111. {
  16112. return Ok(JsonView(false, groupData.Msg));
  16113. }
  16114. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16115. }
  16116. catch (Exception ex)
  16117. {
  16118. return Ok(JsonView(false, ex.Message));
  16119. }
  16120. }
  16121. /// <summary>
  16122. /// 根据op费用Id查询详细数据
  16123. /// </summary>
  16124. /// <param name="dto"></param>
  16125. /// <returns></returns>
  16126. [HttpPost]
  16127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16128. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  16129. {
  16130. try
  16131. {
  16132. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  16133. if (groupData.Code != 0)
  16134. {
  16135. return Ok(JsonView(false, groupData.Msg));
  16136. }
  16137. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16138. }
  16139. catch (Exception ex)
  16140. {
  16141. return Ok(JsonView(false, ex.Message));
  16142. }
  16143. }
  16144. /// <summary>
  16145. /// OP费用录入填写详情
  16146. /// </summary>
  16147. /// <param name="dto"></param>
  16148. /// <returns></returns>
  16149. [HttpPost]
  16150. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16151. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  16152. {
  16153. try
  16154. {
  16155. #region 参数校验
  16156. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  16157. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  16158. if (di == null) return Ok(JsonView(false, "团组错误!"));
  16159. #endregion
  16160. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  16161. if (groupData.Code != 0)
  16162. {
  16163. return Ok(JsonView(false, groupData.Msg));
  16164. }
  16165. //自动审核
  16166. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  16167. #region 尾款自动审核
  16168. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  16169. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  16170. if (opinfos.PriceType == 1062)
  16171. {
  16172. var isAuto = false;
  16173. //找对应的首付款
  16174. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  16175. .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))
  16176. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  16177. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  16178. x.PriceType == 1061 && x.DiId == dto.DiId);
  16179. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  16180. {
  16181. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  16182. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  16183. //合计中排除城市税
  16184. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  16185. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  16186. .Sum(x => x.Price * x.Count);
  16187. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  16188. if (balance >= opinfos.ServiceQuotedPrice)
  16189. {
  16190. isAuto = true;
  16191. }
  16192. }
  16193. if (isAuto)
  16194. {
  16195. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  16196. .SetColumns(a => new Grp_CreditCardPayment
  16197. {
  16198. IsAuditGM = 3, //自动审核通过
  16199. AuditGMOperate = 4,
  16200. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16201. })
  16202. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  16203. .ExecuteCommand();
  16204. }
  16205. }
  16206. #endregion
  16207. #region 应用推送
  16208. try
  16209. {
  16210. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16211. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16212. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16213. //2024-10-21 新增LZ UID
  16214. var userIds = new List<int>() { 21 };
  16215. string title = $"系统通知";
  16216. var diId = dto.DiId;
  16217. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16218. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16219. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  16220. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16221. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  16222. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16223. }
  16224. catch (Exception ex)
  16225. {
  16226. }
  16227. #endregion
  16228. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16229. }
  16230. catch (Exception ex)
  16231. {
  16232. return Ok(JsonView(false, ex.Message));
  16233. }
  16234. }
  16235. /// <summary>
  16236. /// 获取三公详细所有城市
  16237. /// </summary>
  16238. /// <returns></returns>
  16239. [HttpGet]
  16240. public IActionResult OpCarCityResult()
  16241. {
  16242. var jw = JsonView(false);
  16243. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  16244. {
  16245. x.Id,
  16246. x.Country,
  16247. x.City,
  16248. }).ToList();
  16249. if (data.Count > 0)
  16250. {
  16251. jw = JsonView(true, "获取成功!", data);
  16252. }
  16253. else
  16254. {
  16255. jw.Msg = "城市数据为空!";
  16256. jw.Data = Array.Empty<string>();
  16257. }
  16258. return Ok(jw);
  16259. }
  16260. /// <summary>
  16261. /// 导出地接费用明细
  16262. /// </summary>
  16263. /// <param name="dto"></param>
  16264. /// <returns></returns>
  16265. [HttpPost]
  16266. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  16267. {
  16268. var jw = JsonView(false);
  16269. if (dto.Diid < 1)
  16270. {
  16271. jw.Msg = "请输入正确的diid!";
  16272. return Ok(jw);
  16273. }
  16274. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16275. if (group == null)
  16276. {
  16277. jw.Msg = "未找到团组信息!";
  16278. return Ok(jw);
  16279. }
  16280. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  16281. if (localGuideArr.Count == 0)
  16282. {
  16283. jw.Msg = "该团组暂无地接信息!";
  16284. return Ok(jw);
  16285. }
  16286. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  16287. var overspendSoure = new Dictionary<int, int>
  16288. {
  16289. { 91, 982 }, //车
  16290. { 92 , 1059} ,//导游
  16291. { 994 , 1073}, //翻译
  16292. { 988 , 1074 }, //早餐
  16293. { 93 , 1075 }, //午餐
  16294. { 989 , 1076 }, //晚餐
  16295. };
  16296. var Zips = new Dictionary<string, Stream>();
  16297. foreach (var groupArr in localGroup)
  16298. {
  16299. var keyValue = groupArr.Key;
  16300. if (int.TryParse(keyValue, out int cityid))
  16301. {
  16302. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  16303. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  16304. }
  16305. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  16306. foreach (var item in groupArr)
  16307. {
  16308. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  16309. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  16310. new Grp_CarTouristGuideGroundReservationsContentExtend
  16311. {
  16312. Count = a.Count,
  16313. CreateTime = a.CreateTime,
  16314. CreateUserId = a.CreateUserId,
  16315. CTGGRId = a.CTGGRId,
  16316. Currency = a.Currency,
  16317. DatePrice = a.DatePrice,
  16318. DeleteTime = a.DeleteTime,
  16319. DeleteUserId = a.DeleteUserId,
  16320. DiId = a.DiId,
  16321. Id = a.Id,
  16322. IsDel = a.IsDel,
  16323. Price = a.Price,
  16324. PriceContent = a.PriceContent,
  16325. Remark = a.Remark,
  16326. SId = a.SId,
  16327. SidName = b.Name,
  16328. Units = a.Units,
  16329. }
  16330. ).ToList();
  16331. if (content.Count > 0)
  16332. {
  16333. contentArr.Add(content);
  16334. }
  16335. }
  16336. //open excel
  16337. //set excel
  16338. //save excel
  16339. try
  16340. {
  16341. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  16342. IWorkbook workbook;
  16343. if (Path.GetExtension(filePath).ToLower() == ".xls")
  16344. {
  16345. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  16346. }
  16347. else
  16348. {
  16349. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  16350. }
  16351. ISheet sheet = workbook.GetSheetAt(0);
  16352. var rowStartIndex = 2;
  16353. var clounmCount = 10;
  16354. var initStyleRow = sheet.GetRow(2);
  16355. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  16356. //var overspendArrDetail =
  16357. var existsId = new List<CarCompare>();
  16358. var lastElem = arr.Last();
  16359. var thisSid = -1;
  16360. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  16361. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  16362. {
  16363. Name = "未知币种!",
  16364. Remark = "未知币种!",
  16365. };
  16366. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  16367. Action cloneRowFn = () =>
  16368. {
  16369. rowStartIndex++;
  16370. var cloneRow = sheet.CreateRow(rowStartIndex);
  16371. // 复制样式
  16372. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  16373. {
  16374. ICell sourceCell = initStyleRow.GetCell(i);
  16375. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  16376. // 确保单元格存在样式
  16377. if (sourceCell.CellStyle != null)
  16378. {
  16379. targetCell.CellStyle = sourceCell.CellStyle;
  16380. }
  16381. }
  16382. };
  16383. var mergeRow = () =>
  16384. {
  16385. for (int i = 2; i < sheet.LastRowNum; i++)
  16386. {
  16387. var row = sheet.GetRow(i);
  16388. var cellFirst = row.GetCell(0);
  16389. var thisIndex = i + 1;
  16390. while (thisIndex < sheet.LastRowNum)
  16391. {
  16392. var nextRow = sheet.GetRow(thisIndex);
  16393. var nextCellFirst = nextRow.GetCell(0);
  16394. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  16395. {
  16396. thisIndex++;
  16397. }
  16398. else
  16399. {
  16400. break;
  16401. }
  16402. }
  16403. thisIndex--;
  16404. if (thisIndex != i)
  16405. {
  16406. //合并row
  16407. var cellRangeAddress = new CellRangeAddress(
  16408. i, // 起始行索引(0-based)
  16409. thisIndex, // 结束行索引(0-based)
  16410. 0, // 起始列索引(0-based)
  16411. 0 // 结束列索引(0-based)
  16412. );
  16413. sheet.AddMergedRegion(cellRangeAddress);
  16414. i = thisIndex;
  16415. }
  16416. }
  16417. };
  16418. var chaoshiNumber = 0;
  16419. var totalNumber = 0.00M;
  16420. string lastStr = "";
  16421. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  16422. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  16423. {
  16424. b.IsAuditGM,
  16425. x.Id,
  16426. x.Area,
  16427. b.PayPercentage,
  16428. b.PayMoney,
  16429. }).ToList();
  16430. string yesPayment = "", noPayment = "";
  16431. foreach (var item in queryCarArrByCityAndDiid)
  16432. {
  16433. if (item.IsAuditGM == 1)
  16434. {
  16435. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  16436. }
  16437. else
  16438. {
  16439. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  16440. }
  16441. }
  16442. lastStr = yesPayment + noPayment;
  16443. foreach (var item in arr)
  16444. {
  16445. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  16446. {
  16447. if (thisSid != item.SId)
  16448. {
  16449. if (thisSid == -1)
  16450. {
  16451. thisSid = item.SId;
  16452. }
  16453. else
  16454. {
  16455. //合并小计行
  16456. //创建合并区域的实例
  16457. var cellRangeAddress = new CellRangeAddress(
  16458. rowStartIndex, // 起始行索引(0-based)
  16459. rowStartIndex, // 结束行索引(0-based)
  16460. 0, // 起始列索引(0-based)
  16461. 3 // 结束列索引(0-based)
  16462. );
  16463. sheet.AddMergedRegion(cellRangeAddress);
  16464. var CellStyle = workbook.CreateCellStyle();
  16465. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16466. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  16467. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  16468. for (int i = 0; i <= clounmCount; i++)
  16469. {
  16470. if (i > 6)
  16471. {
  16472. var CellStyle1 = workbook.CreateCellStyle();
  16473. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16474. IFont Font = workbook.CreateFont(); // 创建字体
  16475. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  16476. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  16477. CellStyle1.SetFont(Font);
  16478. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  16479. }
  16480. else
  16481. {
  16482. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  16483. }
  16484. }
  16485. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  16486. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  16487. //超时合计
  16488. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  16489. //超时数
  16490. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  16491. //超时合计费用
  16492. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  16493. thisSid = item.SId;
  16494. cloneRowFn();
  16495. chaoshiNumber = 0;
  16496. totalNumber = 0;
  16497. }
  16498. }
  16499. IRow row = sheet.GetRow(rowStartIndex);
  16500. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  16501. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  16502. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  16503. if (isOpenOverspendSoure)
  16504. {
  16505. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  16506. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  16507. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  16508. }
  16509. for (int i = 0; i <= clounmCount; i++)
  16510. {
  16511. var cell = row.GetCell(i);
  16512. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  16513. if (cell == null)
  16514. {
  16515. cell = row.CreateCell(i);
  16516. }
  16517. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  16518. fontRed.CloneStyleFrom(cell.CellStyle);
  16519. IFont Font = workbook.CreateFont(); // 创建字体
  16520. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  16521. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  16522. fontRed.SetFont(Font);
  16523. byte[] rgb = new byte[3] { 255, 242, 204 };
  16524. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  16525. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  16526. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  16527. if (workbook is XSSFWorkbook)
  16528. {
  16529. BackgroundColor255_242_204.FillForegroundColor = 0;
  16530. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  16531. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  16532. }
  16533. else
  16534. {
  16535. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  16536. }
  16537. if (i == 1 || i > 6)
  16538. {
  16539. if (i > 6)
  16540. {
  16541. fontRed.FillForegroundColor = 0;
  16542. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  16543. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  16544. }
  16545. cell.CellStyle = fontRed;
  16546. }
  16547. if (i > 2 && i < 7)
  16548. {
  16549. cell.CellStyle = BackgroundColor255_242_204;
  16550. }
  16551. cell.SetCellValue(setCellValue); //写入单元格
  16552. }
  16553. if (overspendSoure.ContainsKey(thisSid))
  16554. {
  16555. var overspendId = overspendSoure[thisSid];
  16556. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  16557. }
  16558. cloneRowFn();
  16559. existsId.Add(new CarCompare
  16560. {
  16561. DataPrice = item.DatePrice.ObjToDate(),
  16562. Sid = item.SId
  16563. });
  16564. }
  16565. if (item.Equals(lastElem))
  16566. {
  16567. //合并小计行
  16568. //创建合并区域的实例
  16569. var cellRangeAddress = new CellRangeAddress(
  16570. rowStartIndex, // 起始行索引(0-based)
  16571. rowStartIndex, // 结束行索引(0-based)
  16572. 0, // 起始列索引(0-based)
  16573. 3 // 结束列索引(0-based)
  16574. );
  16575. sheet.AddMergedRegion(cellRangeAddress);
  16576. var CellStyle = workbook.CreateCellStyle();
  16577. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16578. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  16579. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  16580. for (int i = 0; i <= clounmCount; i++)
  16581. {
  16582. if (i > 6)
  16583. {
  16584. var CellStyle1 = workbook.CreateCellStyle();
  16585. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16586. IFont Font = workbook.CreateFont(); // 创建字体
  16587. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  16588. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  16589. CellStyle1.SetFont(Font);
  16590. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  16591. }
  16592. else
  16593. {
  16594. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  16595. }
  16596. }
  16597. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  16598. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  16599. //超时合计
  16600. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  16601. //超时数
  16602. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  16603. //超时合计费用
  16604. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  16605. cloneRowFn();
  16606. // 创建合并区域的实例
  16607. cellRangeAddress = new CellRangeAddress(
  16608. rowStartIndex, // 起始行索引(0-based)
  16609. rowStartIndex, // 结束行索引(0-based)
  16610. 0, // 起始列索引(0-based)
  16611. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  16612. );
  16613. // 添加合并区域
  16614. sheet.AddMergedRegion(cellRangeAddress);
  16615. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  16616. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  16617. }
  16618. }
  16619. mergeRow();
  16620. // 保存修改后的Excel文件到新文件
  16621. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  16622. // new FileStream(newFilePath, FileMode.CreateNew)
  16623. using (var stream = new MemoryStream())
  16624. {
  16625. workbook.Write(stream, true);
  16626. stream.Flush();
  16627. stream.Seek(0, SeekOrigin.Begin);
  16628. var memoryStream = new MemoryStream();
  16629. stream.CopyTo(memoryStream);
  16630. memoryStream.Seek(0, SeekOrigin.Begin);
  16631. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  16632. }
  16633. workbook.Close();
  16634. workbook.Dispose();
  16635. }
  16636. catch (Exception ex)
  16637. {
  16638. jw.Msg = "出现异常!" + ex.Message;
  16639. return Ok(jw);
  16640. }
  16641. }
  16642. if (Zips.Count > 0)
  16643. {
  16644. var io = new IOOperatorHelper();
  16645. var byts = io.ConvertZipStream(Zips);
  16646. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  16647. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  16648. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  16649. }
  16650. else
  16651. {
  16652. jw.Msg = "暂无生成文件!";
  16653. }
  16654. return Ok(jw);
  16655. }
  16656. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  16657. {
  16658. string outStr = string.Empty;
  16659. switch (i)
  16660. {
  16661. case 0:
  16662. outStr = arr[0].SidName;
  16663. break;
  16664. case 1:
  16665. outStr = arr[0].DataPriceStr;
  16666. break;
  16667. case 2:
  16668. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  16669. break;
  16670. case 4:
  16671. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  16672. break;
  16673. case 7:
  16674. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16675. {
  16676. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  16677. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  16678. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  16679. }
  16680. break;
  16681. case 8:
  16682. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16683. {
  16684. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  16685. }
  16686. break;
  16687. case 9:
  16688. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16689. {
  16690. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  16691. }
  16692. break;
  16693. case 10:
  16694. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16695. {
  16696. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  16697. }
  16698. break;
  16699. }
  16700. return outStr;
  16701. }
  16702. #region OP行程单
  16703. /// <summary>
  16704. /// OP行程单初始化
  16705. /// </summary>
  16706. /// <param name="dto"></param>
  16707. /// <returns></returns>
  16708. [HttpPost]
  16709. public IActionResult InitOpTravel(InitOpTravelDto dto)
  16710. {
  16711. var jw = JsonView(false);
  16712. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  16713. var group = groupList.First();
  16714. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  16715. if (group == null)
  16716. {
  16717. jw.Msg = "暂无团组!";
  16718. return Ok(jw);
  16719. }
  16720. group = groupList.Find(x => x.Id == diid);
  16721. if (group == null)
  16722. {
  16723. jw.Msg = "请输入正确的团组ID!";
  16724. return Ok(jw);
  16725. }
  16726. string city = string.Empty;
  16727. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  16728. if (blackCode.Count > 0)
  16729. {
  16730. var black = blackCode.First();
  16731. black.BlackCode = black.BlackCode ?? "";
  16732. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  16733. if (blackSp.Length > 0)
  16734. {
  16735. try
  16736. {
  16737. var cityArrCode = new List<string>(20);
  16738. foreach (var item in blackSp)
  16739. {
  16740. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  16741. var IndexSelect = itemSp[2];
  16742. var cityArrCodeLength = cityArrCode.Count - 1;
  16743. var startCity = IndexSelect.Substring(0, 3);
  16744. if (cityArrCodeLength > 0)
  16745. {
  16746. var arrEndCity = cityArrCode[cityArrCodeLength];
  16747. if (arrEndCity != startCity)
  16748. {
  16749. cityArrCode.Add(startCity.ToUpper());
  16750. }
  16751. }
  16752. else
  16753. {
  16754. cityArrCode.Add(startCity.ToUpper());
  16755. }
  16756. var endCity = IndexSelect.Substring(3, 3);
  16757. cityArrCode.Add(endCity.ToUpper());
  16758. }
  16759. var cityThree = string.Empty;
  16760. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  16761. cityThree = cityThree.TrimEnd(',');
  16762. if (string.IsNullOrWhiteSpace(cityThree))
  16763. {
  16764. throw new
  16765. Exception("error");
  16766. }
  16767. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  16768. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  16769. foreach (var item in cityArrCode)
  16770. {
  16771. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  16772. if (find != null)
  16773. {
  16774. city += find.City + "/";
  16775. }
  16776. else
  16777. {
  16778. city += item + "三字码未收入/";
  16779. }
  16780. }
  16781. city = city.TrimEnd('/');
  16782. }
  16783. catch (Exception e)
  16784. {
  16785. city = "黑屏代码格式不正确!";
  16786. }
  16787. }
  16788. }
  16789. else
  16790. {
  16791. city = "未录入黑屏代码";
  16792. }
  16793. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  16794. {
  16795. Date = x.Date,
  16796. Days = x.Days,
  16797. Diffgroup = x.Diffgroup,
  16798. Diid = x.Diid,
  16799. Traffic_First = x.Traffic_First,
  16800. Traffic_Second = x.Traffic_Second,
  16801. Trip = x.Trip,
  16802. WeekDay = x.WeekDay,
  16803. Id = x.Id
  16804. }).ToList();
  16805. jw.Data = new
  16806. {
  16807. groupList = groupList.Select(x => new
  16808. {
  16809. x.Id,
  16810. x.TeamName,
  16811. x.TourCode
  16812. }).ToList(),
  16813. groupInfo = new
  16814. {
  16815. group.VisitDays,
  16816. group.TourCode,
  16817. group.VisitPNumber,
  16818. group.TeamName,
  16819. city
  16820. },
  16821. OpTravelList
  16822. };
  16823. jw.Code = 200;
  16824. jw.Msg = "操作成功!";
  16825. return Ok(jw);
  16826. }
  16827. /// <summary>
  16828. /// 删除团组行程单
  16829. /// </summary>
  16830. /// <returns></returns>
  16831. [HttpPost]
  16832. public IActionResult DelTravel(DelOpTravelDto dto)
  16833. {
  16834. var jw = JsonView(false);
  16835. if (dto.UserId <= 0 || dto.Diid <= 0)
  16836. {
  16837. jw.Msg = "请输入正确的参数!";
  16838. return Ok(jw);
  16839. }
  16840. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16841. .SetColumns(x => new Grp_TravelList
  16842. {
  16843. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  16844. DeleteUserId = dto.UserId,
  16845. IsDel = 1,
  16846. }).ExecuteCommand();
  16847. jw = JsonView(true);
  16848. return Ok(jw);
  16849. }
  16850. /// <summary>
  16851. /// 行程单保存
  16852. /// </summary>
  16853. /// <returns></returns>
  16854. [HttpPost]
  16855. public IActionResult TravelSave(TravelSaveDto dto)
  16856. {
  16857. var jw = JsonView(false);
  16858. if (dto.Arr.Count > 0)
  16859. {
  16860. try
  16861. {
  16862. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  16863. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  16864. .ToList();
  16865. _sqlSugar.BeginTran();
  16866. foreach (var item in dto.Arr)
  16867. {
  16868. if (item.Id == 0)
  16869. {
  16870. throw new Exception("请传入正确的Id");
  16871. }
  16872. //比较上一次的差异
  16873. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  16874. if (findTravel != null)
  16875. {
  16876. item.Trip = item.Trip.Replace("[++]", string.Empty);
  16877. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  16878. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  16879. }
  16880. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  16881. .SetColumns(x => new Grp_TravelList
  16882. {
  16883. Trip = item.Trip
  16884. }).ExecuteCommand();
  16885. }
  16886. _sqlSugar.CommitTran();
  16887. jw = JsonView(true);
  16888. }
  16889. catch (Exception ex)
  16890. {
  16891. _sqlSugar.RollbackTran();
  16892. jw.Msg = "程序异常!" + ex.Message;
  16893. }
  16894. }
  16895. else
  16896. {
  16897. jw.Msg = "请传入正确的参数!";
  16898. }
  16899. return Ok(jw);
  16900. }
  16901. private static string CheckStr(string original, string changed)
  16902. {
  16903. // 创建diff_match_patch对象
  16904. var dmp = new diff_match_patch();
  16905. // 计算差异
  16906. List<Diff> diffs = dmp.diff_main(original, changed);
  16907. // 清理和合并差异
  16908. dmp.diff_cleanupSemantic(diffs);
  16909. // 使用StringBuilder构建最终的字符串
  16910. var finalString = new StringBuilder();
  16911. // 输出差异结果,并构建变动后的字符串
  16912. foreach (Diff diff in diffs)
  16913. {
  16914. switch (diff.operation)
  16915. {
  16916. case Operation.EQUAL:
  16917. // 相等的部分,直接添加到最终字符串
  16918. finalString.Append(diff.text);
  16919. break;
  16920. case Operation.INSERT:
  16921. // 插入的部分,添加标记并添加到最终字符串
  16922. finalString.Append("[++]" + diff.text + "[++]");
  16923. break;
  16924. case Operation.DELETE:
  16925. // 删除的部分,不添加到最终字符串
  16926. //finalString.Append("[++]" + diff.text + "[++]");
  16927. break;
  16928. }
  16929. }
  16930. // 输出变动后的字符串
  16931. return finalString.ToString();
  16932. }
  16933. private class tagContent
  16934. {
  16935. public DateTime Date { get; set; }
  16936. public string StartTag { get; set; }
  16937. public string EndTag { get; set; }
  16938. public string Content { get; set; }
  16939. public static int tagLength { get { return 3; } }
  16940. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  16941. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  16942. public bool IsFinally { get; set; }
  16943. }
  16944. private static List<string> ExtractContentBetweenTags(string input, string tag)
  16945. {
  16946. var results = new List<string>();
  16947. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  16948. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  16949. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  16950. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  16951. string[] strValueArr = new string[1];
  16952. foreach (System.Text.RegularExpressions.Match match in matches)
  16953. {
  16954. var strValue = match.Groups[1].Value;
  16955. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  16956. }
  16957. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  16958. return results;
  16959. }
  16960. /// <summary>
  16961. /// 导出行程单
  16962. /// </summary>
  16963. /// <param name="dto"></param>
  16964. /// <returns></returns>
  16965. [HttpPost]
  16966. public IActionResult ExportTravel(ExportTravelDto dto)
  16967. {
  16968. var jw = JsonView(false);
  16969. jw.Data = "";
  16970. int diid = 0;
  16971. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  16972. if (Find == null)
  16973. {
  16974. jw.Msg = "请选择正确的团组!";
  16975. return Ok(jw);
  16976. }
  16977. else
  16978. {
  16979. diid = Find.Id;
  16980. }
  16981. //数据源
  16982. var _travelList = new List<Grp_TravelList>();
  16983. DataTable dtBlack = null;
  16984. try
  16985. {
  16986. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  16987. }
  16988. catch (Exception)
  16989. {
  16990. jw.Msg = "机票黑屏代码有误!";
  16991. return Ok(jw);
  16992. }
  16993. string CityStr = string.Empty;
  16994. if (dtBlack.Rows.Count == 0)
  16995. {
  16996. jw.Msg = "机票黑屏代码有误!";
  16997. return Ok(jw);
  16998. }
  16999. else
  17000. {
  17001. foreach (DataRow row in dtBlack.Rows)
  17002. {
  17003. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17004. {
  17005. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  17006. return Ok(jw);
  17007. }
  17008. }
  17009. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  17010. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  17011. }
  17012. // 指定的文字
  17013. var targetTextDic = new Dictionary<string, List<string>>();
  17014. //创建数据源Table
  17015. var dtSource = new DataTable();
  17016. dtSource.Columns.Add("Days", typeof(string));
  17017. dtSource.Columns.Add("Date", typeof(string));
  17018. dtSource.Columns.Add("Week", typeof(string));
  17019. dtSource.Columns.Add("Traffic", typeof(string));
  17020. dtSource.Columns.Add("Trip", typeof(string));
  17021. //获取数据,放到datatable
  17022. foreach (var item in _travelList)
  17023. {
  17024. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  17025. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  17026. .Replace(tagContent.TagFormat.Item2, string.Empty)
  17027. .Replace("[++]", string.Empty);
  17028. DataRow dr = dtSource.NewRow();
  17029. dr["Days"] = item.Days;
  17030. dr["Date"] = item.Date;
  17031. dr["Week"] = item.WeekDay;
  17032. dr["Traffic"] = item.Traffic_First
  17033. + "\r\n"
  17034. + item.Traffic_Second;
  17035. dr["Trip"] = item.Trip;
  17036. dtSource.Rows.Add(dr);
  17037. }
  17038. var dic = new Dictionary<string, string>
  17039. {
  17040. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  17041. { "City", CityStr },
  17042. { "Days", Find.VisitDays.ToString() },
  17043. { "DeleCode", Find.TourCode },
  17044. { "Pnum", Find.VisitPNumber.ToString() }
  17045. };
  17046. //模板路径
  17047. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  17048. //载入模板
  17049. Document doc = null;
  17050. DocumentBuilder builder = null;
  17051. try
  17052. {
  17053. //载入模板
  17054. doc = new Document(tempPath);
  17055. builder = new DocumentBuilder(doc);
  17056. }
  17057. catch (Exception)
  17058. {
  17059. jw.Msg = "模板位置不存在!";
  17060. return Ok(jw);
  17061. }
  17062. foreach (var key in dic.Keys)
  17063. {
  17064. Bookmark bookmark = doc.Range.Bookmarks[key];
  17065. if (bookmark != null)
  17066. {
  17067. builder.MoveToBookmark(key);
  17068. builder.Write(dic[key]);
  17069. }
  17070. }
  17071. //获取word里所有表格
  17072. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17073. //获取所填表格的序数
  17074. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17075. try
  17076. {
  17077. //循环赋值
  17078. for (int i = 0; i < dtSource.Rows.Count; i++)
  17079. {
  17080. builder.MoveToCell(0, i + 1, 0, 0);
  17081. builder.Write(dtSource.Rows[i]["Days"].ToString());
  17082. builder.MoveToCell(0, i + 1, 1, 0);
  17083. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  17084. builder.MoveToCell(0, i + 1, 2, 0);
  17085. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  17086. var trip = dtSource.Rows[i]["Trip"].ToString();
  17087. builder.MoveToCell(0, i + 1, 3, 0);
  17088. builder.Write(trip);
  17089. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  17090. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  17091. // 获取特定索引的段落
  17092. Paragraph paragraph = (Paragraph)paragraphs[0];
  17093. Run run = paragraph.Runs[0];
  17094. Aspose.Words.Font font = run.Font;
  17095. font.Name = "黑体";
  17096. //设置双休红色
  17097. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  17098. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  17099. paragraph = (Paragraph)paragraphs[1];
  17100. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  17101. {
  17102. run = paragraph.Runs[0];
  17103. font = run.Font;
  17104. font.Color = Color.Red;
  17105. }
  17106. }
  17107. }
  17108. catch (Exception ex)
  17109. {
  17110. }
  17111. //删除多余行
  17112. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  17113. {
  17114. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  17115. }
  17116. var targetTextList = new List<string>();
  17117. // 遍历文档中的表格
  17118. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17119. {
  17120. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17121. {
  17122. var cellIndex = 0;
  17123. foreach (Cell cell in row.Cells)
  17124. {
  17125. if (cellIndex == 1 && row.Cells.Count == 4)
  17126. {
  17127. foreach (var target in targetTextDic.Keys)
  17128. {
  17129. if (cell.GetText().Contains(target))
  17130. {
  17131. targetTextList = targetTextDic[target];
  17132. break;
  17133. }
  17134. }
  17135. }
  17136. // 遍历单元格中的所有段落
  17137. foreach (Paragraph paragraph in cell.Paragraphs)
  17138. {
  17139. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  17140. var runs = new List<Run>();
  17141. foreach (Run run in paragraph.Runs)
  17142. {
  17143. runs.Add(run);
  17144. }
  17145. foreach (Run run in runs)
  17146. {
  17147. foreach (var targetText in targetTextList)
  17148. {
  17149. // 检查文字是否包含指定文字
  17150. if (run.Text.Contains(targetText))
  17151. {
  17152. // 将包含的部分设置为红色
  17153. HighlightText(run, targetText, Color.Red);
  17154. }
  17155. }
  17156. }
  17157. }
  17158. cellIndex++;
  17159. }
  17160. }
  17161. }
  17162. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  17163. if (!Directory.Exists(savePath))
  17164. {
  17165. try
  17166. {
  17167. Directory.CreateDirectory(savePath);
  17168. }
  17169. catch
  17170. {
  17171. }
  17172. }
  17173. string path = savePath + Find.TeamName + "出访日程";
  17174. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  17175. try
  17176. {
  17177. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  17178. string postfix = ".docx";
  17179. if (dto.IsPDF == 1)
  17180. {
  17181. saveFormat = Aspose.Words.SaveFormat.Pdf;
  17182. postfix = ".pdf";
  17183. }
  17184. doc.Save(path + postfix, saveFormat);
  17185. jw = JsonView(true, "导出成功", ftpPath + postfix);
  17186. }
  17187. catch (Exception)
  17188. {
  17189. jw = JsonView(false);
  17190. }
  17191. return Ok(jw);
  17192. }
  17193. /// <summary>
  17194. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  17195. /// </summary>
  17196. /// <param name="num"></param>
  17197. /// <returns></returns>
  17198. static string GetNum(string num)
  17199. {
  17200. string str = "";
  17201. switch (num)
  17202. {
  17203. case "1":
  17204. str = "一";
  17205. break;
  17206. case "2":
  17207. str = "二";
  17208. break;
  17209. case "3":
  17210. str = "三";
  17211. break;
  17212. case "4":
  17213. str = "四";
  17214. break;
  17215. case "5":
  17216. str = "五";
  17217. break;
  17218. case "6":
  17219. str = "六";
  17220. break;
  17221. case "7":
  17222. str = "七";
  17223. break;
  17224. case "8":
  17225. str = "八";
  17226. break;
  17227. case "9":
  17228. str = "九";
  17229. break;
  17230. case "10":
  17231. str = "十";
  17232. break;
  17233. case "11":
  17234. str = "十一";
  17235. break;
  17236. case "12":
  17237. str = "十二";
  17238. break;
  17239. case "一":
  17240. str = "1";
  17241. break;
  17242. case "二":
  17243. str = "2";
  17244. break;
  17245. case "三":
  17246. str = "3";
  17247. break;
  17248. case "四":
  17249. str = "4";
  17250. break;
  17251. case "五":
  17252. str = "5";
  17253. break;
  17254. case "六":
  17255. str = "6";
  17256. break;
  17257. case "七":
  17258. str = "7";
  17259. break;
  17260. case "八":
  17261. str = "8";
  17262. break;
  17263. case "九":
  17264. str = "9";
  17265. break;
  17266. case "十":
  17267. str = "10";
  17268. break;
  17269. case "十一":
  17270. str = "11";
  17271. break;
  17272. case "十二":
  17273. str = "12";
  17274. break;
  17275. }
  17276. return str;
  17277. }
  17278. /// <summary>
  17279. /// 高亮包含指定文字的部分
  17280. /// </summary>
  17281. /// <param name="run"></param>
  17282. /// <param name="targetText"></param>
  17283. /// <param name="color"></param>
  17284. static void HighlightText(Run run, string targetText, Color color)
  17285. {
  17286. string text = run.Text;
  17287. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  17288. if (startIndex >= 0)
  17289. {
  17290. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  17291. // 前部分
  17292. if (startIndex > 0)
  17293. {
  17294. Run beforeRun = (Run)run.Clone(true);
  17295. beforeRun.Text = text.Substring(0, startIndex);
  17296. parentParagraph.InsertBefore(beforeRun, run);
  17297. }
  17298. // 匹配部分
  17299. Run matchRun = (Run)run.Clone(true);
  17300. matchRun.Text = text.Substring(startIndex, targetText.Length);
  17301. matchRun.Font.Color = color;
  17302. parentParagraph.InsertBefore(matchRun, run);
  17303. // 后部分
  17304. if (startIndex + targetText.Length < text.Length)
  17305. {
  17306. Run afterRun = (Run)run.Clone(true);
  17307. afterRun.Text = text.Substring(startIndex + targetText.Length);
  17308. parentParagraph.InsertBefore(afterRun, run);
  17309. }
  17310. // 删除原始Run
  17311. run.Remove();
  17312. }
  17313. }
  17314. #endregion
  17315. #endregion
  17316. #region 团组成本
  17317. /// <summary>
  17318. /// 团组成本数据初始化
  17319. /// </summary>
  17320. /// <param name="dto"></param>
  17321. /// <returns></returns>
  17322. [HttpPost]
  17323. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  17324. {
  17325. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17326. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17327. WHEN COUNT(*) >= 0 THEN 'True'
  17328. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17329. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  17330. ").ToList(); //团组列表
  17331. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  17332. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  17333. var visaCountryInfoArr = new ArrayList();
  17334. var groupinfoValue = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == diid && x.IsDel == 0);
  17335. if (groupinfoValue != null)
  17336. {
  17337. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  17338. var dicity = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == groupinfoValue.CityId);
  17339. dicity ??= new Sys_Cities()
  17340. {
  17341. ParentId = 122
  17342. };
  17343. var diparent = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == dicity.ParentId);
  17344. var spArr = new string[1] { countryArr };
  17345. if (countryArr.Contains("|"))
  17346. {
  17347. spArr = countryArr.Split("|");
  17348. }
  17349. else if (countryArr.Contains("、"))
  17350. {
  17351. spArr = countryArr.Split("、");
  17352. }
  17353. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  17354. {
  17355. try
  17356. {
  17357. var visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  17358. .Where(x => x.IsDel == 0 && x.Country == item)
  17359. .ToList();
  17360. if (!visa.Any())
  17361. {
  17362. visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  17363. .Where(x => x.IsDel == 0 && x.Country.Contains(item))
  17364. .ToList();
  17365. }
  17366. if (visa.Any())
  17367. {
  17368. var visainfo = _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  17369. .Where(x => x.IsDel == 0 && visa.Select(x => x.Id).Contains(x.ParentId))
  17370. .ToList();
  17371. var visaMain = visainfo.FirstOrDefault(x => x.ProvinceId == diparent.Id);
  17372. var visayinsiValue = visainfo.FirstOrDefault(x => x.ParentId == visa.FirstOrDefault(x => x.FeeType == 1)?.Id);
  17373. visaCountryInfoArr.Add(new
  17374. {
  17375. country = item,
  17376. yinsi = new
  17377. {
  17378. Id = visayinsiValue.Id,
  17379. value = visayinsiValue.SmallVisaPrice
  17380. },
  17381. visaMain = new
  17382. {
  17383. Id = visaMain.Id,
  17384. IsVisaOnArrival = visaMain.IsVisaOnArrival ? "是" : "否",
  17385. IsElectronicSign = visaMain.IsElectronicSign ? "是" : "否",
  17386. VisaTime = visaMain.VisaTime,
  17387. IsVisaExemptionLarge = visaMain.IsVisaExemptionLarge ? "是" : "否",
  17388. LargeVisaPrice = visaMain.LargeVisaPrice,
  17389. LargeAgencyFee = visaMain.LargeAgencyFee,
  17390. IsVisaExemptionSmall = visaMain.IsVisaExemptionSmall ? "是" : "否",
  17391. SmallVisaPrice = visaMain.SmallVisaPrice,
  17392. SmallAgencyFee = visaMain.SmallAgencyFee,
  17393. NormExtFee = visaMain.NormExtFee,
  17394. UrgExtFee = visaMain.UrgExtFee,
  17395. IsUrgent = visaMain.IsUrgent ? "是" : "否",
  17396. UrgentTime = visaMain.UrgentTime,
  17397. UrgentPrice = visaMain.UrgentPrice,
  17398. UrgentPriceDesc = visaMain.UrgentPriceDesc,
  17399. Remark = visaMain.Remark,
  17400. }
  17401. });
  17402. }
  17403. }
  17404. catch (Exception ex)
  17405. {
  17406. //写入日志
  17407. _logger.LogError(ex, "团组成本解析签证异常!");
  17408. }
  17409. }
  17410. }
  17411. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  17412. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  17413. #region 屏蔽黑屏代码生成
  17414. //var create = _GroupCostRepository.
  17415. // CreateGroupCostByBlackCode(dto.Diid);
  17416. //if (groupCost.Count == 0 && create.Code == 0)
  17417. //{
  17418. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  17419. //}
  17420. #endregion
  17421. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  17422. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  17423. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  17424. groupCostMap = groupCostMap.Select(x =>
  17425. {
  17426. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  17427. {
  17428. x.Date = dataForamt.ToString("yyyy-MM-dd");
  17429. }
  17430. return x;
  17431. }).ToList();
  17432. //GroupCostParameter.Add(new
  17433. // Grp_GroupCostParameter());
  17434. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  17435. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  17436. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  17437. return Ok(JsonView(new
  17438. {
  17439. groupList,
  17440. groupInfo,
  17441. groupChecks,
  17442. groupCost = groupCostMap,
  17443. hotelNumber,
  17444. GroupCostParameter = GroupCostParameterMap,
  17445. visaCountryInfoArr = visaCountryInfoArr,
  17446. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  17447. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  17448. hotelIsTrue,
  17449. groupModuleOperators
  17450. }));
  17451. }
  17452. /// <summary>
  17453. /// 团组成本信息保存
  17454. /// </summary>
  17455. /// <param name="dto"></param>
  17456. /// <returns></returns>
  17457. [HttpPost]
  17458. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  17459. {
  17460. if (dto.Diid <= 0 || dto.Userid <= 0)
  17461. {
  17462. return Ok(JsonView(false));
  17463. }
  17464. JsonView jw = null;
  17465. bool isTrue = false;
  17466. #region 复制团组成本
  17467. //if (dto.Diid == 2581)
  17468. //{
  17469. // dto.Diid = 2599;
  17470. // dto.CheckBoxs.ForEach(x =>
  17471. // {
  17472. // x.Diid = 2599;
  17473. // });
  17474. // dto.GroupCosts.ForEach(x =>
  17475. // {
  17476. // x.Diid = 2599;
  17477. // });
  17478. // dto.CostTypeHotelNumbers.ForEach(x =>
  17479. // {
  17480. // x.Diid = 2599;
  17481. // });
  17482. // dto.GroupCostParameters.ForEach(x =>
  17483. // {
  17484. // x.DiId = 2599;
  17485. // });
  17486. //}
  17487. #endregion
  17488. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  17489. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  17490. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  17491. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  17492. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  17493. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  17494. try
  17495. {
  17496. _sqlSugar.BeginTran();
  17497. isTrue = await _GroupCostRepository.
  17498. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  17499. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  17500. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  17501. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  17502. _sqlSugar.CommitTran();
  17503. jw = JsonView(true, "保存成功!", isTrue);
  17504. }
  17505. catch (Exception)
  17506. {
  17507. _sqlSugar.RollbackTran();
  17508. jw = JsonView(false);
  17509. }
  17510. return Ok(jw);
  17511. }
  17512. /// <summary>
  17513. /// 复制团组成本信息
  17514. /// </summary>
  17515. /// <param name="dto"></param>
  17516. /// <returns></returns>
  17517. [HttpPost]
  17518. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  17519. {
  17520. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  17521. {
  17522. return Ok(JsonView(false, "参数有误!"));
  17523. }
  17524. #region 复制团组成本
  17525. dto.Diid = dto.ToGroupId;
  17526. dto.CheckBoxs.ForEach(x =>
  17527. {
  17528. x.Diid = dto.ToGroupId;
  17529. });
  17530. dto.GroupCosts.ForEach(x =>
  17531. {
  17532. x.Diid = dto.ToGroupId;
  17533. });
  17534. dto.CostTypeHotelNumbers.ForEach(x =>
  17535. {
  17536. x.Diid = dto.ToGroupId;
  17537. });
  17538. dto.GroupCostParameters.ForEach(x =>
  17539. {
  17540. x.DiId = dto.ToGroupId;
  17541. });
  17542. #endregion
  17543. JsonView jw = null;
  17544. bool isTrue = false;
  17545. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  17546. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  17547. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  17548. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  17549. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  17550. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  17551. try
  17552. {
  17553. _sqlSugar.BeginTran();
  17554. isTrue = await _GroupCostRepository.
  17555. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  17556. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  17557. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  17558. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  17559. _sqlSugar.CommitTran();
  17560. jw = JsonView(true, "保存成功!", isTrue);
  17561. }
  17562. catch (Exception)
  17563. {
  17564. _sqlSugar.RollbackTran();
  17565. jw = JsonView(false);
  17566. }
  17567. return Ok(jw);
  17568. }
  17569. /// <summary>
  17570. /// 司兼导数据
  17571. /// </summary>
  17572. /// <param name="dto"></param>
  17573. /// <returns></returns>
  17574. [HttpPost]
  17575. public IActionResult GetCarGuides(CarGuidesDto dto)
  17576. {
  17577. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  17578. return Ok(JsonView(true, "获取成功!", Data));
  17579. }
  17580. /// <summary>
  17581. /// 导游数据
  17582. /// </summary>
  17583. /// <param name="dto"></param>
  17584. /// <returns></returns>
  17585. [HttpPost]
  17586. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  17587. {
  17588. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  17589. // 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
  17590. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  17591. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  17592. return Ok(JsonView(true, "获取成功!", Data));
  17593. }
  17594. /// <summary>
  17595. /// 成本车数据
  17596. /// </summary>
  17597. /// <param name="dto"></param>
  17598. /// <returns></returns>
  17599. [HttpPost]
  17600. public IActionResult GetCarInfo(CarGuidesDto dto)
  17601. {
  17602. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  17603. return Ok(JsonView(true, "获取成功!", Data));
  17604. }
  17605. /// <summary>
  17606. /// 景点数据
  17607. /// </summary>
  17608. /// <param name="dto"></param>
  17609. /// <returns></returns>
  17610. [HttpPost]
  17611. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  17612. {
  17613. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  17614. return Ok(JsonView(true, "获取成功!", Data));
  17615. }
  17616. /// <summary>
  17617. /// 成本通知
  17618. /// </summary>
  17619. /// <param name="dto"></param>
  17620. /// <returns></returns>
  17621. [HttpPost]
  17622. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  17623. {
  17624. if (dto.Diid < 0)
  17625. {
  17626. return Ok(JsonView(false));
  17627. }
  17628. JsonView jw;
  17629. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17630. if (GroupCostParameter != null)
  17631. {
  17632. int IsShare = 0;
  17633. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  17634. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  17635. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  17636. string msg = string.Empty;
  17637. if (isTrue)
  17638. {
  17639. if (IsShare == 0)
  17640. {
  17641. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  17642. }
  17643. else
  17644. {
  17645. #region 企微通知对应岗位用户
  17646. try
  17647. {
  17648. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  17649. //机票预算群通知
  17650. await AppNoticeLibrary.SendChatMsg_AirCostChat(dto.Diid, QiyeWeChatEnum.AirCostChat01);
  17651. }
  17652. catch (Exception)
  17653. {
  17654. }
  17655. #endregion
  17656. msg = "通知成功,其他模块操作人员可见此成本信息!";
  17657. }
  17658. jw = JsonView(isTrue, msg, new { IsShare });
  17659. }
  17660. else
  17661. {
  17662. msg = "修改失败!";
  17663. jw = JsonView(isTrue, msg);
  17664. }
  17665. }
  17666. else
  17667. {
  17668. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  17669. }
  17670. return Ok(jw);
  17671. }
  17672. /// <summary>
  17673. /// 导出报价单
  17674. /// </summary>
  17675. /// <param name="dto"></param>
  17676. /// <returns></returns>
  17677. [HttpPost]
  17678. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  17679. {
  17680. if (dto.Diid == 0)
  17681. {
  17682. return Ok(JsonView(false, "请传递团组id"));
  17683. }
  17684. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  17685. if (deleInfo.Code != 0)
  17686. {
  17687. return Ok(JsonView(false, "团组信息查询失败!"));
  17688. }
  17689. var di = deleInfo.Data as DelegationInfoWebView;
  17690. if (di != null)
  17691. {
  17692. di.TeamName = di.TeamName.Replace("|", "、");
  17693. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  17694. //文件名
  17695. string strFileName = di.TeamName + "-收款账单.doc";
  17696. //获取模板
  17697. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  17698. //载入模板
  17699. Document doc = new Document(tmppath);
  17700. decimal TotalPrice = 0.00M;
  17701. string itemStr = string.Empty;
  17702. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  17703. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  17704. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  17705. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  17706. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  17707. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  17708. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  17709. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  17710. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  17711. foreach (var cost in groupCostType)
  17712. {
  17713. var List = cost.ToList();
  17714. if (cost.Key == "A")
  17715. {
  17716. foreach (var ListItem in List)
  17717. {
  17718. if (ListItem.number > 0)
  17719. {
  17720. if (ListItem.code.Contains("TBR"))
  17721. {
  17722. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17723. }
  17724. else
  17725. {
  17726. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17727. }
  17728. TotalPrice += (ListItem.number * ListItem.price);
  17729. }
  17730. }
  17731. }
  17732. else
  17733. {
  17734. itemStr = itemStr.Insert(0, "A段\r\n");
  17735. itemStr += "B段\r\n";
  17736. foreach (var ListItem in List)
  17737. {
  17738. if (ListItem.number > 0)
  17739. {
  17740. if (ListItem.code.Contains("TBR"))
  17741. {
  17742. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17743. }
  17744. else
  17745. {
  17746. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17747. }
  17748. TotalPrice += (ListItem.number * ListItem.price);
  17749. }
  17750. }
  17751. }
  17752. }
  17753. #region 替换Word模板书签内容
  17754. Dictionary<string, string> marks = new Dictionary<string, string>();
  17755. marks.Add("To", di.ClientUnit);//付款方
  17756. marks.Add("ToTel", di.TellPhone);//付款方电话
  17757. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17758. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17759. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17760. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17761. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17762. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17763. marks.Add("PayItemContent", itemStr);//详细信息
  17764. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  17765. #endregion
  17766. ////注
  17767. //if (doc.Range.Bookmarks["Attention"] != null)
  17768. //{
  17769. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  17770. // mark.Text = frList[0].Attention;
  17771. //}
  17772. foreach (var item in marks.Keys)
  17773. {
  17774. if (doc.Range.Bookmarks[item] != null)
  17775. {
  17776. Bookmark mark = doc.Range.Bookmarks[item];
  17777. mark.Text = marks[item];
  17778. }
  17779. }
  17780. byte[] bytes = null;
  17781. using (MemoryStream stream = new MemoryStream())
  17782. {
  17783. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  17784. bytes = stream.ToArray();
  17785. }
  17786. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  17787. return Ok(JsonView(true, "", new
  17788. {
  17789. Data = bytes,
  17790. strFileName,
  17791. }));
  17792. }
  17793. else
  17794. {
  17795. return Ok(JsonView(false, "团组信息不存在!"));
  17796. }
  17797. }
  17798. /// <summary>
  17799. /// 导出团组成本
  17800. /// </summary>
  17801. /// <param name="dto"></param>
  17802. /// <returns></returns>
  17803. [HttpPost]
  17804. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  17805. {
  17806. var jw = JsonView(false);
  17807. if (dto.Diid == 0)
  17808. {
  17809. return Ok(JsonView(false, "请传递团组id"));
  17810. }
  17811. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  17812. if (deleInfo.Code != 0)
  17813. {
  17814. return Ok(JsonView(false, "团组信息查询失败!"));
  17815. }
  17816. var di = deleInfo.Data as DelegationInfoWebView;
  17817. if (di == null)
  17818. {
  17819. return Ok(JsonView(false, "团组信息查询失败!"));
  17820. }
  17821. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  17822. WorkbookDesigner designer = new WorkbookDesigner();
  17823. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  17824. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  17825. List<int> hideColumnList = new List<int>();
  17826. var ColumnSetting = new[]
  17827. {
  17828. new { tag = "VF", Index = 4, P = "CarCost" },
  17829. new { tag = "VN", Index = 5, P = "CarNumber" },
  17830. new { tag = "VRD", Index = 6, P = "CarTiming" },
  17831. new { tag = "T/G S", Index = 7, P = "TGS" },
  17832. new { tag = "TGWH", Index = 8, P = "TGWH" },
  17833. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  17834. new { tag = "T/G M", Index = 10, P = "TGM" },
  17835. new { tag = "T/G A", Index = 11, P = "TGA" },
  17836. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  17837. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  17838. new { tag = "C/F S", Index = 14, P = "CFS" },
  17839. new { tag = "C/F M", Index = 15, P = "CFM" },
  17840. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  17841. new { tag = "B", Index = 17, P = "B" },
  17842. new { tag = "L", Index = 18, P = "L" },
  17843. new { tag = "D", Index = 19, P = "D" },
  17844. new { tag = "TBR", Index = 20, P = "TBR" },
  17845. new { tag = "SGR", Index = 21, P = "SGR" },
  17846. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  17847. new { tag = "Suite", Index = 23, P = "Suite" },
  17848. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  17849. new { tag = "T/V", Index = 25, P = "TV" },
  17850. new { tag = "1/L", Index = 26, P = "iL" },
  17851. new { tag = "I/F", Index = 27, P = "IF" },
  17852. new { tag = "EF", Index = 28, P = "EF" },
  17853. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  17854. new { tag = "TE", Index = 30, P = "TE" },
  17855. new { tag = "T/G T", Index = 31, P = "TGTips" },
  17856. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  17857. new { tag = "P/C", Index = 33, P = "PC" },
  17858. new { tag = "T/L F", Index = 34, P = "TLF" },
  17859. new { tag = "E/C T", Index = 35, P = "ECT" }
  17860. };
  17861. Func<string, bool> isEmpty = (str) =>
  17862. {
  17863. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  17864. {
  17865. return true;
  17866. }
  17867. if (string.IsNullOrWhiteSpace(str))
  17868. {
  17869. return true;
  17870. }
  17871. return false;
  17872. };
  17873. for (int i = 0; i < List_GC.Count; i++)
  17874. {
  17875. GroupCost_Excel gc = new GroupCost_Excel();
  17876. gc.Id = List_GC[i].Id;
  17877. gc.Diid = List_GC[i].Diid.ToString();
  17878. gc.DAY = List_GC[i].DAY;
  17879. string week = "";
  17880. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  17881. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  17882. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  17883. gc.ITIN = List_GC[i].ITIN;
  17884. gc.CarType = List_GC[i].CarType;
  17885. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  17886. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  17887. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  17888. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  17889. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  17890. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  17891. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  17892. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  17893. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  17894. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  17895. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  17896. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  17897. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  17898. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  17899. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  17900. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  17901. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  17902. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  17903. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  17904. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  17905. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  17906. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  17907. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  17908. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  17909. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  17910. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  17911. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  17912. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  17913. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  17914. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  17915. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  17916. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  17917. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  17918. gc.EFR = List_GC[i].EFR;
  17919. List_GC1.Add(gc);
  17920. }
  17921. if (List_GC1.Count > 0)
  17922. {
  17923. var p = List_GC1[0];
  17924. var prs = p.GetType().GetProperties();
  17925. foreach (var item in prs)
  17926. {
  17927. var tp = item.PropertyType;
  17928. if (tp == typeof(int))
  17929. {
  17930. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  17931. if (val == 0)
  17932. {
  17933. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  17934. if (columnSetting != null)
  17935. {
  17936. hideColumnList.Add(columnSetting.Index);
  17937. }
  17938. }
  17939. }
  17940. if (tp == typeof(decimal))
  17941. {
  17942. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  17943. if (val == 0)
  17944. {
  17945. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  17946. if (columnSetting != null)
  17947. {
  17948. hideColumnList.Add(columnSetting.Index);
  17949. }
  17950. }
  17951. }
  17952. if (tp == typeof(string))
  17953. {
  17954. var val = List_GC1.Sum(x =>
  17955. {
  17956. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  17957. if (decimal.TryParse(str, out decimal str_De))
  17958. {
  17959. return str_De;
  17960. }
  17961. else
  17962. {
  17963. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  17964. }
  17965. });
  17966. if (val == 0)
  17967. {
  17968. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  17969. if (columnSetting != null)
  17970. {
  17971. hideColumnList.Add(columnSetting.Index);
  17972. }
  17973. }
  17974. }
  17975. }
  17976. }
  17977. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  17978. dt.TableName = "TB";
  17979. //报表标题等不用dt的值
  17980. designer.SetDataSource("TeamName", dto.title.TeamName);
  17981. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  17982. designer.SetDataSource("Tax", dto.title.Tax);
  17983. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  17984. designer.SetDataSource("Currency", dto.title.Currency);
  17985. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  17986. designer.SetDataSource("Rate", dto.title.Rate);
  17987. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  17988. var Aparams = hotels.Find(x => x.Type == "Default");
  17989. if (Aparams == null)
  17990. {
  17991. return Ok(jw);
  17992. }
  17993. //酒店数量
  17994. var txtSGRNumber = Aparams.SGR.ToString();
  17995. var txtTBRNumber = Aparams.TBR.ToString();
  17996. var txtJSESNumber = Aparams.JSES.ToString();
  17997. var txtSUITENumbe = Aparams.SUITE.ToString();
  17998. if (dto.costType == "B")
  17999. {
  18000. Aparams = hotels.Find(x => x.Type == "A");
  18001. var Bparams = hotels.Find(x => x.Type == "B");
  18002. if (Aparams == null || Bparams == null)
  18003. {
  18004. return Ok(jw);
  18005. }
  18006. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  18007. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  18008. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  18009. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  18010. }
  18011. designer.SetDataSource("SGRNumber", txtSGRNumber);
  18012. designer.SetDataSource("TBRNumber", txtTBRNumber);
  18013. designer.SetDataSource("JSESNumber", txtJSESNumber);
  18014. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  18015. var ws = designer.Workbook.Worksheets[1];
  18016. int Row = List_GC.Count;
  18017. int startIndex = 0;
  18018. int HideRows = 0;
  18019. Row = 0;
  18020. List<int> hideRowsList = new List<int>();
  18021. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  18022. #region A段left数据
  18023. var left = dto.leftInfo.Find(x => x.Type == "A");
  18024. if (left == null)
  18025. {
  18026. return Ok(jw);
  18027. }
  18028. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  18029. if (leftBindData != null)
  18030. {
  18031. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  18032. designer.SetDataSource("VisaRS", leftBindData.rs);
  18033. designer.SetDataSource("VisaXS", leftBindData.xs);
  18034. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18035. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18036. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18037. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18038. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18039. }
  18040. else
  18041. {
  18042. hideRowsList.Add(Row + startIndex + HideRows);
  18043. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18044. }
  18045. HideRows += 2;
  18046. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  18047. if (leftBindData != null)
  18048. {
  18049. designer.SetDataSource("BXDRCB", leftBindData.cb);
  18050. designer.SetDataSource("BXRS", leftBindData.rs);
  18051. designer.SetDataSource("BXXS", leftBindData.xs);
  18052. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18053. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18054. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18055. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18056. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18057. }
  18058. else
  18059. {
  18060. hideRowsList.Add(Row + startIndex + HideRows);
  18061. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18062. }
  18063. HideRows += 2;
  18064. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  18065. if (leftBindData != null)
  18066. {
  18067. designer.SetDataSource("HSDRCB", leftBindData.cb);
  18068. designer.SetDataSource("HSRS", leftBindData.rs);
  18069. designer.SetDataSource("HSXS", leftBindData.xs);
  18070. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18071. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18072. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18073. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18074. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18075. }
  18076. else
  18077. {
  18078. hideRowsList.Add(Row + startIndex + HideRows);
  18079. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18080. }
  18081. HideRows += 2;
  18082. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  18083. if (leftBindData != null)
  18084. {
  18085. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  18086. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  18087. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  18088. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18089. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18090. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18091. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18092. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18093. }
  18094. else
  18095. {
  18096. hideRowsList.Add(Row + startIndex + HideRows);
  18097. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18098. }
  18099. HideRows += 2;
  18100. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  18101. if (leftBindData != null)
  18102. {
  18103. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  18104. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  18105. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  18106. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18107. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18108. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18109. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18110. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18111. }
  18112. else
  18113. {
  18114. hideRowsList.Add(Row + startIndex + HideRows);
  18115. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18116. }
  18117. HideRows += 2;
  18118. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  18119. if (leftBindData != null)
  18120. {
  18121. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  18122. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  18123. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  18124. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18125. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18126. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18127. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18128. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18129. }
  18130. else
  18131. {
  18132. hideRowsList.Add(Row + startIndex + HideRows);
  18133. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18134. }
  18135. HideRows += 2;
  18136. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  18137. if (leftBindData != null)
  18138. {
  18139. ////TBR
  18140. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  18141. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  18142. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  18143. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18144. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18145. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18146. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18147. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18148. }
  18149. else
  18150. {
  18151. hideRowsList.Add(Row + startIndex + HideRows);
  18152. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18153. }
  18154. HideRows += 2;
  18155. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  18156. if (leftBindData != null)
  18157. {
  18158. ////SGR
  18159. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  18160. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  18161. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  18162. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18163. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18164. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18165. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18166. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18167. }
  18168. else
  18169. {
  18170. hideRowsList.Add(Row + startIndex + HideRows);
  18171. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18172. }
  18173. HideRows += 2;
  18174. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  18175. if (leftBindData != null)
  18176. {
  18177. ////JS/ES
  18178. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  18179. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  18180. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  18181. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18182. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18183. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18184. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18185. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18186. }
  18187. else
  18188. {
  18189. hideRowsList.Add(Row + startIndex + HideRows);
  18190. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18191. }
  18192. HideRows += 2;
  18193. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  18194. if (leftBindData != null)
  18195. {
  18196. ////SUITE
  18197. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  18198. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  18199. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  18200. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18201. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18202. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18203. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18204. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18205. }
  18206. else
  18207. {
  18208. hideRowsList.Add(Row + startIndex + HideRows);
  18209. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18210. }
  18211. HideRows += 2;
  18212. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  18213. if (leftBindData != null)
  18214. {
  18215. designer.SetDataSource("DJDRCB", leftBindData.cb);
  18216. designer.SetDataSource("DJRS", leftBindData.rs);
  18217. designer.SetDataSource("DJXS", leftBindData.xs);
  18218. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18219. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18220. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18221. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18222. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18223. }
  18224. else
  18225. {
  18226. hideRowsList.Add(Row + startIndex + HideRows);
  18227. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18228. }
  18229. HideRows += 2;
  18230. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  18231. if (leftBindData != null)
  18232. {
  18233. designer.SetDataSource("HCPCB", leftBindData.cb);
  18234. designer.SetDataSource("HCPRS", leftBindData.rs);
  18235. designer.SetDataSource("HCPXS", leftBindData.xs);
  18236. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18237. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18238. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18239. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18240. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18241. }
  18242. else
  18243. {
  18244. hideRowsList.Add(Row + startIndex + HideRows);
  18245. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18246. }
  18247. HideRows += 2;
  18248. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  18249. if (leftBindData != null)
  18250. {
  18251. designer.SetDataSource("CPCB", leftBindData.cb);
  18252. designer.SetDataSource("CPRS", leftBindData.rs);
  18253. designer.SetDataSource("CPXS", leftBindData.xs);
  18254. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18255. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18256. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18257. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18258. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18259. }
  18260. else
  18261. {
  18262. hideRowsList.Add(Row + startIndex + HideRows);
  18263. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18264. }
  18265. HideRows += 2;
  18266. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  18267. if (leftBindData != null)
  18268. {
  18269. designer.SetDataSource("GWDRCD", leftBindData.cb);
  18270. designer.SetDataSource("GWRS", leftBindData.rs);
  18271. designer.SetDataSource("GWXS", leftBindData.xs);
  18272. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18273. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18274. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18275. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18276. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18277. }
  18278. else
  18279. {
  18280. hideRowsList.Add(Row + startIndex + HideRows);
  18281. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18282. }
  18283. HideRows += 2;
  18284. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  18285. if (leftBindData != null)
  18286. {
  18287. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  18288. designer.SetDataSource("LYJRS", leftBindData.rs);
  18289. designer.SetDataSource("LYJXS", leftBindData.xs);
  18290. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18291. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18292. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18293. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18294. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18295. }
  18296. else
  18297. {
  18298. hideRowsList.Add(Row + startIndex + HideRows);
  18299. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18300. }
  18301. #endregion
  18302. #region A段Right信息
  18303. var right = dto.rightInfo.Find(x => x.Type == "A");
  18304. if (right == null)
  18305. {
  18306. return Ok(jw);
  18307. }
  18308. HideRows += 4;
  18309. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  18310. if (rightBindData != null)
  18311. {
  18312. //经济舱 + 双人间 TBR
  18313. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  18314. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  18315. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18316. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  18317. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18318. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18319. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18320. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18321. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18322. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18323. }
  18324. else
  18325. {
  18326. hideRowsList.Add(Row + startIndex + HideRows);
  18327. }
  18328. HideRows += 2;
  18329. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  18330. if (rightBindData != null)
  18331. {
  18332. //经济舱 + 单人间 SGR
  18333. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  18334. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  18335. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18336. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  18337. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18338. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18339. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18340. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18341. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18342. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18343. }
  18344. else
  18345. {
  18346. hideRowsList.Add(Row + startIndex + HideRows);
  18347. }
  18348. HideRows += 2;
  18349. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  18350. if (rightBindData != null)
  18351. {
  18352. //公务舱 + 单人间 SGR
  18353. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  18354. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  18355. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18356. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  18357. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18358. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18359. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18360. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18361. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18362. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18363. }
  18364. else
  18365. {
  18366. hideRowsList.Add(Row + startIndex + HideRows);
  18367. }
  18368. HideRows += 2;
  18369. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  18370. if (rightBindData != null)
  18371. {
  18372. //公务舱 + 小套房 JSES
  18373. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  18374. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  18375. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18376. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  18377. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18378. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18379. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18380. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18381. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18382. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18383. }
  18384. else
  18385. {
  18386. hideRowsList.Add(Row + startIndex + HideRows);
  18387. }
  18388. HideRows += 2;
  18389. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  18390. if (rightBindData != null)
  18391. {
  18392. //公务舱 + 小套房 JSES
  18393. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  18394. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  18395. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18396. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  18397. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18398. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18399. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18400. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18401. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18402. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18403. }
  18404. else
  18405. {
  18406. hideRowsList.Add(Row + startIndex + HideRows);
  18407. }
  18408. HideRows += 2;
  18409. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  18410. if (rightBindData != null)
  18411. {
  18412. //经济舱 + 大套房
  18413. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  18414. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  18415. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18416. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  18417. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18418. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18419. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18420. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18421. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18422. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18423. }
  18424. else
  18425. {
  18426. hideRowsList.Add(Row + startIndex + HideRows);
  18427. }
  18428. HideRows += 2;
  18429. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  18430. if (rightBindData != null)
  18431. {
  18432. //头等舱 + 小套房 JSES
  18433. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  18434. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  18435. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18436. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  18437. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18438. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18439. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18440. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18441. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18442. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18443. }
  18444. else
  18445. {
  18446. hideRowsList.Add(Row + startIndex + HideRows);
  18447. }
  18448. HideRows += 2;
  18449. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  18450. if (rightBindData != null)
  18451. {
  18452. //头等舱 + 大套房
  18453. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  18454. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  18455. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18456. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  18457. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18458. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18459. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18460. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18461. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18462. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18463. }
  18464. else
  18465. {
  18466. hideRowsList.Add(Row + startIndex + HideRows);
  18467. }
  18468. #endregion
  18469. #region B段标题清空
  18470. designer.SetDataSource("CostBDRCB", "");
  18471. designer.SetDataSource("CostBRS", "");
  18472. designer.SetDataSource("CostBXS", "");
  18473. designer.SetDataSource("CostBZCB", "");
  18474. designer.SetDataSource("CostBDRBJ", "");
  18475. designer.SetDataSource("CostBZBJ", "");
  18476. designer.SetDataSource("CostBDRLR", "");
  18477. designer.SetDataSource("CostBZLR", "");
  18478. designer.SetDataSource("CostBDRCBOM", "");
  18479. designer.SetDataSource("CostBRSOM", "");
  18480. designer.SetDataSource("CostBZCBOM", "");
  18481. designer.SetDataSource("CostBDRBJOM", "");
  18482. designer.SetDataSource("CostBZBJOM", "");
  18483. designer.SetDataSource("CostBDRLROM", "");
  18484. designer.SetDataSource("CostBZLROM", "");
  18485. #endregion
  18486. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  18487. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  18488. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  18489. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  18490. designer.SetDataSource("DJName", "地接(CNY)");
  18491. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  18492. designer.SetDataSource("CPName", "地接-船票(CNY)");
  18493. designer.SetDataSource("GWName", "公务(CNY)");
  18494. designer.SetDataSource("YQHName", "邀请函(CNY)");
  18495. designer.SetDataSource("LYJName", "零用金(CNY)");
  18496. designer.SetDataSource("HSName", "核酸检测(CNY)");
  18497. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  18498. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  18499. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  18500. designer.SetDataSource("BXName", "保险(CNY)");
  18501. designer.SetDataSource("VisaName", "签证(CNY)");
  18502. #region B段基本数据
  18503. if (dto.costType == "B")
  18504. {
  18505. left = dto.leftInfo.Find(x => x.Type == "B");
  18506. if (left == null)
  18507. {
  18508. return Ok(jw);
  18509. }
  18510. #region B段left数据
  18511. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  18512. if (leftBindData != null)
  18513. {
  18514. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  18515. designer.SetDataSource("BHSRS", leftBindData.rs);
  18516. designer.SetDataSource("BHSXS", leftBindData.xs);
  18517. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18518. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18519. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18520. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18521. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18522. }
  18523. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  18524. if (leftBindData != null)
  18525. {
  18526. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  18527. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  18528. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  18529. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18530. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18531. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18532. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18533. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18534. }
  18535. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  18536. if (leftBindData != null)
  18537. {
  18538. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  18539. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  18540. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  18541. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18542. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18543. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18544. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18545. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18546. }
  18547. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  18548. if (leftBindData != null)
  18549. {
  18550. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  18551. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  18552. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  18553. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18554. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18555. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18556. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18557. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18558. }
  18559. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  18560. if (leftBindData != null)
  18561. {
  18562. designer.SetDataSource("BHCPCB", leftBindData.cb);
  18563. designer.SetDataSource("BHCPRS", leftBindData.rs);
  18564. designer.SetDataSource("BHCPXS", leftBindData.xs);
  18565. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18566. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18567. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18568. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18569. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18570. }
  18571. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  18572. if (leftBindData != null)
  18573. {
  18574. designer.SetDataSource("BCPCB", leftBindData.cb);
  18575. designer.SetDataSource("BCPRS", leftBindData.rs);
  18576. designer.SetDataSource("BCPXS", leftBindData.xs);
  18577. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18578. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18579. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18580. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18581. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18582. }
  18583. //TBR
  18584. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  18585. if (leftBindData != null)
  18586. {
  18587. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  18588. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  18589. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  18590. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18591. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18592. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18593. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18594. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18595. }
  18596. //SGR
  18597. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  18598. if (leftBindData != null)
  18599. {
  18600. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  18601. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  18602. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  18603. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18604. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18605. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18606. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18607. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18608. }
  18609. //JS/ES
  18610. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  18611. if (leftBindData != null)
  18612. {
  18613. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  18614. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  18615. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  18616. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18617. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18618. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18619. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18620. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18621. }
  18622. //SUITE
  18623. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  18624. if (leftBindData != null)
  18625. {
  18626. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  18627. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  18628. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  18629. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18630. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18631. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18632. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18633. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18634. }
  18635. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  18636. if (leftBindData != null)
  18637. {
  18638. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  18639. designer.SetDataSource("BDJRS", leftBindData.rs);
  18640. designer.SetDataSource("BDJXS", leftBindData.xs);
  18641. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18642. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18643. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18644. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18645. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18646. }
  18647. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  18648. if (leftBindData != null)
  18649. {
  18650. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  18651. designer.SetDataSource("BGWRS", leftBindData.rs);
  18652. designer.SetDataSource("BGWXS", leftBindData.xs);
  18653. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18654. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18655. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18656. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18657. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18658. }
  18659. #region 优化方案
  18660. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  18661. //excelBind.Add("零用金", new {
  18662. //cb="",
  18663. //rs="",
  18664. //xs ="",
  18665. //zcb = "",
  18666. //});
  18667. #endregion
  18668. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  18669. if (leftBindData != null)
  18670. {
  18671. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  18672. designer.SetDataSource("BLYJRS", leftBindData.rs);
  18673. designer.SetDataSource("BLYJXS", leftBindData.xs);
  18674. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18675. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18676. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18677. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18678. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18679. }
  18680. #endregion
  18681. #region B段Right信息
  18682. right = dto.rightInfo.Find(x => x.Type == "B");
  18683. if (right == null)
  18684. {
  18685. return Ok(jw);
  18686. }
  18687. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  18688. if (rightBindData != null)
  18689. {
  18690. //经济舱 + 双人间 TBR
  18691. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  18692. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  18693. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18694. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  18695. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18696. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18697. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18698. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18699. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18700. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18701. }
  18702. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  18703. if (rightBindData != null)
  18704. {
  18705. //经济舱 + 单人间 SGR
  18706. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  18707. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  18708. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18709. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  18710. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18711. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18712. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18713. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18714. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18715. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18716. }
  18717. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  18718. if (rightBindData != null)
  18719. {
  18720. //公务舱 + 单人间 SGR
  18721. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  18722. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  18723. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18724. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  18725. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18726. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18727. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18728. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18729. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18730. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18731. }
  18732. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  18733. if (rightBindData != null)
  18734. {
  18735. //公务舱 + 小套房 JSES
  18736. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  18737. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  18738. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18739. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  18740. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18741. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18742. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18743. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18744. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18745. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18746. }
  18747. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  18748. if (rightBindData != null)
  18749. {
  18750. //公务舱 + 小套房 JSES
  18751. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  18752. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  18753. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18754. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  18755. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18756. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18757. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18758. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18759. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18760. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18761. }
  18762. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  18763. if (rightBindData != null)
  18764. {
  18765. //经济舱 + 大套房
  18766. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  18767. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  18768. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18769. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  18770. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18771. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18772. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18773. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18774. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18775. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18776. }
  18777. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  18778. if (rightBindData != null)
  18779. {
  18780. //头等舱 + 小套房 JSES
  18781. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  18782. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  18783. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18784. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  18785. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18786. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18787. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18788. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18789. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18790. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18791. }
  18792. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  18793. if (rightBindData != null)
  18794. {
  18795. //头等舱 + 大套房
  18796. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  18797. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  18798. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18799. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  18800. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18801. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18802. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18803. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18804. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18805. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18806. }
  18807. #endregion
  18808. #region 标题
  18809. designer.SetDataSource("CostBDRCB", "单人成本");
  18810. designer.SetDataSource("CostBRS", "人数");
  18811. designer.SetDataSource("CostBXS", "系数");
  18812. designer.SetDataSource("CostBZCB", "总成本");
  18813. designer.SetDataSource("CostBDRBJ", "单人报价");
  18814. designer.SetDataSource("CostBZBJ", "总报价");
  18815. designer.SetDataSource("CostBDRLR", "单人利润");
  18816. designer.SetDataSource("CostBZLR", "总利润");
  18817. designer.SetDataSource("CostBDRCBOM", "单人成本");
  18818. designer.SetDataSource("CostBRSOM", "人数");
  18819. designer.SetDataSource("CostBZCBOM", "总成本");
  18820. designer.SetDataSource("CostBDRBJOM", "单人报价");
  18821. designer.SetDataSource("CostBZBJOM", "总报价");
  18822. designer.SetDataSource("CostBDRLROM", "单人利润");
  18823. designer.SetDataSource("CostBZLROM", "总利润");
  18824. #endregion
  18825. }
  18826. #endregion
  18827. designer.SetDataSource("TzZCB2", TzZCB2);
  18828. designer.SetDataSource("TzZBJ2", TzZBJ2);
  18829. designer.SetDataSource("TzZLR2", TzZLR2);
  18830. string[] dataSourceKeys = new string[]
  18831. {
  18832. "VF",
  18833. "TGS",
  18834. "TGOF",
  18835. "TGM",
  18836. "TGA",
  18837. "TGTF",
  18838. "TGEF",
  18839. "CFM",
  18840. "CFOF",
  18841. "B",
  18842. "L",
  18843. "D",
  18844. "TBR",
  18845. "SGR",
  18846. "JSES",
  18847. "Suite",
  18848. "TV",
  18849. "1L",
  18850. "IF",
  18851. "EF",
  18852. "BRF",
  18853. "TE",
  18854. "TGT",
  18855. "DRVT",
  18856. "PC",
  18857. "TLF",
  18858. "ECT"
  18859. };
  18860. foreach (var item in dataSourceKeys)
  18861. {
  18862. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  18863. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  18864. var find = dto.titleModel.FirstOrDefault(expr);
  18865. if (find != null)
  18866. {
  18867. designer.SetDataSource(item, find.text);
  18868. }
  18869. else
  18870. {
  18871. designer.SetDataSource(item, 0);
  18872. }
  18873. }
  18874. designer.SetDataSource(dt);
  18875. //根据数据源处理生成报表内容
  18876. designer.Process();
  18877. designer.Workbook.Worksheets[0].Name = "费用明细";
  18878. designer.Workbook.Worksheets[1].Name = "费用总核算";
  18879. Worksheet sheet = designer.Workbook.Worksheets[0];
  18880. #region 隐藏舱位
  18881. var settingAir = new[]
  18882. {
  18883. new { key = "经济舱", index = 7 },
  18884. new { key = "公务舱", index = 19 },
  18885. new { key = "头等舱", index = 11 }
  18886. };
  18887. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  18888. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  18889. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  18890. .Select((c, s) => s.Name)
  18891. .ToList()
  18892. .GroupBy(x => x)
  18893. .Select(x => x.Key);
  18894. foreach (var item in settingAir)
  18895. {
  18896. if (!airType.Contains(item.key))
  18897. {
  18898. hideRowsList.Add(item.index);
  18899. }
  18900. }
  18901. #endregion
  18902. foreach (var Rowindex in hideRowsList)
  18903. {
  18904. ws.Cells.HideRows(Rowindex, 2);
  18905. }
  18906. ws = designer.Workbook.Worksheets[0];
  18907. foreach (var Column in hideColumnList)
  18908. {
  18909. ws.Cells.HideColumns(Column, 1);
  18910. }
  18911. byte[] bytes = null;
  18912. string strFileName = di.TeamName + "-团组-成本.xls";
  18913. using (MemoryStream stream = new MemoryStream())
  18914. {
  18915. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  18916. bytes = stream.ToArray();
  18917. }
  18918. return Ok(JsonView(true, "", new
  18919. {
  18920. Data = bytes,
  18921. strFileName,
  18922. }));
  18923. }
  18924. /// <summary>
  18925. /// 导出客户报表
  18926. /// </summary>
  18927. /// <returns></returns>
  18928. [HttpPost]
  18929. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  18930. {
  18931. var jw = JsonView(false);
  18932. if (dto.Diid == 0)
  18933. {
  18934. return Ok(JsonView(false, "请传递团组id"));
  18935. }
  18936. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  18937. if (deleInfo.Code != 0)
  18938. {
  18939. return Ok(JsonView(false, "团组信息查询失败!"));
  18940. }
  18941. var di = deleInfo.Data as DelegationInfoWebView;
  18942. if (di == null)
  18943. {
  18944. return Ok(JsonView(false, "团组信息查询失败!"));
  18945. }
  18946. //文件名
  18947. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  18948. //获取模板
  18949. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  18950. //载入模板
  18951. Document doc = new Document(tmppath);
  18952. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  18953. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  18954. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  18955. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  18956. var AParameter = ParameterList.Find(x => x.CostType == "A");
  18957. var BParameter = ParameterList.Find(x => x.CostType == "B");
  18958. if (AParameter == null)
  18959. {
  18960. return Ok(JsonView(false, "系数不存在!"));
  18961. }
  18962. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  18963. , TzAirDesc, TzZCost;
  18964. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  18965. = TzAirDesc = TzZCost = string.Empty;
  18966. TzNumber = AParameter.CostTypenumber.ToString();
  18967. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  18968. CarGuides1 = dto.CarGuides1;
  18969. Meal = dto.Meal;
  18970. SubsidizedMeals = dto.SubsidizedMeals;
  18971. NightRepair = dto.NightRepair;
  18972. AttractionsTickets = dto.AttractionsTickets;
  18973. MiscellaneousFees = dto.MiscellaneousFees;
  18974. ATip = dto.ATip;
  18975. TzHotelDesc = "";
  18976. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  18977. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  18978. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  18979. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  18980. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  18981. TzAirDesc = "";
  18982. TzZCost = dto.TzZCost;
  18983. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  18984. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  18985. var index = 1;
  18986. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  18987. foreach (var item in TzHotelDescArr)
  18988. {
  18989. if (AinfoArr != null)
  18990. {
  18991. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  18992. if (Ainfo != null)
  18993. {
  18994. if (int.Parse(Ainfo.rs) <= 0)
  18995. {
  18996. continue;
  18997. }
  18998. var hotelText = string.Empty;
  18999. switch (item)
  19000. {
  19001. case "SGR":
  19002. hotelText = "单人间";
  19003. break;
  19004. case "JSES":
  19005. hotelText = "小套房";
  19006. break;
  19007. case "SUITE":
  19008. hotelText = "套房";
  19009. break;
  19010. case "TBR":
  19011. hotelText = "双人间";
  19012. break;
  19013. }
  19014. if (item != "TBR")
  19015. {
  19016. 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";
  19017. }
  19018. else
  19019. {
  19020. 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";
  19021. }
  19022. index++;
  19023. }
  19024. }
  19025. }
  19026. index = 1;
  19027. foreach (var item in TzAirDescArr)
  19028. {
  19029. if (AinfoArr != null)
  19030. {
  19031. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19032. if (Ainfo != null)
  19033. {
  19034. if (int.Parse(Ainfo.rs) <= 0)
  19035. {
  19036. continue;
  19037. }
  19038. 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";
  19039. index++;
  19040. }
  19041. }
  19042. }
  19043. if (dto.costType == "B")
  19044. {
  19045. if (BParameter == null)
  19046. {
  19047. return Ok(JsonView(false, "B段系数不存在!"));
  19048. }
  19049. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  19050. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  19051. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  19052. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  19053. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  19054. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  19055. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  19056. foreach (var item in TzHotelDescArr)
  19057. {
  19058. if (AinfoArr != null)
  19059. {
  19060. TzHotelDesc += "B段信息 \r\n";
  19061. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19062. if (Ainfo != null)
  19063. {
  19064. if (int.Parse(Ainfo.rs) <= 0)
  19065. {
  19066. continue;
  19067. }
  19068. var hotelText = string.Empty;
  19069. switch (item)
  19070. {
  19071. case "SGR":
  19072. hotelText = "单人间";
  19073. break;
  19074. case "JSES":
  19075. hotelText = "小套房";
  19076. break;
  19077. case "SUITE":
  19078. hotelText = "套房";
  19079. break;
  19080. case "TBR":
  19081. hotelText = "双人间";
  19082. break;
  19083. }
  19084. if (item != "TBR")
  19085. {
  19086. 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";
  19087. }
  19088. else
  19089. {
  19090. 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";
  19091. }
  19092. index++;
  19093. }
  19094. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  19095. }
  19096. }
  19097. index = 1;
  19098. foreach (var item in TzAirDescArr)
  19099. {
  19100. if (AinfoArr != null)
  19101. {
  19102. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19103. if (Ainfo != null)
  19104. {
  19105. if (int.Parse(Ainfo.rs) <= 0)
  19106. {
  19107. continue;
  19108. }
  19109. 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";
  19110. index++;
  19111. }
  19112. }
  19113. }
  19114. }
  19115. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  19116. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  19117. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  19118. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  19119. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  19120. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  19121. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  19122. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  19123. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  19124. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  19125. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  19126. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  19127. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  19128. DickeyValue.Add("Visa", Visa); // 签证单人报价
  19129. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  19130. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  19131. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  19132. DickeyValue.Add("TzZCost", TzZCost);
  19133. foreach (var key in DickeyValue.Keys)
  19134. {
  19135. if (doc.Range.Bookmarks[key] != null)
  19136. {
  19137. Bookmark mark = doc.Range.Bookmarks[key];
  19138. mark.Text = DickeyValue[key];
  19139. }
  19140. }
  19141. byte[] bytes = null;
  19142. string strFileName = di.TeamName + "-客户报价.doc";
  19143. using (MemoryStream stream = new MemoryStream())
  19144. {
  19145. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  19146. bytes = stream.ToArray();
  19147. }
  19148. return Ok(JsonView(true, "", new
  19149. {
  19150. Data = bytes,
  19151. strFileName,
  19152. }));
  19153. }
  19154. /// <summary>
  19155. /// 团组成本 各模块(酒店,地接,机票)成本提示
  19156. /// </summary>
  19157. /// <param name="dto"></param>
  19158. /// <returns></returns>
  19159. [HttpPost]
  19160. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19161. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  19162. {
  19163. try
  19164. {
  19165. #region 参数验证
  19166. if (dto.DiId < 0)
  19167. {
  19168. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  19169. }
  19170. List<int> cTableIds = new List<int>() {
  19171. 76 ,//酒店预订
  19172. 77 ,//行程
  19173. 79 ,//车/导游地接
  19174. 80 ,//签证
  19175. 81 ,//邀请/公务活
  19176. 82 ,//团组客户保险
  19177. 85 ,//机票预订
  19178. 98 ,//其他款项
  19179. 285 ,//收款退还
  19180. 751 ,//酒店早餐
  19181. 1015 // 超支费用
  19182. };
  19183. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  19184. {
  19185. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  19186. }
  19187. #endregion
  19188. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  19189. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  19190. if (_GroupCostParameters.Count <= 0)
  19191. {
  19192. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  19193. }
  19194. if (_GroupCostParameters[0].IsShare == 0)
  19195. {
  19196. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  19197. }
  19198. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  19199. //处理date为空问题
  19200. if (_GroupCosts.Count > 0)
  19201. {
  19202. for (int i = 0; i < _GroupCosts.Count; i++)
  19203. {
  19204. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  19205. {
  19206. if (i > 0)
  19207. {
  19208. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  19209. }
  19210. }
  19211. }
  19212. }
  19213. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  19214. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  19215. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  19216. string currCode = "";
  19217. #region currCode 验证
  19218. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  19219. if (isInt)
  19220. {
  19221. var currData = currDatas.Find(it => it.Id == intCurrency);
  19222. if (currData != null)
  19223. {
  19224. currCode = currData.Name;
  19225. }
  19226. }
  19227. else
  19228. {
  19229. currCode = _GroupCostParameters[0].Currency.Trim();
  19230. }
  19231. #endregion
  19232. //op,酒店单段模式存储
  19233. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  19234. {
  19235. CurrencyCode = currCode,
  19236. Rate = _GroupCostParameters[0].Rate,
  19237. CostType = _GroupCostParameters[0].CostType,
  19238. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  19239. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  19240. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  19241. };
  19242. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  19243. if (_GroupCostParameters.Count == 2)
  19244. {
  19245. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  19246. }
  19247. foreach (var item in _GroupCostParameters)
  19248. {
  19249. decimal _rate = 1;
  19250. decimal _rate1 = item.Rate;
  19251. decimal _scale = 1;
  19252. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  19253. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  19254. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  19255. //if (userInfo != null)
  19256. //{
  19257. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  19258. // {
  19259. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  19260. // {
  19261. // _scale = 1.00M;
  19262. // }
  19263. // }
  19264. //}
  19265. #endregion
  19266. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  19267. {
  19268. CurrencyCode = currCode,
  19269. Rate = _rate1,
  19270. CostType = item.CostType,
  19271. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  19272. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  19273. CostTypeNumber = item.CostTypenumber
  19274. };
  19275. if (_GroupCostParameters.Count > 1)
  19276. {
  19277. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  19278. }
  19279. else
  19280. {
  19281. modulePromptInfo.CostTypeNumber = item.LYJRS;
  19282. }
  19283. if (dto.CTable == 79)//
  19284. {
  19285. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  19286. modulePromptInfo.TotalCost = item.DJCB;
  19287. }
  19288. List<string> costTypes = new List<string>() { "A", "B" };
  19289. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  19290. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  19291. if (_GroupCostsDuplicates.Count() == 1)
  19292. {
  19293. _GroupCostsTypeData = _GroupCosts;
  19294. }
  19295. else
  19296. {
  19297. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  19298. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  19299. }
  19300. /*
  19301. * 76 酒店预订
  19302. * 77 行程
  19303. * 79 车/导游地接
  19304. * 80 签证
  19305. * 81 邀请/公务活动
  19306. * 82 团组客户保险
  19307. * 85 机票预订
  19308. * 98 其他款项
  19309. * 285 收款退还
  19310. * 751 酒店早餐
  19311. * 1015 超支费用
  19312. */
  19313. switch (dto.CTable)
  19314. {
  19315. case 76: // 酒店预订
  19316. _ModuleSubPromptInfo.AddRange(
  19317. _GroupCostsTypeData.Select(it => new
  19318. {
  19319. it.DAY,
  19320. it.Date,
  19321. it.ACCON,
  19322. it.ITIN,
  19323. it.SGR,
  19324. it.TBR,
  19325. it.JS_ES,
  19326. it.Suite
  19327. })
  19328. );
  19329. break;
  19330. case 79: // 车/导游地接
  19331. _ModuleSubPromptInfo.AddRange(
  19332. _GroupCostsTypeData.Select(it => new
  19333. {
  19334. Date = it.Date, //日期
  19335. CarFee = it.CarCost * _rate * _scale, //车费用
  19336. CarType = it.CarType, //车型
  19337. DriverFee = it.CFS * _rate * _scale, //司机工资
  19338. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  19339. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  19340. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  19341. GuideFee = it.TGS * _rate * _scale, //导游费用
  19342. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  19343. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  19344. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  19345. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  19346. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  19347. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  19348. Breakfast = it.B * _rate * _scale, //早餐费
  19349. Lunch = it.L * _rate * _scale, //午餐费
  19350. Dinner = it.D * _rate * _scale, //晚餐费
  19351. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  19352. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  19353. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  19354. TicketFee = it.EF * _rate * _scale, //门票费
  19355. TicketRemark = it.EFR, //门票费描述
  19356. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  19357. TravelSupplies = it.TE * _rate * _scale, //出行物资
  19358. SpentCash = it.PC * _rate * _scale, //零用金
  19359. LeadersFee = it.TLF * _rate * _scale, //领队费
  19360. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  19361. })
  19362. );
  19363. break;
  19364. case 85: // 机票
  19365. List<dynamic> datas = new List<dynamic>();
  19366. datas.Add(
  19367. new
  19368. {
  19369. AirType = "经济舱",
  19370. AirNum = item.JJCRS,
  19371. AirDRCB = item.JJCCB,
  19372. AirZCB = (item.JJCRS * item.JJCCB)
  19373. }
  19374. );
  19375. datas.Add(
  19376. new
  19377. {
  19378. AirType = "公务舱",
  19379. AirNum = item.GWCRS,
  19380. AirDRCB = item.GWCCB,
  19381. AirZCB = (item.GWCRS * item.GWCCB)
  19382. }
  19383. );
  19384. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  19385. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  19386. modulePromptInfo.Data = new
  19387. {
  19388. airFeeData = datas,
  19389. airInitData = initDatas
  19390. };
  19391. _ModulePromptInfos.Add(modulePromptInfo);
  19392. break;
  19393. default:
  19394. break;
  19395. }
  19396. }
  19397. if (dto.CTable != 85)
  19398. {
  19399. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  19400. _ModulePromptInfos.Add(_ModulePromptInfo);
  19401. }
  19402. _view.ModulePromptInfos = _ModulePromptInfos;
  19403. return Ok(JsonView(true, "操作成功!", _view));
  19404. }
  19405. catch (Exception ex)
  19406. {
  19407. return Ok(JsonView(false, ex.Message));
  19408. }
  19409. }
  19410. /// <summary>
  19411. /// 根据黑屏代码重新生成行程
  19412. /// </summary>
  19413. /// <param name="dto"></param>
  19414. /// <returns></returns>
  19415. [HttpPost]
  19416. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  19417. {
  19418. var jw = JsonView(false, "Error");
  19419. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19420. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  19421. .Select(x => new
  19422. {
  19423. x.Id,
  19424. x.Title
  19425. })
  19426. .ToList();
  19427. if (Create.Any())
  19428. {
  19429. jw.Msg = "获取成功!";
  19430. jw.Code = 200;
  19431. jw.Data = new
  19432. {
  19433. BlackCodeListSelect = Create,
  19434. blackCodeIsTrue = true
  19435. };
  19436. }
  19437. else
  19438. {
  19439. jw.Code = 400;
  19440. jw.Data = new
  19441. {
  19442. BlackCodeListSelect = Create,
  19443. blackCodeIsTrue = false,
  19444. };
  19445. }
  19446. return Ok(jw);
  19447. }
  19448. /// <summary>
  19449. /// 根据黑屏代码Id重新生成行程
  19450. /// </summary>
  19451. /// <param name="dto"></param>
  19452. /// <returns></returns>
  19453. [HttpPost]
  19454. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  19455. {
  19456. var jw = JsonView(false, "Error");
  19457. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  19458. if (result.Code == 0)
  19459. {
  19460. jw.Msg = "获取成功!";
  19461. jw.Code = 200;
  19462. jw.Data = new
  19463. {
  19464. groupCost = result.Data,
  19465. blackCodeIsTrue = true
  19466. };
  19467. }
  19468. else
  19469. {
  19470. jw.Code = 400;
  19471. jw.Data = new
  19472. {
  19473. groupCost = result.Data,
  19474. blackCodeIsTrue = false,
  19475. };
  19476. }
  19477. return Ok(jw);
  19478. }
  19479. /// <summary>
  19480. /// 成本获取OP历史车费用
  19481. /// </summary>
  19482. /// <param name="dto"></param>
  19483. /// <returns></returns>
  19484. [HttpPost]
  19485. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  19486. {
  19487. var jw = JsonView(false);
  19488. try
  19489. {
  19490. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  19491. //获取现有所有车的数据
  19492. if (!dto.Param.IsNullOrWhiteSpace())
  19493. {
  19494. string sql = $@"
  19495. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  19496. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  19497. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  19498. 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
  19499. AND gctggr.ServiceEndTime is not NULL
  19500. ORDER by gctggrc.id DESC
  19501. ";
  19502. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  19503. var numeberResult = await Task.Run(() =>
  19504. {
  19505. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  19506. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  19507. return numberArr;
  19508. });
  19509. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  19510. foreach (var item in numeberResult)
  19511. {
  19512. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  19513. {
  19514. Country = "数据异常!",
  19515. City = string.Empty,
  19516. };
  19517. item.Area = find.Country + " " + find.City;
  19518. }
  19519. dbResult.AddRange(numeberResult);
  19520. if (dto.Param.Contains("、"))
  19521. {
  19522. var sp = dto.Param.Split("、");
  19523. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  19524. .Where(x =>
  19525. {
  19526. return System.Array.Exists(sp, e =>
  19527. {
  19528. bool where = false;
  19529. if (x.Area != null)
  19530. {
  19531. where = x.Area.Contains(e);
  19532. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  19533. {
  19534. return false;
  19535. }
  19536. }
  19537. if (x.PriceName != null && !where)
  19538. {
  19539. where = x.PriceName.Contains(e);
  19540. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  19541. {
  19542. return false;
  19543. }
  19544. }
  19545. return where;
  19546. });
  19547. }).ToList();
  19548. }
  19549. else
  19550. {
  19551. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  19552. .Where(x =>
  19553. {
  19554. bool where = false;
  19555. if (x.Area != null)
  19556. {
  19557. where = x.Area.Contains(dto.Param);
  19558. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  19559. {
  19560. return false;
  19561. }
  19562. }
  19563. if (x.PriceName != null && !where)
  19564. {
  19565. where = x.PriceName.Contains(dto.Param);
  19566. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  19567. {
  19568. return false;
  19569. }
  19570. }
  19571. return where;
  19572. }
  19573. )
  19574. .ToList();
  19575. }
  19576. }
  19577. var view = dbResult.Select(x =>
  19578. {
  19579. decimal dp = 0.00M;
  19580. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  19581. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  19582. if (string.IsNullOrWhiteSpace(x.DatePrice))
  19583. {
  19584. if (startB && endB)
  19585. {
  19586. var timesp = endD.Subtract(startD);
  19587. if ((timesp.Days + 1) != 0)
  19588. {
  19589. dp = x.Price / (timesp.Days + 1);
  19590. }
  19591. }
  19592. }
  19593. else
  19594. {
  19595. dp = x.Price;
  19596. }
  19597. return new
  19598. {
  19599. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  19600. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  19601. x.Area,
  19602. x.id,
  19603. price = x.Price.ToString("F2"),
  19604. x.PriceName,
  19605. x.PriceContent,
  19606. x.TeamName,
  19607. x.DatePrice,
  19608. dayPrice = dp.ToString("F2"),
  19609. };
  19610. }).OrderByDescending(x => x.id).ToList();
  19611. jw = JsonView(true, "获取成功!", view);
  19612. }
  19613. catch (Exception e)
  19614. {
  19615. jw = JsonView(false, e.Message);
  19616. }
  19617. return Ok(jw);
  19618. }
  19619. [HttpPost]
  19620. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  19621. {
  19622. var jw = JsonView(true);
  19623. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  19624. #region SQL语句
  19625. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  19626. //{
  19627. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  19628. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  19629. // WHEN COUNT(*) >= 0 THEN 'True'
  19630. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  19631. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  19632. // ")
  19633. // .ToList();
  19634. //}
  19635. //else
  19636. //{
  19637. // string likeKey = string.Empty;
  19638. // foreach (var item in dto.Keyword)
  19639. // {
  19640. // likeKey += "%" + item;
  19641. // }
  19642. // likeKey += "%";
  19643. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  19644. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  19645. // WHEN COUNT(*) >= 0 THEN 'True'
  19646. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  19647. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  19648. // ")
  19649. // .ToList();
  19650. //}
  19651. #endregion
  19652. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  19653. {
  19654. @KeyWord = dto.Keyword
  19655. });
  19656. if (table != null && table.Rows.Count > 0)
  19657. {
  19658. foreach (DataRow row in table.Rows)
  19659. {
  19660. matches.Add(new DelegationInfoAndIsTrueView
  19661. {
  19662. Id = row.Field<int>("Id"),
  19663. GroupName = row.Field<string>("GroupName"),
  19664. isTrue = row.Field<string>("isTrue")
  19665. });
  19666. }
  19667. }
  19668. if (matches.Any())
  19669. {
  19670. jw.Data = matches;
  19671. }
  19672. else
  19673. {
  19674. jw.Code = 201;
  19675. jw.Msg = "empty list";
  19676. jw.Data = new List<string>(1);
  19677. }
  19678. return Ok(jw);
  19679. }
  19680. /// <summary>
  19681. /// 报价Word下载
  19682. /// </summary>
  19683. /// <param name="dto"></param>
  19684. /// <returns></returns>
  19685. [HttpPost]
  19686. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  19687. {
  19688. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  19689. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  19690. if (di == null)
  19691. {
  19692. return Ok(JsonView(false, "团组不存在!"));
  19693. }
  19694. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  19695. if (mainPrice == null || mainPrice.IsShare == 0)
  19696. {
  19697. return Ok(JsonView(false, "团组成本不存在!"));
  19698. }
  19699. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  19700. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  19701. if (costTypeHotelNumbers == null)
  19702. {
  19703. return Ok(JsonView(false, "团组成本不存在!"));
  19704. }
  19705. //文件名
  19706. string strFileName = di.TeamName + "-收款账单.doc";
  19707. //获取模板
  19708. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  19709. //载入模板
  19710. Document doc = new Document(tmppath);
  19711. decimal allPrice = 0.00M;
  19712. string itemStr = string.Empty;
  19713. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  19714. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  19715. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  19716. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  19717. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  19718. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  19719. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  19720. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  19721. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  19722. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  19723. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  19724. {
  19725. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  19726. ("BXRS", "BXCB", "BXXS", "bx"),
  19727. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  19728. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  19729. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  19730. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  19731. ("CPRS", "CPCB", "CPXS", "cp"),
  19732. ("HSRS", "HSCB", "HSXS", "hsjc"),
  19733. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  19734. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  19735. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  19736. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  19737. ("DJRS", "DJCB", "DJXS", "dj"),
  19738. ("GWRS", "GWCB", "GWXS", "gw"),
  19739. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  19740. };
  19741. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  19742. var rightSum = 0.00M;
  19743. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  19744. {
  19745. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  19746. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  19747. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  19748. if (prefix == "tbr")
  19749. {
  19750. rsValue *= 2;
  19751. cbValue /= 2;
  19752. }
  19753. if (OtherCostPropertyBJ.Contains(prefix))
  19754. {
  19755. rightSum += cbValue * xsValue;
  19756. }
  19757. }
  19758. var hotelRooms = new Dictionary<string, int>
  19759. {
  19760. { "SGR", costTypeHotelNumbers.SGR },
  19761. { "TBR", costTypeHotelNumbers.TBR },
  19762. { "JSES", costTypeHotelNumbers.JSES },
  19763. { "SUITE", costTypeHotelNumbers.SUITE }
  19764. };
  19765. var flights = new Dictionary<string, int>
  19766. {
  19767. { "经济舱", mainPrice.JJCRS },
  19768. { "公务舱", mainPrice.GWCRS },
  19769. { "头等舱", mainPrice.TDCRS }
  19770. };
  19771. var flightRoomMatchingRules = new Dictionary<string, string[]>
  19772. {
  19773. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  19774. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  19775. { "头等舱", new[] { "SUITE", "JSES" } }
  19776. };
  19777. var result = new Dictionary<string, int>();
  19778. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  19779. foreach (var flight in flights.Keys)
  19780. {
  19781. // 获取当前舱位的匹配规则
  19782. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  19783. {
  19784. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  19785. }
  19786. }
  19787. #region right计算
  19788. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  19789. {
  19790. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19791. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  19792. airHotelPriceList.Add(new
  19793. AirHotelPrice
  19794. {
  19795. Name = "经济舱TBR",
  19796. Price = rightSum + air + hotel,
  19797. Count = result["经济舱TBR"] * 2
  19798. });
  19799. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  19800. }
  19801. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  19802. {
  19803. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19804. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  19805. airHotelPriceList.Add(new
  19806. AirHotelPrice
  19807. {
  19808. Name = "经济舱SGR",
  19809. Price = rightSum + air + hotel,
  19810. Count = result["经济舱SGR"]
  19811. });
  19812. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  19813. }
  19814. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  19815. {
  19816. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  19817. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  19818. airHotelPriceList.Add(new
  19819. AirHotelPrice
  19820. {
  19821. Name = "公务舱SGR",
  19822. Price = rightSum + air + hotel,
  19823. Count = result["公务舱SGR"]
  19824. });
  19825. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  19826. }
  19827. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  19828. {
  19829. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  19830. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  19831. airHotelPriceList.Add(new
  19832. AirHotelPrice
  19833. {
  19834. Name = "公务舱JSES",
  19835. Price = rightSum + air + hotel,
  19836. Count = result["公务舱JSES"]
  19837. });
  19838. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  19839. }
  19840. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  19841. {
  19842. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  19843. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  19844. airHotelPriceList.Add(new
  19845. AirHotelPrice
  19846. {
  19847. Name = "公务舱SUITE",
  19848. Price = rightSum + air + hotel,
  19849. Count = result["公务舱SUITE"]
  19850. });
  19851. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  19852. }
  19853. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  19854. {
  19855. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19856. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  19857. airHotelPriceList.Add(new
  19858. AirHotelPrice
  19859. {
  19860. Name = "经济舱SUITE",
  19861. Price = rightSum + air + hotel,
  19862. Count = result["经济舱SUITE"]
  19863. });
  19864. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  19865. }
  19866. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  19867. {
  19868. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  19869. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  19870. airHotelPriceList.Add(new
  19871. AirHotelPrice
  19872. {
  19873. Name = "头等舱JSES",
  19874. Price = rightSum + air + hotel,
  19875. Count = result["头等舱JSES"]
  19876. });
  19877. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  19878. }
  19879. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  19880. {
  19881. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  19882. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  19883. airHotelPriceList.Add(new
  19884. AirHotelPrice
  19885. {
  19886. Name = "头等舱SUITE",
  19887. Price = rightSum + air + hotel,
  19888. Count = result["头等舱SUITE"]
  19889. });
  19890. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  19891. }
  19892. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  19893. {
  19894. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19895. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  19896. airHotelPriceList.Add(new
  19897. AirHotelPrice
  19898. {
  19899. Name = "经济舱JSES",
  19900. Price = rightSum + air + hotel,
  19901. Count = result["经济舱JSES"]
  19902. });
  19903. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  19904. }
  19905. #endregion
  19906. foreach (var item in airSouer.Keys)
  19907. {
  19908. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  19909. if (find != null && find.Count > 0)
  19910. {
  19911. if (item.Contains("TBR"))
  19912. {
  19913. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  19914. }
  19915. else
  19916. {
  19917. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  19918. }
  19919. }
  19920. }
  19921. #region 替换Word模板书签内容
  19922. Dictionary<string, string> marks = new Dictionary<string, string>();
  19923. marks.Add("To", di.ClientUnit);//付款方
  19924. marks.Add("ToTel", di.TellPhone);//付款方电话
  19925. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  19926. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  19927. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  19928. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  19929. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  19930. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  19931. marks.Add("PayItemContent", itemStr);//详细信息
  19932. marks.Add("Total", allPrice.ToString("F2"));//合计
  19933. #endregion
  19934. foreach (var item in marks.Keys)
  19935. {
  19936. if (doc.Range.Bookmarks[item] != null)
  19937. {
  19938. Bookmark mark = doc.Range.Bookmarks[item];
  19939. mark.Text = marks[item];
  19940. }
  19941. }
  19942. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  19943. doc.Save(savePaht);
  19944. var jw = new JsonView();
  19945. jw.Msg = "生成成功!";
  19946. jw.Code = 200;
  19947. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  19948. return Ok(jw);
  19949. }
  19950. /// <summary>
  19951. /// 详细报价费用Excel下载
  19952. /// </summary>
  19953. /// <param name="dto"></param>
  19954. /// <returns></returns>
  19955. [HttpPost]
  19956. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  19957. {
  19958. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  19959. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  19960. if (di == null)
  19961. {
  19962. return Ok(JsonView(false, "团组不存在!"));
  19963. }
  19964. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  19965. if (mainPrice == null || mainPrice.IsShare == 0)
  19966. {
  19967. return Ok(JsonView(false, "团组成本不存在!"));
  19968. }
  19969. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  19970. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  19971. if (costTypeHotelNumbers == null)
  19972. {
  19973. return Ok(JsonView(false, "团组成本不存在!"));
  19974. }
  19975. WorkbookDesigner designer = new WorkbookDesigner();
  19976. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  19977. List<int> hideRowsList = new List<int>();
  19978. int conterStartIndex = 3;
  19979. int rowIndex = conterStartIndex;
  19980. designer.SetDataSource("GroupName", di.TeamName);
  19981. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  19982. {
  19983. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  19984. ("BXRS", "BXCB", "BXXS", "bx"),
  19985. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  19986. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  19987. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  19988. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  19989. ("CPRS", "CPCB", "CPXS", "cp") ,
  19990. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  19991. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  19992. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  19993. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  19994. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  19995. ("DJRS", "DJCB", "DJXS", "dj") ,
  19996. ("GWRS", "GWCB", "GWXS", "gw") ,
  19997. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  19998. };
  19999. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  20000. var rightSum = 0.00M;
  20001. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  20002. {
  20003. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  20004. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  20005. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  20006. if (prefix == "tbr")
  20007. {
  20008. rsValue *= 2;
  20009. cbValue /= 2;
  20010. }
  20011. if (OtherCostPropertyBJ.Contains(prefix))
  20012. {
  20013. rightSum += cbValue * xsValue;
  20014. }
  20015. if (rsValue == 0)
  20016. {
  20017. hideRowsList.Add(rowIndex);
  20018. }
  20019. else
  20020. {
  20021. designer.SetDataSource($"{prefix}rs", rsValue);
  20022. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  20023. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  20024. }
  20025. rowIndex += 2;
  20026. }
  20027. var hotelRooms = new Dictionary<string, int>
  20028. {
  20029. { "SGR", costTypeHotelNumbers.SGR },
  20030. { "TBR", costTypeHotelNumbers.TBR },
  20031. { "JSES", costTypeHotelNumbers.JSES },
  20032. { "SUITE", costTypeHotelNumbers.SUITE }
  20033. };
  20034. var flights = new Dictionary<string, int>
  20035. {
  20036. { "经济舱", mainPrice.JJCRS },
  20037. { "公务舱", mainPrice.GWCRS },
  20038. { "头等舱", mainPrice.TDCRS }
  20039. };
  20040. var flightRoomMatchingRules = new Dictionary<string, string[]>
  20041. {
  20042. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  20043. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  20044. { "头等舱", new[] { "SUITE", "JSES" } }
  20045. };
  20046. var result = new Dictionary<string, int>();
  20047. foreach (var flight in flights.Keys)
  20048. {
  20049. // 获取当前舱位的匹配规则
  20050. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  20051. {
  20052. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  20053. }
  20054. }
  20055. var allPrice = 0.00M;
  20056. #region right计算
  20057. int airRowIndex = 35;
  20058. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  20059. {
  20060. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20061. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  20062. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  20063. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  20064. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  20065. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  20066. }
  20067. else
  20068. {
  20069. hideRowsList.Add(airRowIndex);
  20070. }
  20071. airRowIndex += 2;
  20072. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  20073. {
  20074. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20075. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  20076. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  20077. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  20078. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  20079. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  20080. }
  20081. else
  20082. {
  20083. hideRowsList.Add(airRowIndex);
  20084. }
  20085. airRowIndex += 2;
  20086. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  20087. {
  20088. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  20089. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  20090. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  20091. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  20092. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  20093. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  20094. }
  20095. else
  20096. {
  20097. hideRowsList.Add(airRowIndex);
  20098. }
  20099. airRowIndex += 2;
  20100. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  20101. {
  20102. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  20103. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  20104. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  20105. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  20106. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  20107. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  20108. }
  20109. else
  20110. {
  20111. hideRowsList.Add(airRowIndex);
  20112. }
  20113. airRowIndex += 2;
  20114. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  20115. {
  20116. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  20117. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  20118. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  20119. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  20120. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  20121. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  20122. }
  20123. else
  20124. {
  20125. hideRowsList.Add(airRowIndex);
  20126. }
  20127. airRowIndex += 2;
  20128. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  20129. {
  20130. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20131. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  20132. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  20133. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  20134. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  20135. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  20136. }
  20137. else
  20138. {
  20139. hideRowsList.Add(airRowIndex);
  20140. }
  20141. airRowIndex += 2;
  20142. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  20143. {
  20144. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  20145. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  20146. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  20147. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  20148. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  20149. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  20150. }
  20151. else
  20152. {
  20153. hideRowsList.Add(airRowIndex);
  20154. }
  20155. airRowIndex += 2;
  20156. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  20157. {
  20158. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  20159. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  20160. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  20161. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  20162. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  20163. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  20164. }
  20165. else
  20166. {
  20167. hideRowsList.Add(airRowIndex);
  20168. }
  20169. airRowIndex += 2;
  20170. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  20171. {
  20172. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20173. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  20174. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  20175. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  20176. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  20177. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  20178. }
  20179. else
  20180. {
  20181. hideRowsList.Add(airRowIndex);
  20182. }
  20183. #endregion
  20184. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  20185. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  20186. var ws = designer.Workbook.Worksheets[0];
  20187. foreach (var Rowindex in hideRowsList)
  20188. {
  20189. ws.Cells.HideRows(Rowindex, 2);
  20190. }
  20191. designer.Process();
  20192. designer.Workbook.Save(savePaht);
  20193. return Ok(JsonView(true, "生成成功!", new
  20194. {
  20195. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  20196. }));
  20197. }
  20198. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  20199. {
  20200. foreach (var roomType in roomTypes)
  20201. {
  20202. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  20203. {
  20204. hotelRooms[roomType]--;
  20205. flights[flightType]--;
  20206. if (roomType == "TBR")
  20207. {
  20208. flights[flightType]--; // 双人间在减少1
  20209. }
  20210. string key = flightType + roomType;
  20211. if (result.Keys.Contains(key))
  20212. {
  20213. result[key]++;
  20214. }
  20215. else
  20216. {
  20217. result.Add(key, 1);
  20218. }
  20219. }
  20220. }
  20221. }
  20222. private class AirHotelPrice
  20223. {
  20224. public string Name { get; set; }
  20225. public decimal Price { get; set; }
  20226. public int Count { get; set; }
  20227. }
  20228. /// <summary>
  20229. /// 团组系数设置
  20230. /// </summary>
  20231. /// <param name="dto"></param>
  20232. /// <returns></returns>
  20233. [HttpPost]
  20234. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  20235. {
  20236. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  20237. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  20238. if (di == null)
  20239. {
  20240. return Ok(JsonView(false, "团组不存在!"));
  20241. }
  20242. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  20243. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  20244. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  20245. // FirstAsync(firstExpression.ToExpression());
  20246. #region JSON
  20247. string hcpJson = @"
  20248. [
  20249. {
  20250. ""min"": 1,
  20251. ""max"": 500,
  20252. ""value"": 1.50
  20253. },
  20254. {
  20255. ""min"": 501,
  20256. ""max"": 1000,
  20257. ""value"": 1.40
  20258. },
  20259. {
  20260. ""min"": 1001,
  20261. ""max"": 2000,
  20262. ""value"": 1.35
  20263. }
  20264. ]";
  20265. #endregion
  20266. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  20267. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  20268. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  20269. .ToList();
  20270. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  20271. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  20272. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  20273. // new List<(Predicate<decimal>, decimal)>()
  20274. // {
  20275. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  20276. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  20277. // }
  20278. // ));
  20279. #region 签证系数
  20280. var visaXS = 0.00M;
  20281. switch (dto.VisaCB)
  20282. {
  20283. case decimal n when (n > 1 && n < 500):
  20284. switch (dto.VisaRS)
  20285. {
  20286. case 2 or 3:
  20287. visaXS = 1.35M;
  20288. break;
  20289. case 4 or 5:
  20290. visaXS = 1.30M;
  20291. break;
  20292. case 6 or 7:
  20293. visaXS = 1.25M;
  20294. break;
  20295. case 8 or 9 or 10:
  20296. visaXS = 1.20M;
  20297. break;
  20298. case > 10:
  20299. visaXS = 1.15M;
  20300. break;
  20301. default:
  20302. visaXS = 0.00M;
  20303. break;
  20304. }
  20305. break;
  20306. case decimal n when (n >= 500 && n < 1000):
  20307. switch (dto.VisaRS)
  20308. {
  20309. case 2 or 3 or 4:
  20310. visaXS = 1.30M;
  20311. break;
  20312. case 5 or 6 or 7 or 8:
  20313. visaXS = 1.25M;
  20314. break;
  20315. case 9 or 10:
  20316. visaXS = 1.20M;
  20317. break;
  20318. case > 10:
  20319. visaXS = 1.15M;
  20320. break;
  20321. default:
  20322. visaXS = 0.00M;
  20323. break;
  20324. }
  20325. break;
  20326. default:
  20327. switch (dto.VisaRS)
  20328. {
  20329. case 2 or 3 or 4:
  20330. visaXS = 1.30M;
  20331. break;
  20332. case 5 or 6 or 7 or 8:
  20333. visaXS = 1.25M;
  20334. break;
  20335. case 9 or 10:
  20336. visaXS = 1.20M;
  20337. break;
  20338. case > 10:
  20339. visaXS = 1.15M;
  20340. break;
  20341. default:
  20342. visaXS = 0.00M;
  20343. break;
  20344. }
  20345. break;
  20346. }
  20347. #endregion
  20348. #region 火车系数
  20349. var hcpXS = 0.00M;
  20350. foreach (var (condition, result) in hcpSwitchDictionary)
  20351. {
  20352. if (condition(dto.HCPCB))
  20353. {
  20354. hcpXS = result;
  20355. break;
  20356. }
  20357. }
  20358. #endregion
  20359. #region 机票系数
  20360. #region 经济舱系数
  20361. var jjcXS = 0.00M;
  20362. switch (dto.JJCCB)
  20363. {
  20364. case decimal x when (x >= 1000 && x <= 3000):
  20365. jjcXS = 2.6M;
  20366. break;
  20367. case decimal x when (x >= 3001 && x <= 8000):
  20368. jjcXS = 2.3M;
  20369. break;
  20370. case decimal x when (x >= 8001 && x <= 15000):
  20371. jjcXS = 2.1M;
  20372. break;
  20373. case decimal x when (x >= 15001 && x <= 30000):
  20374. jjcXS = 1.95M;
  20375. break;
  20376. case > 30000:
  20377. jjcXS = 1.8M;
  20378. break;
  20379. default:
  20380. break;
  20381. }
  20382. #endregion
  20383. #region 公务舱系数
  20384. var gwcXS = 0.00M;
  20385. switch (dto.GWCCB)
  20386. {
  20387. case decimal x when (x >= 1000 && x <= 3000):
  20388. gwcXS = 2.5M;
  20389. break;
  20390. case decimal x when (x >= 3001 && x <= 8000):
  20391. gwcXS = 2.2M;
  20392. break;
  20393. case decimal x when (x >= 8001 && x <= 15000):
  20394. gwcXS = 2.0M;
  20395. break;
  20396. case decimal x when (x >= 15001 && x <= 30000):
  20397. gwcXS = 1.85M;
  20398. break;
  20399. case > 30000:
  20400. gwcXS = 1.7M;
  20401. break;
  20402. default:
  20403. break;
  20404. }
  20405. #endregion
  20406. #region 头等舱系数
  20407. var tdcXS = 0.00M;
  20408. switch (dto.TDCCB)
  20409. {
  20410. case > 70000:
  20411. tdcXS = 1.5M;
  20412. break;
  20413. default:
  20414. tdcXS = 1.9M;
  20415. break;
  20416. }
  20417. #endregion
  20418. #endregion
  20419. #region 酒店系数
  20420. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  20421. {
  20422. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  20423. {1.5M, new List<string>(){"越南社会主义共和国",
  20424. "老挝",
  20425. "柬埔寨",
  20426. "泰国",
  20427. "缅甸",
  20428. "马来西亚",
  20429. //"新加坡",
  20430. "文莱达鲁萨兰",
  20431. "印度尼西亚",
  20432. "东帝汶"}},
  20433. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  20434. };
  20435. #region SGR
  20436. var sgrXS = 1.25M;
  20437. #endregion
  20438. #region TBR
  20439. var tbrXS = 1.25M;
  20440. #endregion
  20441. #region JSES
  20442. var jsesXS = 1.25M;
  20443. #endregion
  20444. #region SUITE
  20445. var suiteXS = 1.25M;
  20446. #endregion
  20447. var countryArr = di.VisitCountry.Split("|");
  20448. foreach (var item in dic)
  20449. {
  20450. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  20451. .Count();
  20452. if (extsisCount > 0)
  20453. {
  20454. jsesXS = item.Key;
  20455. sgrXS = item.Key;
  20456. tbrXS = item.Key;
  20457. suiteXS = item.Key;
  20458. }
  20459. }
  20460. #endregion
  20461. #region 地接系数
  20462. var djXS = 0.00M;
  20463. switch (dto.DJRS)
  20464. {
  20465. case 2 or 3:
  20466. djXS = 2.65M;
  20467. break;
  20468. case 4:
  20469. djXS = 2.6M;
  20470. break;
  20471. case 5 or 6:
  20472. djXS = 2.5M;
  20473. break;
  20474. case 7 or 8:
  20475. djXS = 2.4M;
  20476. break;
  20477. case 9 or 10:
  20478. djXS = 2.3M;
  20479. break;
  20480. case 11:
  20481. djXS = 2.2M;
  20482. break;
  20483. case 12:
  20484. djXS = 2.1M;
  20485. break;
  20486. case 13 or 14:
  20487. djXS = 2M;
  20488. break;
  20489. case 15:
  20490. djXS = 1.9M;
  20491. break;
  20492. case 16 or 17 or 18:
  20493. djXS = 1.8M;
  20494. break;
  20495. case 19 or 20:
  20496. djXS = 1.7M;
  20497. break;
  20498. }
  20499. #endregion
  20500. #region 零用金系数
  20501. var lyjXS = 0.00M;
  20502. switch (dto.LYJRS)
  20503. {
  20504. case 2:
  20505. lyjXS = 1.25M;
  20506. break;
  20507. case 3 or 4 or 5:
  20508. lyjXS = 1.2M;
  20509. break;
  20510. case int number when (number > 5 && number < 10):
  20511. lyjXS = 1.15M;
  20512. break;
  20513. case > 10:
  20514. lyjXS = 1.1M;
  20515. break;
  20516. default:
  20517. break;
  20518. }
  20519. #endregion
  20520. return Ok(JsonView(true, "查询成功", new ArrayList()
  20521. {
  20522. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  20523. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  20524. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  20525. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  20526. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  20527. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  20528. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  20529. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  20530. new { label = "地接系数", value = djXS, key = "djXS" },
  20531. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  20532. new { label = "公务系数", value = 2M, key = "gwXS" }
  20533. }));
  20534. }
  20535. #endregion
  20536. #region 酒店预订 New 2023-12-28 17:45
  20537. /// <summary>
  20538. /// 酒店预订
  20539. /// 酒店费用列表 根据团组Id查询
  20540. /// </summary>
  20541. /// <param name="_dto"></param>
  20542. /// <returns></returns>
  20543. [HttpPost]
  20544. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20545. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  20546. {
  20547. #region 参数验证
  20548. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20549. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20550. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20551. #region 团组操作权限验证 76 酒店预定模块
  20552. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20553. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20554. #endregion
  20555. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20556. #region 页面操作权限验证
  20557. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20558. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20559. #endregion
  20560. #endregion
  20561. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  20562. }
  20563. /// <summary>
  20564. /// 酒店预订
  20565. /// 基础数据
  20566. /// </summary>
  20567. /// <param name="_dto"></param>
  20568. /// <returns></returns>
  20569. [HttpPost]
  20570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20571. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  20572. {
  20573. #region 参数验证
  20574. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20575. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20576. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20577. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20578. #region 页面操作权限验证
  20579. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20580. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20581. #endregion
  20582. #region 团组操作权限验证 76 酒店预定模块
  20583. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20584. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20585. #endregion
  20586. #endregion
  20587. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  20588. }
  20589. /// <summary>
  20590. /// 酒店预订
  20591. /// 创建 入住卷号码
  20592. /// </summary>
  20593. /// <param name="_dto"></param>
  20594. /// <returns></returns>
  20595. [HttpPost]
  20596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20597. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  20598. {
  20599. #region 参数验证
  20600. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20601. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20602. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20603. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20604. #region 页面操作权限验证
  20605. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20606. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20607. #endregion
  20608. #region 团组操作权限验证 76 酒店预定模块
  20609. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20610. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20611. #endregion
  20612. #endregion
  20613. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  20614. if (data.Code != 0)
  20615. {
  20616. return Ok(JsonView(false, data.Msg));
  20617. }
  20618. return Ok(JsonView(true, data.Msg, data.Data));
  20619. }
  20620. /// <summary>
  20621. /// 酒店预订
  20622. /// 详情
  20623. /// </summary>
  20624. /// <param name="_dto"></param>
  20625. /// <returns></returns>
  20626. [HttpPost]
  20627. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20628. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  20629. {
  20630. #region 参数验证
  20631. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  20632. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20633. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  20634. #region 团组操作权限验证 76 酒店预定模块
  20635. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20636. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20637. #endregion
  20638. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20639. #region 页面操作权限验证
  20640. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20641. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20642. #endregion
  20643. #endregion
  20644. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  20645. }
  20646. /// <summary>
  20647. /// 酒店预订
  20648. /// Add Or Edit
  20649. /// </summary>
  20650. /// <param name="_dto"></param>
  20651. /// <returns></returns>
  20652. [HttpPost]
  20653. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20654. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  20655. {
  20656. #region 参数验证
  20657. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20658. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20659. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20660. #region 团组操作权限验证 76 酒店预定模块
  20661. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20662. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20663. #endregion
  20664. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20665. #region 页面操作权限验证
  20666. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20667. if (_dto.Id == 0) // Add
  20668. {
  20669. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20670. }
  20671. else if (_dto.Id > 1) // Edit
  20672. {
  20673. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20674. }
  20675. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  20676. #endregion
  20677. #endregion
  20678. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  20679. if (_view.Code != 200)
  20680. {
  20681. return Ok(_view);
  20682. }
  20683. #region 成本无酒店价格数据进入超支
  20684. _sqlSugar.BeginTran();
  20685. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  20686. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  20687. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  20688. for (int i = 0; i < groupCost.Count; i++)
  20689. {
  20690. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  20691. {
  20692. groupCost[i].Date = groupCost[i - 1].Date;
  20693. }
  20694. }
  20695. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  20696. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  20697. List<Fin_GroupExtraCostDto_OP>();
  20698. if (start_Bool && end_Bool)
  20699. {
  20700. while (start_Time < end_Time)
  20701. {
  20702. foreach (var item in groupCost_Grp)
  20703. {
  20704. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  20705. {
  20706. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  20707. {
  20708. extraCostList.Add(new
  20709. Fin_GroupExtraCostDto_OP
  20710. {
  20711. Area = _dto.AreaId,
  20712. coefficient = 1.5M,
  20713. createUser = _dto.UserId,
  20714. currency = _dto.CardPriceCurrency,
  20715. diId = _dto.DiId,
  20716. ManagerConfirm = 0,
  20717. SupervisorConfirm = 0,
  20718. SYsupervisorConfirm = 0,
  20719. editType = 1,
  20720. PortType = 1,
  20721. price = _dto.CardPrice,
  20722. PriceCount = 1,
  20723. priceType = 1027,
  20724. priceDetailType = 1044,
  20725. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  20726. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  20727. });
  20728. }
  20729. }
  20730. }
  20731. start_Time = start_Time.AddDays(1);
  20732. }
  20733. }
  20734. if (extraCostList.Any())
  20735. {
  20736. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  20737. }
  20738. _sqlSugar.CommitTran();
  20739. #endregion
  20740. #region 应用推送
  20741. try
  20742. {
  20743. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  20744. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  20745. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  20746. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  20747. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  20748. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  20749. var diId = _dto.DiId;
  20750. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20751. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20752. #region 操作记录
  20753. var opInfo = new Crm_TableOperationRecord()
  20754. {
  20755. TableName = "Grp_HotelReservations",
  20756. PortType = _dto.PortType,
  20757. DataId = hotelId,
  20758. CreateUserId = _dto.UserId
  20759. };
  20760. //var opStatus = OperationEnum.NoOperation;
  20761. if (_dto.Id < 1) //添加操作
  20762. {
  20763. opInfo.OperationItem = OperationEnum.Add;
  20764. }
  20765. else if (_dto.Id > 0)
  20766. {
  20767. opInfo.OperationItem = OperationEnum.Edit;
  20768. }
  20769. string opRemark = string.Empty;
  20770. if (ccpInfo != null)
  20771. {
  20772. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  20773. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  20774. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  20775. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  20776. }
  20777. opInfo.Remark = opRemark;
  20778. await _tableorRep.AddAsync(opInfo);
  20779. #endregion
  20780. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  20781. //2024-10-21 新增LZ UID
  20782. var userIds = new List<int>() { 21 };
  20783. string title = $"费用审核";
  20784. string content = "";
  20785. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20786. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20787. try
  20788. {
  20789. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  20790. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  20791. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  20792. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  20793. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  20794. }
  20795. catch (Exception ex)
  20796. {
  20797. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  20798. }
  20799. }
  20800. catch (Exception ex)
  20801. {
  20802. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  20803. }
  20804. try
  20805. {
  20806. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  20807. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  20808. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  20809. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  20810. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  20811. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  20812. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  20813. //自动审核
  20814. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  20815. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  20816. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  20817. //2024-10-21 新增LZ UID
  20818. var userIds = new List<int>() { 21 };
  20819. string title = $"系统通知";
  20820. var diId = _dto.DiId;
  20821. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20822. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20823. string content = "";
  20824. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20825. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20826. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  20827. }
  20828. catch (Exception ex)
  20829. {
  20830. }
  20831. #endregion
  20832. return Ok(_view);
  20833. }
  20834. /// <summary>
  20835. /// 酒店自动审核测试
  20836. /// Add Or Edit
  20837. /// </summary>
  20838. /// <param name="diid"></param>
  20839. /// <param name="dataId"></param>
  20840. /// <returns></returns>
  20841. [HttpPost]
  20842. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20843. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  20844. {
  20845. #region 应用推送
  20846. try
  20847. {
  20848. //自动审核
  20849. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  20850. }
  20851. catch (Exception ex)
  20852. {
  20853. return Ok(JsonView(false, ex.Message));
  20854. }
  20855. #endregion
  20856. return Ok(JsonView(false, "操作成功"));
  20857. }
  20858. /// <summary>
  20859. /// 酒店预订
  20860. /// Del
  20861. /// </summary>
  20862. /// <param name="_dto"></param>
  20863. /// <returns></returns>
  20864. [HttpPost]
  20865. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20866. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  20867. {
  20868. #region 参数验证
  20869. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20870. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20871. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20872. #region 团组操作权限验证 76 酒店预定模块
  20873. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20874. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20875. #endregion
  20876. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20877. #region 页面操作权限验证
  20878. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20879. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20880. #endregion
  20881. #endregion
  20882. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  20883. #region 操作记录
  20884. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  20885. {
  20886. TableName = "Grp_HotelReservations",
  20887. PortType = _dto.PortType,
  20888. OperationItem = OperationEnum.Del,
  20889. DataId = _dto.Id,
  20890. CreateUserId = _dto.UserId
  20891. });
  20892. #endregion
  20893. return Ok(data);
  20894. }
  20895. /// <summary>
  20896. /// 酒店预订
  20897. /// 生成VOUCHER
  20898. /// 2024.05.06 之前版本
  20899. /// </summary>
  20900. /// <param name="_dto"></param>
  20901. /// <returns></returns>
  20902. [HttpPost]
  20903. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20904. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  20905. {
  20906. try
  20907. {
  20908. #region 参数验证
  20909. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20910. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20911. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20912. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  20913. #region 团组操作权限验证 76 酒店预定模块
  20914. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20915. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20916. #endregion
  20917. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20918. #region 页面操作权限验证
  20919. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20920. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20921. #endregion
  20922. #endregion
  20923. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  20924. //判断数据是否完整
  20925. if (hr != null)
  20926. {
  20927. if (!string.IsNullOrEmpty(hr.DetermineNo))
  20928. {
  20929. string strFileName = "HotelStatement/";
  20930. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  20931. if (dele != null)
  20932. strFileName += dele.TourCode;
  20933. //载入模板
  20934. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  20935. Document doc = new Document(sss);
  20936. DocumentBuilder builder = new DocumentBuilder(doc);
  20937. #region 替换Word模板书签内容
  20938. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  20939. //入住卷预定号码
  20940. if (doc.Range.Bookmarks["VNO"] != null)
  20941. {
  20942. Bookmark mark = doc.Range.Bookmarks["VNO"];
  20943. mark.Text = hr.CheckNumber;
  20944. }
  20945. //酒店时间
  20946. if (doc.Range.Bookmarks["Date"] != null)
  20947. {
  20948. Bookmark mark = doc.Range.Bookmarks["Date"];
  20949. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  20950. }
  20951. //团号
  20952. if (doc.Range.Bookmarks["TNo"] != null)
  20953. {
  20954. Bookmark mark = doc.Range.Bookmarks["TNo"];
  20955. mark.Text = dele.TourCode;
  20956. }
  20957. //预定号码
  20958. if (doc.Range.Bookmarks["BookingId"] != null)
  20959. {
  20960. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  20961. mark.Text = hr.ReservationsNo;
  20962. }
  20963. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  20964. {
  20965. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  20966. mark.Text = hr.DetermineNo;
  20967. }
  20968. //酒店城市
  20969. if (doc.Range.Bookmarks["City"] != null)
  20970. {
  20971. Bookmark mark = doc.Range.Bookmarks["City"];
  20972. mark.Text = hr.City;
  20973. }
  20974. //酒店名称
  20975. if (doc.Range.Bookmarks["HName"] != null)
  20976. {
  20977. Bookmark mark = doc.Range.Bookmarks["HName"];
  20978. mark.Text = hr.HotelName;
  20979. }
  20980. //酒店地址
  20981. if (doc.Range.Bookmarks["Address"] != null)
  20982. {
  20983. Bookmark mark = doc.Range.Bookmarks["Address"];
  20984. mark.Text = hr.HotelAddress;
  20985. }
  20986. //酒店电话
  20987. if (doc.Range.Bookmarks["Tel"] != null)
  20988. {
  20989. Bookmark mark = doc.Range.Bookmarks["Tel"];
  20990. mark.Text = hr.HotelTel;
  20991. }
  20992. //酒店传真
  20993. if (doc.Range.Bookmarks["Fax"] != null)
  20994. {
  20995. Bookmark mark = doc.Range.Bookmarks["Fax"];
  20996. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  20997. {
  20998. mark.Text = hr.HotelFax;
  20999. }
  21000. }
  21001. //入住时间
  21002. if (doc.Range.Bookmarks["CIn"] != null)
  21003. {
  21004. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  21005. Bookmark mark = doc.Range.Bookmarks["CIn"];
  21006. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  21007. }
  21008. //退房时间
  21009. if (doc.Range.Bookmarks["COut"] != null)
  21010. {
  21011. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  21012. Bookmark mark = doc.Range.Bookmarks["COut"];
  21013. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  21014. }
  21015. //客户名称
  21016. if (doc.Range.Bookmarks["GName"] != null)
  21017. {
  21018. string guestName = "";
  21019. string[] clients = Array.Empty<string>();
  21020. if (hr.GuestName.Contains(","))
  21021. {
  21022. clients = hr.GuestName.Split(",");
  21023. }
  21024. else
  21025. {
  21026. clients = new string[] { hr.GuestName };
  21027. }
  21028. List<int> clientIds_int = new List<int>();
  21029. if (clients.Length > 0)
  21030. {
  21031. foreach (var item in clients)
  21032. {
  21033. if (item.IsNumeric())
  21034. {
  21035. clientIds_int.Add(int.Parse(item));
  21036. }
  21037. }
  21038. }
  21039. if (clientIds_int.Count > 0)
  21040. {
  21041. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  21042. foreach (var client in _clientDatas)
  21043. {
  21044. //男
  21045. if (client.Sex == 0) guestName += $"Mr.";
  21046. //女
  21047. else if (client.Sex == 1) guestName += $"Ms.";
  21048. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  21049. {
  21050. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  21051. }
  21052. //guestName += $"{client.Pinyin},";
  21053. }
  21054. if (guestName.Length > 0)
  21055. {
  21056. guestName = guestName.Substring(0, guestName.Length - 1);
  21057. }
  21058. }
  21059. else
  21060. {
  21061. guestName = hr.GuestName;
  21062. }
  21063. Bookmark mark = doc.Range.Bookmarks["GName"];
  21064. mark.Text = guestName;
  21065. }
  21066. //房间介绍
  21067. if (doc.Range.Bookmarks["ROOM"] != null)
  21068. {
  21069. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  21070. mark.Text = hr.RoomExplanation;
  21071. }
  21072. //报价描述
  21073. if (doc.Range.Bookmarks["NOTE"] != null)
  21074. {
  21075. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  21076. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  21077. if (ss != null)
  21078. mark.Text = ss.Name;
  21079. }
  21080. //入住时间
  21081. if (doc.Range.Bookmarks["CheckIn"] != null)
  21082. {
  21083. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  21084. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  21085. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  21086. }
  21087. //退房时间
  21088. if (doc.Range.Bookmarks["CheckOut"] != null)
  21089. {
  21090. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  21091. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  21092. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  21093. }
  21094. //日期
  21095. if (doc.Range.Bookmarks["DT"] != null)
  21096. {
  21097. Bookmark mark = doc.Range.Bookmarks["DT"];
  21098. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  21099. }
  21100. //名称
  21101. if (doc.Range.Bookmarks["VName"] != null)
  21102. {
  21103. Bookmark mark = doc.Range.Bookmarks["VName"];
  21104. mark.Text = hr.HotelName;
  21105. }
  21106. //号码
  21107. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  21108. {
  21109. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  21110. mark.Text = hr.CheckNumber;
  21111. }
  21112. #endregion
  21113. strFileName += "VOUCHER.doc";
  21114. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  21115. doc.Save(fileDir);
  21116. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  21117. return Ok(JsonView(true, "操作成功!", Url));
  21118. }
  21119. else
  21120. {
  21121. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  21122. }
  21123. }
  21124. else
  21125. {
  21126. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  21127. }
  21128. }
  21129. catch (Exception ex)
  21130. {
  21131. return Ok(JsonView(false, ex.Message));
  21132. }
  21133. }
  21134. /// <summary>
  21135. /// 酒店预订
  21136. /// 生成VOUCHER
  21137. /// 2024.05.06 之后版本
  21138. /// </summary>
  21139. /// <param name="_dto"></param>
  21140. /// <returns></returns>
  21141. [HttpPost]
  21142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21143. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  21144. {
  21145. #region 参数验证
  21146. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  21147. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  21148. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  21149. #region 团组操作权限验证 76 酒店预定模块
  21150. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  21151. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  21152. #endregion
  21153. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21154. #region 页面操作权限验证
  21155. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21156. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21157. #endregion
  21158. #endregion
  21159. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  21160. //判断数据是否完整
  21161. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  21162. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  21163. string strFileName = "HotelStatement/";
  21164. string guestNames = ""; //格式Mr.xxx Ms.xxx
  21165. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  21166. #region 数据处理
  21167. List<int> guestIds = new List<int>();
  21168. //int index = 0;
  21169. foreach (var item in hrDtas)
  21170. {
  21171. if (item.GuestName.Contains(","))
  21172. {
  21173. string[] guestIdArr = item.GuestName.Split(',');
  21174. foreach (var guestIdStr in guestIdArr)
  21175. {
  21176. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  21177. if (guestBool)
  21178. {
  21179. guestIds.Add(guestId);
  21180. }
  21181. }
  21182. }
  21183. else guestNames += item.GuestName;
  21184. var voucherInfo = new HotelVoucherInfoView()
  21185. {
  21186. HotelName = item.HotelName,
  21187. CheckInDate = item.CheckInDate,
  21188. CheckOutDate = item.CheckOutDate,
  21189. ConfirmationNumber = item.DetermineNo.Trim(),
  21190. RoomType = item.RoomExplanation
  21191. };
  21192. vouchers.Add(voucherInfo);
  21193. }
  21194. if (guestIds.Count > 0)
  21195. {
  21196. guestIds = guestIds.Distinct().ToList();
  21197. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  21198. if (guestDatas.Count > 0)
  21199. {
  21200. guestNames = "";
  21201. foreach (var guest in guestDatas)
  21202. {
  21203. string guestName = "";
  21204. if (guest.Sex == 0) guestName += @"MR.";
  21205. else if (guest.Sex == 1) guestName += @"MS.";
  21206. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  21207. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  21208. guestNames += @$"{guestName.Trim()}、";
  21209. }
  21210. if (guestNames.Length > 0)
  21211. {
  21212. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  21213. }
  21214. }
  21215. }
  21216. #endregion
  21217. //载入模板
  21218. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  21219. Document doc = new Document(sss);
  21220. DocumentBuilder builder = new DocumentBuilder(doc);
  21221. if (doc.Range.Bookmarks["GuestName"] != null)
  21222. {
  21223. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  21224. mark.Text = guestNames;
  21225. }
  21226. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21227. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  21228. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  21229. for (int i = 1; i <= vouchers.Count; i++)
  21230. {
  21231. HotelVoucherInfoView hviv = vouchers[i - 1];
  21232. builder.MoveToCell(0, i, 0, 0);
  21233. builder.Write(hviv.HotelName);
  21234. builder.MoveToCell(0, i, 1, 0);
  21235. builder.Write(hviv.CheckInDate);
  21236. builder.MoveToCell(0, i, 2, 0);
  21237. builder.Write(hviv.CheckOutDate);
  21238. builder.MoveToCell(0, i, 3, 0);
  21239. builder.Write(hviv.RoomType);
  21240. builder.MoveToCell(0, i, 4, 0);
  21241. builder.Write(hviv.ConfirmationNumber);
  21242. }
  21243. //删除多余行
  21244. int currRowIndex = vouchers.Count + 1;
  21245. int delRows = 21 - currRowIndex;
  21246. if (delRows > 0)
  21247. {
  21248. for (int i = 0; i < delRows; i++)
  21249. {
  21250. table.Rows.RemoveAt(currRowIndex);
  21251. //cultivateRowIndex++;
  21252. }
  21253. }
  21254. strFileName += "VOUCHER.docx";
  21255. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  21256. doc.Save(fileDir);
  21257. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  21258. return Ok(JsonView(true, "操作成功!", Url));
  21259. }
  21260. /// <summary>
  21261. /// 酒店预订
  21262. /// 生成VOUCHER 批量生成
  21263. /// New
  21264. /// </summary>
  21265. /// <param name="_dto"></param>
  21266. /// <returns></returns>
  21267. [HttpPost]
  21268. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21269. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  21270. {
  21271. #region 参数验证
  21272. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  21273. if (_dto.PageId < 1) _dto.PageId = 28;
  21274. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  21275. #region 团组操作权限验证 76 酒店预定模块
  21276. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  21277. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  21278. #endregion
  21279. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21280. #region 页面操作权限验证
  21281. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21282. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21283. #endregion
  21284. #endregion
  21285. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  21286. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  21287. .OrderBy(x => x.CheckInDate)
  21288. .ToListAsync();
  21289. //判断数据是否完整
  21290. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  21291. string strFileName = "HotelStatement/";
  21292. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  21293. if (dele != null)
  21294. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  21295. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  21296. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  21297. .Where(it => it.IsDel == 0)
  21298. .ToListAsync();
  21299. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  21300. for (int i = 0; i < hrDtas.Count; i++)
  21301. {
  21302. string guestNames = string.Empty;
  21303. List<int> guestIds = new List<int>();
  21304. var item = hrDtas[i];
  21305. //处理客户姓名
  21306. if (item.GuestName.Contains(","))
  21307. {
  21308. string[] guestIdArr = item.GuestName.Split(',');
  21309. foreach (var guestIdStr in guestIdArr)
  21310. if (int.TryParse(guestIdStr, out int guestId))
  21311. guestIds.Add(guestId);
  21312. }
  21313. else
  21314. {
  21315. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  21316. if (guestIdBool)
  21317. {
  21318. guestIds.Add(guestId);
  21319. }
  21320. //NaN
  21321. if (item.GuestName.Contains("NaN"))
  21322. {
  21323. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  21324. }
  21325. }
  21326. if (guestIds.Count > 0)
  21327. {
  21328. guestIds = guestIds.Distinct().ToList();
  21329. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  21330. if (guestDatas1.Count > 0)
  21331. {
  21332. guestNames = "";
  21333. foreach (var guest in guestDatas1)
  21334. {
  21335. string guestName = "";
  21336. if (guest.Sex == 0) guestName += @"MR.";
  21337. else if (guest.Sex == 1) guestName += @"MS.";
  21338. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  21339. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  21340. guestNames += @$"{guestName.Trim()}、";
  21341. }
  21342. if (guestNames.Length > 0)
  21343. {
  21344. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  21345. }
  21346. }
  21347. }
  21348. //if (!string.IsNullOrEmpty(guestNames))
  21349. //{
  21350. hrDtas[i].GuestName = guestNames;
  21351. //}
  21352. }
  21353. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  21354. Document doc = new Document();
  21355. DocumentBuilder builder = new DocumentBuilder(doc);
  21356. try
  21357. {
  21358. builder.MoveToDocumentStart();
  21359. foreach (var item in hrDtas)
  21360. {
  21361. //标题
  21362. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  21363. builder.ParagraphFormat.LineSpacing = 1;
  21364. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21365. builder.ParagraphFormat.Style.Font.Size = 9;
  21366. builder.ParagraphFormat.Style.Font.Bold = true;
  21367. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21368. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  21369. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  21370. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21371. builder.ParagraphFormat.LineSpacing = 1;
  21372. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21373. builder.ParagraphFormat.Style.Font.Size = 9;
  21374. builder.ParagraphFormat.Style.Font.Bold = true;
  21375. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  21376. builder.StartTable();
  21377. // 设置边框颜色
  21378. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  21379. //设置边框样式
  21380. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  21381. //表格
  21382. #region 第一行
  21383. builder.InsertCell();
  21384. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21385. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21386. //builder.CellFormat.AllowAutoFit = false;
  21387. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21388. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21389. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21390. builder.CellFormat.WrapText = true; //自动换行
  21391. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21392. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  21393. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21394. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21395. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21396. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21397. builder.Write("TOUR NO:");
  21398. builder.InsertCell();
  21399. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21400. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21401. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21402. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21403. builder.ParagraphFormat.Style.Font.Bold = false;
  21404. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21405. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21406. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21407. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21408. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21409. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21410. builder.Write($"{dele?.TourCode ?? "-"}");
  21411. builder.InsertCell();
  21412. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21413. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21414. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21415. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21416. builder.ParagraphFormat.Style.Font.Bold = false;
  21417. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21418. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21419. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21420. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21421. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21422. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21423. builder.Write($"CITY:");
  21424. builder.InsertCell();
  21425. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21426. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21427. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21428. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21429. builder.ParagraphFormat.Style.Font.Bold = false;
  21430. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21431. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21432. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21433. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21434. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21435. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21436. builder.Write($"{item.City}");
  21437. builder.EndRow();
  21438. #endregion
  21439. #region 第二行
  21440. builder.InsertCell();
  21441. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21442. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21443. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21444. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21445. builder.ParagraphFormat.Style.Font.Bold = false;
  21446. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21447. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21448. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21449. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21450. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21451. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21452. builder.Write("CONFIRMATION NO:");
  21453. builder.InsertCell();
  21454. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21455. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21456. builder.ParagraphFormat.Style.Font.Size = 8;
  21457. builder.ParagraphFormat.Style.Font.Bold = false;
  21458. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21459. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21460. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21461. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21462. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21463. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21464. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21465. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21466. builder.Write($"{item.DetermineNo}");
  21467. builder.InsertCell();
  21468. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21469. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21470. builder.InsertCell();
  21471. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21472. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21473. builder.EndRow();
  21474. #endregion
  21475. #region 第三行
  21476. builder.InsertCell();
  21477. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21478. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21479. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21480. builder.ParagraphFormat.Style.Font.Bold = false;
  21481. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21482. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21483. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21484. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21485. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21486. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21487. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21488. builder.Write($"HOTEL NAME:");
  21489. builder.InsertCell();
  21490. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21491. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21492. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21493. builder.ParagraphFormat.Style.Font.Bold = false;
  21494. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21495. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21496. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21497. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21498. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21499. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21500. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21501. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21502. builder.Write($"{item.HotelName}");
  21503. builder.InsertCell();
  21504. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21505. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21506. builder.InsertCell();
  21507. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21508. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21509. builder.EndRow();
  21510. #endregion
  21511. #region 第四行
  21512. builder.InsertCell();
  21513. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21514. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21515. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21516. builder.ParagraphFormat.Style.Font.Bold = false;
  21517. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21518. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21519. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21520. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21521. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21522. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21523. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21524. builder.Write($"HOTEL ADDRESS:");
  21525. builder.InsertCell();
  21526. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21527. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21528. builder.ParagraphFormat.Style.Font.Size = 8;
  21529. builder.ParagraphFormat.Style.Font.Bold = false;
  21530. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21531. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21532. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21533. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21534. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21535. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21536. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21537. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21538. builder.Write($"{item.HotelAddress}");
  21539. builder.InsertCell();
  21540. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21541. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21542. builder.InsertCell();
  21543. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21544. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21545. builder.EndRow();
  21546. #endregion
  21547. #region 第五行
  21548. builder.InsertCell();
  21549. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21550. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21551. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21552. builder.ParagraphFormat.Style.Font.Bold = false;
  21553. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21554. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21555. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21556. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21557. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21558. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21559. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21560. builder.Write("TEL:");
  21561. builder.InsertCell();
  21562. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21563. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21564. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21565. builder.ParagraphFormat.Style.Font.Bold = false;
  21566. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21567. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21568. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21569. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21570. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21571. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21572. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21573. builder.Write($"{item.HotelTel}");
  21574. builder.InsertCell();
  21575. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21576. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21577. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21578. builder.ParagraphFormat.Style.Font.Bold = false;
  21579. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21580. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21581. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21582. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21583. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21584. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21585. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21586. builder.Write($"FAX:");
  21587. builder.InsertCell();
  21588. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21589. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21590. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21591. builder.ParagraphFormat.Style.Font.Bold = false;
  21592. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21593. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21594. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21595. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21596. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21597. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21598. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21599. builder.Write($"{item.HotelFax}");
  21600. builder.EndRow();
  21601. #endregion
  21602. #region 第六行
  21603. builder.InsertCell();
  21604. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21605. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21606. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21607. builder.ParagraphFormat.Style.Font.Bold = false;
  21608. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21609. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21610. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21611. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21612. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21613. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21614. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21615. builder.Write("CHECK IN:");
  21616. builder.InsertCell();
  21617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21618. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21619. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21620. builder.ParagraphFormat.Style.Font.Bold = false;
  21621. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21622. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21623. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21624. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21625. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21626. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21627. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21628. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  21629. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  21630. builder.Write($"{checkInStr}");
  21631. builder.InsertCell();
  21632. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21633. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21634. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21635. builder.ParagraphFormat.Style.Font.Bold = false;
  21636. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21637. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21638. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21639. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21640. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21641. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21642. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21643. builder.Write($"CHECK OUT:");
  21644. builder.InsertCell();
  21645. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21646. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21647. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21648. builder.ParagraphFormat.Style.Font.Bold = false;
  21649. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21650. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21651. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21652. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21653. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21654. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21655. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21656. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  21657. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  21658. builder.Write($"{checkOutStr}");
  21659. builder.EndRow();
  21660. #endregion
  21661. #region 第七行
  21662. builder.InsertCell();
  21663. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21664. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21665. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21666. builder.ParagraphFormat.Style.Font.Bold = false;
  21667. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21668. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21669. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21670. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21671. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21672. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21673. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21674. builder.Write($"GUEST NAME:");
  21675. builder.InsertCell();
  21676. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21677. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21678. builder.ParagraphFormat.Style.Font.Size = 8;
  21679. builder.ParagraphFormat.Style.Font.Bold = false;
  21680. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21681. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21682. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21683. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21684. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21685. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21686. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21687. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21688. builder.Write($"{item.GuestName.Trim()}");
  21689. builder.InsertCell();
  21690. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21691. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21692. builder.InsertCell();
  21693. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21694. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21695. builder.EndRow();
  21696. #endregion
  21697. #region 第八行
  21698. builder.InsertCell();
  21699. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21700. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21701. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21702. builder.ParagraphFormat.Style.Font.Bold = false;
  21703. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21704. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21705. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21706. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21707. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21708. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21709. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21710. builder.Write($"ROOM TYPE:");
  21711. builder.InsertCell();
  21712. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21713. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21714. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21715. builder.ParagraphFormat.Style.Font.Bold = false;
  21716. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21717. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21718. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21719. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21720. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21721. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21722. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21723. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21724. builder.Write($"{item.RoomExplanation}");
  21725. builder.InsertCell();
  21726. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21727. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21728. builder.InsertCell();
  21729. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21730. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21731. builder.EndRow();
  21732. #endregion
  21733. #region 第九行
  21734. builder.InsertCell();
  21735. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21736. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21737. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21738. builder.ParagraphFormat.Style.Font.Bold = false;
  21739. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21740. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21741. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21742. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21743. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21744. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21745. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21746. builder.Write($"NOTE:");
  21747. builder.InsertCell();
  21748. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21749. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21750. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21751. builder.ParagraphFormat.Style.Font.Bold = false;
  21752. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21753. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21754. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21755. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21756. 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.");
  21757. builder.InsertCell();
  21758. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21759. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21760. builder.InsertCell();
  21761. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21762. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21763. builder.EndRow();
  21764. #endregion
  21765. builder.EndTable();
  21766. //换行
  21767. builder.Writeln("");
  21768. builder.Writeln("");
  21769. }
  21770. #region 获取文档中的所有表格 设置文字自适应
  21771. // 获取文档中的所有表格。
  21772. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  21773. {
  21774. // 遍历表格中的所有行。
  21775. foreach (Aspose.Words.Tables.Row row in table.Rows)
  21776. {
  21777. foreach (Cell cell in row.Cells)
  21778. {
  21779. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  21780. cellFormat.Width = 0;
  21781. }
  21782. }
  21783. }
  21784. #endregion
  21785. #region 设置页眉
  21786. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  21787. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  21788. if (System.IO.File.Exists(voucherHeaderPath))
  21789. {
  21790. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  21791. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  21792. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  21793. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  21794. // 调整图片位置
  21795. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  21796. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  21797. shape.Top = 50; // 将图片距离页眉上边缘的距离
  21798. shape.Left = 0; // 将图片距离页面左边缘的距离
  21799. shape.Width = 81; // 设置图片宽度
  21800. shape.Height = 36; // 设置图片高度
  21801. }
  21802. //靠右
  21803. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  21804. //// 设置页脚上下边距
  21805. //builder.PageSetup.HeaderDistance = 42;
  21806. // 添加页眉线
  21807. Aspose.Words.Border borderHeader = null;
  21808. try
  21809. {
  21810. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  21811. }
  21812. catch (Exception e)
  21813. {
  21814. // TODO Auto-generated catch block
  21815. //e.printStackTrace();
  21816. }
  21817. borderHeader.Shadow = true;
  21818. borderHeader.DistanceFromText = 2;
  21819. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  21820. #endregion
  21821. }
  21822. catch (Exception ex)
  21823. {
  21824. }
  21825. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  21826. doc.Save(fileDir);
  21827. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  21828. return Ok(JsonView(true, "操作成功!", Url));
  21829. }
  21830. /// <summary>
  21831. /// 酒店预订
  21832. /// 生成 预定成本 Excel
  21833. /// </summary>
  21834. /// <param name="_dto"></param>
  21835. /// <returns></returns>
  21836. [HttpPost]
  21837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21838. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  21839. {
  21840. #region 参数验证
  21841. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  21842. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  21843. if (!vadalitorRes.IsValid)
  21844. {
  21845. var errors = new StringBuilder();
  21846. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  21847. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  21848. }
  21849. #region 团组操作权限验证 76 酒店预定模块
  21850. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  21851. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  21852. #endregion
  21853. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21854. #region 页面操作权限验证
  21855. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21856. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21857. #endregion
  21858. #endregion
  21859. decimal _rate = 1.00M;
  21860. string _currency = string.Empty;
  21861. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  21862. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  21863. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  21864. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  21865. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  21866. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  21867. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  21868. if (_GroupCostParameter == null)
  21869. {
  21870. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  21871. bool isIntType = int.TryParse(_currency, out int currId);
  21872. if (isIntType)
  21873. {
  21874. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  21875. }
  21876. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  21877. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  21878. if (currInfo == null)
  21879. {
  21880. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  21881. }
  21882. else _rate = currInfo.Rate;
  21883. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  21884. {
  21885. _rate = _GroupCostParameter.Rate;
  21886. }
  21887. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  21888. //string strFileName = "HotelStatement/";
  21889. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  21890. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  21891. var rateDatas = new List<dynamic>();
  21892. #region 数据处理
  21893. foreach (var item in hrDtas)
  21894. {
  21895. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  21896. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  21897. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  21898. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  21899. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  21900. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  21901. {
  21902. continue;
  21903. }
  21904. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  21905. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  21906. string singleRoomFeeStr = string.Empty,
  21907. doubleRoomFeeStr = string.Empty,
  21908. suiteRoomFeeStr = string.Empty,
  21909. otherRoomFeeStr = string.Empty,
  21910. payMoneyStr = string.Empty,
  21911. cardPriceStr = string.Empty;
  21912. if (roomCurr.Equals("CNY"))
  21913. {
  21914. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  21915. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  21916. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  21917. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  21918. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  21919. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  21920. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  21921. }
  21922. else
  21923. {
  21924. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  21925. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  21926. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  21927. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  21928. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  21929. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  21930. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  21931. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  21932. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  21933. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  21934. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  21935. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  21936. if (ccpPaymentCurrency.Equals("CNY"))
  21937. {
  21938. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  21939. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  21940. }
  21941. else
  21942. {
  21943. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  21944. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  21945. }
  21946. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  21947. if (hotelcardPriceCurrency.Equals("CNY"))
  21948. {
  21949. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  21950. }
  21951. else
  21952. {
  21953. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  21954. }
  21955. }
  21956. string breakfastPriceStr = string.Empty,
  21957. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  21958. governmentRentStr = string.Empty,
  21959. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  21960. cityTaxStr = string.Empty,
  21961. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  21962. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  21963. if (!string.IsNullOrEmpty(breakfastCurrency1))
  21964. {
  21965. if (breakfastCurrency1.Equals("CNY"))
  21966. {
  21967. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  21968. }
  21969. else
  21970. {
  21971. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  21972. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  21973. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  21974. }
  21975. }
  21976. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  21977. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  21978. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  21979. {
  21980. if (governmentRentCurrency.Equals("CNY"))
  21981. {
  21982. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  21983. }
  21984. else
  21985. {
  21986. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  21987. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  21988. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  21989. }
  21990. }
  21991. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  21992. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  21993. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  21994. {
  21995. if (cityTaxStrCurrency1.Equals("CNY"))
  21996. {
  21997. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  21998. }
  21999. else
  22000. {
  22001. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  22002. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  22003. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  22004. }
  22005. }
  22006. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  22007. int payDId = roomInfo?.PayDId ?? 0;
  22008. pcfds.Add(new HotelReservations_PCFD_View()
  22009. {
  22010. City = item.City,
  22011. HotelName = item.HotelName,
  22012. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  22013. // SingleRoomCount = item.SingleRoomCount,
  22014. SingleRoomPrice = singleRoomFeeStr,
  22015. // DoubleRoomCount = item.DoubleRoomCount,
  22016. DoubleRoomPrice = doubleRoomFeeStr,
  22017. //SuiteRoomCount = item.SuiteRoomCount,
  22018. SuiteRoomPrice = suiteRoomFeeStr,
  22019. OtherRoomPrice = otherRoomFeeStr,
  22020. //OtherRoomCount = item.OtherRoomCount,
  22021. BreakfastPrice = breakfastPriceStr,
  22022. GovernmentRent = governmentRentStr,
  22023. CityTax = cityTaxStr,
  22024. RoomExplanation = item.RoomExplanation,
  22025. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  22026. PayTime = roomInfo?.ConsumptionDate,
  22027. BankNo = roomInfo?.BankNo,
  22028. PayMoney = payMoneyStr,
  22029. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  22030. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  22031. CardPrice = cardPriceStr,
  22032. Remark = ccpInfo.Remark
  22033. });
  22034. }
  22035. #endregion
  22036. //载入模板
  22037. WorkbookDesigner designer = new WorkbookDesigner();
  22038. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  22039. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  22040. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  22041. designer.SetDataSource("TourNo", groupInfo.TourCode);
  22042. var rateDatas1 = rateDatas.Distinct();
  22043. var rateStr = string.Empty;
  22044. foreach (var item in rateDatas1)
  22045. {
  22046. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  22047. }
  22048. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  22049. designer.SetDataSource("Opertor", userInfo.CnName);
  22050. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  22051. dt.TableName = "ViewMyHotelReservations";
  22052. designer.SetDataSource(dt);
  22053. designer.Process();
  22054. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  22055. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  22056. designer.Workbook.Save(serverPath);
  22057. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  22058. #region 删除指定行
  22059. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  22060. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  22061. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  22062. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  22063. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  22064. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  22065. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  22066. cssIndex = dt.Columns["CityTax"].Ordinal,
  22067. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  22068. remarkIndex = dt.Columns["Remark"].Ordinal;
  22069. //删除指定列
  22070. foreach (DataRow item in dt.Rows)
  22071. {
  22072. string singleStr = item["SingleRoomPrice"].ToString();
  22073. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  22074. if (containsDigitButNotZero1) singleDel = false;
  22075. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  22076. string doubleStr = item["DoubleRoomPrice"].ToString();
  22077. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22078. if (containsDigitButNotZero2) doubleDel = false;
  22079. string suiteStr = item["SuiteRoomPrice"].ToString();
  22080. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22081. if (containsDigitButNotZero3) suiteDel = false;
  22082. string otherStr = item["OtherRoomPrice"].ToString();
  22083. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  22084. if (containsDigitButNotZero4) otherDel = false;
  22085. string zcStr = item["BreakfastPrice"].ToString();
  22086. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  22087. if (containsDigitButNotZero5) zcDel = false;
  22088. string dsStr = item["GovernmentRent"].ToString();
  22089. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  22090. if (containsDigitButNotZero6) dsDel = false;
  22091. string cssStr = item["CityTax"].ToString();
  22092. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  22093. if (containsDigitButNotZero7) cssDel = false;
  22094. string cpStr = item["ConsumptionPatterns"].ToString();
  22095. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  22096. string remarkStr = item["Remark"].ToString();
  22097. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  22098. }
  22099. DeleteColumn(serverPath, remarkIndex, remarkDel);
  22100. DeleteColumn(serverPath, cpIndex, cpDel);
  22101. DeleteColumn(serverPath, dsIndex, dsDel);
  22102. DeleteColumn(serverPath, cssIndex, cssDel);
  22103. DeleteColumn(serverPath, zcIndex, zcDel);
  22104. DeleteColumn(serverPath, otherIndex, otherDel);
  22105. DeleteColumn(serverPath, suiteIndex, suiteDel);
  22106. DeleteColumn(serverPath, doubleIndex, doubleDel);
  22107. DeleteColumn(serverPath, singleIndex, singleDel);
  22108. #endregion
  22109. //只保留第一个表格
  22110. DeleteSheet(serverPath);
  22111. return Ok(JsonView(true, "操作成功", url = rst));
  22112. }
  22113. else
  22114. {
  22115. _currency = _GroupCostParameter.Currency;
  22116. bool isIntType = int.TryParse(_currency, out int currId);
  22117. if (isIntType)
  22118. {
  22119. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  22120. }
  22121. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  22122. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  22123. if (currInfo == null)
  22124. {
  22125. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  22126. }
  22127. if (!_currency.ToUpper().Equals("CNY"))
  22128. {
  22129. _rate = _GroupCostParameter.Rate;
  22130. }
  22131. _rate = currInfo.Rate;
  22132. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  22133. //string strFileName = "HotelStatement/";
  22134. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  22135. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  22136. #region 数据处理
  22137. foreach (var item in hrDtas)
  22138. {
  22139. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  22140. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  22141. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  22142. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  22143. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  22144. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  22145. string singleRoomFeeStr = string.Empty,
  22146. doubleRoomFeeStr = string.Empty,
  22147. suiteRoomFeeStr = string.Empty,
  22148. otherRoomFeeStr = string.Empty,
  22149. payMoneyStr = string.Empty,
  22150. cardPriceStr = string.Empty;
  22151. if (roomCurr.Equals(_currency))
  22152. {
  22153. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  22154. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  22155. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  22156. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  22157. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  22158. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  22159. }
  22160. else
  22161. {
  22162. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  22163. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  22164. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  22165. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  22166. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  22167. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  22168. }
  22169. string breakfastPriceStr = string.Empty,
  22170. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  22171. governmentRentStr = string.Empty,
  22172. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  22173. cityTaxStrStr = string.Empty,
  22174. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  22175. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  22176. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  22177. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  22178. int payDId = roomInfo?.PayDId ?? 0;
  22179. pcfds.Add(new HotelReservations_PCFD_View()
  22180. {
  22181. City = item.City,
  22182. HotelName = item.HotelName,
  22183. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  22184. // SingleRoomCount = item.SingleRoomCount,
  22185. SingleRoomPrice = singleRoomFeeStr,
  22186. // DoubleRoomCount = item.DoubleRoomCount,
  22187. DoubleRoomPrice = doubleRoomFeeStr,
  22188. //SuiteRoomCount = item.SuiteRoomCount,
  22189. SuiteRoomPrice = suiteRoomFeeStr,
  22190. OtherRoomPrice = otherRoomFeeStr,
  22191. //OtherRoomCount = item.OtherRoomCount,
  22192. BreakfastPrice = breakfastPriceStr,
  22193. GovernmentRent = governmentRentStr,
  22194. CityTax = cityTaxStrStr,
  22195. RoomExplanation = item.RoomExplanation,
  22196. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  22197. PayTime = roomInfo?.ConsumptionDate,
  22198. BankNo = roomInfo?.BankNo,
  22199. PayMoney = payMoneyStr,
  22200. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  22201. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  22202. CardPrice = cardPriceStr,
  22203. Remark = ccpInfo.Remark
  22204. });
  22205. }
  22206. #endregion
  22207. //载入模板
  22208. WorkbookDesigner designer = new WorkbookDesigner();
  22209. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  22210. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  22211. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  22212. designer.SetDataSource("TourNo", groupInfo.TourCode);
  22213. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  22214. designer.SetDataSource("Opertor", userInfo.CnName);
  22215. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  22216. dt.TableName = "ViewMyHotelReservations";
  22217. designer.SetDataSource(dt);
  22218. designer.Process();
  22219. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  22220. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  22221. designer.Workbook.Save(serverPath);
  22222. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  22223. #region 删除指定行
  22224. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  22225. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  22226. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  22227. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  22228. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  22229. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  22230. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  22231. cssIndex = dt.Columns["CityTax"].Ordinal,
  22232. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  22233. remarkIndex = dt.Columns["Remark"].Ordinal;
  22234. //删除指定列
  22235. foreach (DataRow item in dt.Rows)
  22236. {
  22237. string singleStr = item["SingleRoomPrice"].ToString();
  22238. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  22239. if (containsDigitButNotZero1) singleDel = false;
  22240. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  22241. string doubleStr = item["DoubleRoomPrice"].ToString();
  22242. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22243. if (containsDigitButNotZero2) doubleDel = false;
  22244. string suiteStr = item["SuiteRoomPrice"].ToString();
  22245. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22246. if (containsDigitButNotZero3) suiteDel = false;
  22247. string otherStr = item["OtherRoomPrice"].ToString();
  22248. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  22249. if (containsDigitButNotZero4) otherDel = false;
  22250. string zcStr = item["BreakfastPrice"].ToString();
  22251. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  22252. if (containsDigitButNotZero5) zcDel = false;
  22253. string dsStr = item["GovernmentRent"].ToString();
  22254. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  22255. if (containsDigitButNotZero6) dsDel = false;
  22256. string cssStr = item["CityTax"].ToString();
  22257. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  22258. if (containsDigitButNotZero7) cssDel = false;
  22259. string cpStr = item["ConsumptionPatterns"].ToString();
  22260. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  22261. string remarkStr = item["Remark"].ToString();
  22262. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  22263. }
  22264. DeleteColumn(serverPath, remarkIndex, remarkDel);
  22265. DeleteColumn(serverPath, cpIndex, cpDel);
  22266. DeleteColumn(serverPath, dsIndex, dsDel);
  22267. DeleteColumn(serverPath, cssIndex, cssDel);
  22268. DeleteColumn(serverPath, zcIndex, zcDel);
  22269. DeleteColumn(serverPath, otherIndex, otherDel);
  22270. DeleteColumn(serverPath, suiteIndex, suiteDel);
  22271. DeleteColumn(serverPath, doubleIndex, doubleDel);
  22272. DeleteColumn(serverPath, singleIndex, singleDel);
  22273. #endregion
  22274. //只保留第一个表格
  22275. DeleteSheet(serverPath);
  22276. return Ok(JsonView(true, "操作成功", url = rst));
  22277. }
  22278. //return Ok(JsonView(false));
  22279. }
  22280. /// <summary>
  22281. /// 删除指定列
  22282. /// </summary>
  22283. /// <param name="file"></param>
  22284. /// <param name="columnIndex"></param>
  22285. /// <param name="isDel"></param>
  22286. private void DeleteColumn(string file, int columnIndex, bool isDel)
  22287. {
  22288. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  22289. //wb.Save(file);
  22290. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  22291. if (sheet1 != null)
  22292. {
  22293. if (isDel)
  22294. {
  22295. Cells cells = sheet1.Cells;
  22296. cells.DeleteColumn(columnIndex);
  22297. }
  22298. }
  22299. wb.Save(file);
  22300. }
  22301. /// <summary>
  22302. /// 删除sheet
  22303. /// </summary>
  22304. /// <param name="file"></param>
  22305. private void DeleteSheet(string file)
  22306. {
  22307. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  22308. //wb.Save(file);
  22309. List<string> sheets = new List<string>();
  22310. foreach (var item in wb.Worksheets)
  22311. {
  22312. sheets.Add(item.Name);
  22313. }
  22314. if (sheets.Count > 0)
  22315. {
  22316. sheets.RemoveAt(0);//不删除第一个sheet
  22317. foreach (var item in sheets)
  22318. {
  22319. wb.Worksheets.RemoveAt(item);
  22320. }
  22321. }
  22322. wb.Save(file);
  22323. }
  22324. /// <summary>
  22325. /// 酒店预订
  22326. /// 确认单
  22327. /// </summary>
  22328. /// <param name="_dto"></param>
  22329. /// <returns></returns>
  22330. [HttpPost]
  22331. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22332. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  22333. {
  22334. try
  22335. {
  22336. #region 参数验证
  22337. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  22338. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  22339. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  22340. #region 团组操作权限验证 76 酒店预定模块
  22341. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  22342. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  22343. #endregion
  22344. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22345. #region 页面操作权限验证
  22346. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22347. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  22348. #endregion
  22349. #endregion
  22350. //团组信息
  22351. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  22352. //酒店数据
  22353. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  22354. if (listhoteldata.Count < 0)
  22355. {
  22356. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  22357. }
  22358. //利datatable存储
  22359. DataTable dt = new DataTable();
  22360. dt.Columns.Add("CheckInDate", typeof(string));
  22361. dt.Columns.Add("City", typeof(string));
  22362. dt.Columns.Add("Hotel", typeof(string));
  22363. dt.Columns.Add("Room", typeof(string));
  22364. for (int i = 0; i < listhoteldata.Count; i++)
  22365. {
  22366. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  22367. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  22368. while (dayStart < dayEnd)
  22369. {
  22370. string temp = "";
  22371. DataRow row = dt.NewRow();
  22372. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  22373. row["City"] = listhoteldata[i].City;
  22374. row["Hotel"] = listhoteldata[i].HotelName;
  22375. if (listhoteldata[i].SingleRoomCount > 0)
  22376. {
  22377. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  22378. }
  22379. if (listhoteldata[i].DoubleRoomCount > 0)
  22380. {
  22381. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  22382. }
  22383. if (listhoteldata[i].SuiteRoomCount > 0)
  22384. {
  22385. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  22386. }
  22387. if (listhoteldata[i].OtherRoomCount > 0)
  22388. {
  22389. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  22390. }
  22391. row["Room"] = temp;
  22392. dt.Rows.Add(row);
  22393. dayStart = dayStart.AddDays(1);
  22394. }
  22395. }
  22396. Dictionary<string, string> dic = new Dictionary<string, string>();
  22397. dic.Add("Dele", di.TeamName);
  22398. dic.Add("City", di.VisitCountry);
  22399. //模板路径
  22400. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  22401. //载入模板
  22402. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  22403. DocumentBuilder builder = new DocumentBuilder(doc);
  22404. foreach (var key in dic.Keys)
  22405. {
  22406. builder.MoveToBookmark(key);
  22407. builder.Write(dic[key]);
  22408. }
  22409. //获取word里所有表格
  22410. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22411. //获取所填表格的序数
  22412. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22413. var rowStart = tableOne.Rows[0]; //获取第1行
  22414. //循环赋值
  22415. for (int i = 0; i < dt.Rows.Count; i++)
  22416. {
  22417. builder.MoveToCell(0, i + 1, 0, 0);
  22418. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  22419. builder.MoveToCell(0, i + 1, 1, 0);
  22420. builder.Write(dt.Rows[i]["City"].ToString());
  22421. builder.MoveToCell(0, i + 1, 2, 0);
  22422. builder.Write(dt.Rows[i]["Hotel"].ToString());
  22423. builder.MoveToCell(0, i + 1, 3, 0);
  22424. builder.Write(dt.Rows[i]["Room"].ToString());
  22425. }
  22426. //删除多余行
  22427. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  22428. {
  22429. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  22430. }
  22431. string strFileName = di.TeamName + "酒店确认单.doc";
  22432. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  22433. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  22434. return Ok(JsonView(true, "成功", url));
  22435. }
  22436. catch (Exception ex)
  22437. {
  22438. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  22439. }
  22440. }
  22441. #endregion
  22442. #region 团组状态
  22443. /// <summary>
  22444. /// 团组状态列表 Page
  22445. /// </summary>
  22446. /// <param name="dto">团组列表请求dto</param>
  22447. /// <returns></returns>
  22448. [HttpPost]
  22449. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22450. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  22451. {
  22452. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  22453. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  22454. {
  22455. string sqlWhere = string.Empty;
  22456. if (dto.IsSure == 0) //未完成
  22457. {
  22458. sqlWhere += string.Format(@" And IsSure = 0");
  22459. }
  22460. else if (dto.IsSure == 1) //已完成
  22461. {
  22462. sqlWhere += string.Format(@" And IsSure = 1");
  22463. }
  22464. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  22465. {
  22466. string tj = dto.SearchCriteria;
  22467. 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}%')",
  22468. tj, tj, tj, tj, tj);
  22469. }
  22470. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  22471. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  22472. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  22473. From (
  22474. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  22475. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  22476. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  22477. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  22478. From Grp_DelegationInfo gdi
  22479. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  22480. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  22481. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  22482. Where gdi.IsDel = 0 {0}
  22483. ) temp ", sqlWhere);
  22484. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  22485. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  22486. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  22487. }
  22488. else
  22489. {
  22490. return Ok(JsonView(false, "查询失败"));
  22491. }
  22492. }
  22493. /// <summary>
  22494. /// 团组状态
  22495. /// 设置操作完成
  22496. /// </summary>
  22497. /// <param name="dto">团组列表请求dto</param>
  22498. /// <returns></returns>
  22499. [HttpPost]
  22500. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22501. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  22502. {
  22503. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  22504. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  22505. {
  22506. Id = dto.Id,
  22507. IsSure = 1
  22508. };
  22509. var result = await _sqlSugar.Updateable(_DelegationInfo)
  22510. .UpdateColumns(it => new { it.IsSure })
  22511. .WhereColumns(it => new { it.Id })
  22512. .ExecuteCommandAsync();
  22513. if (result > 0)
  22514. {
  22515. return Ok(JsonView(true, "操作完成!"));
  22516. }
  22517. return Ok(JsonView(false, "操作失败!"));
  22518. }
  22519. #endregion
  22520. #region 保险费用录入
  22521. /// <summary>
  22522. /// 根据团组Id查询保险费用列表
  22523. /// </summary>
  22524. /// <param name="dto"></param>
  22525. /// <returns></returns>
  22526. [HttpPost]
  22527. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22528. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  22529. {
  22530. Result groupData = await _customersRep.CustomersByDiId(dto);
  22531. if (groupData.Code != 0)
  22532. {
  22533. return Ok(JsonView(false, groupData.Msg));
  22534. }
  22535. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22536. }
  22537. /// <summary>
  22538. /// 根据保险费用Id查询保险费用详细
  22539. /// </summary>
  22540. /// <param name="dto"></param>
  22541. /// <returns></returns>
  22542. [HttpPost]
  22543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22544. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  22545. {
  22546. try
  22547. {
  22548. Result groupData = await _customersRep.CustomersById(dto);
  22549. if (groupData.Code != 0)
  22550. {
  22551. return Ok(JsonView(false, groupData.Msg));
  22552. }
  22553. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22554. }
  22555. catch (Exception ex)
  22556. {
  22557. return Ok(JsonView(false, ex.Message));
  22558. }
  22559. }
  22560. /// <summary>
  22561. /// 保险费用录入页面初始化绑定
  22562. /// </summary>
  22563. /// <param name="dto"></param>
  22564. /// <returns></returns>
  22565. [HttpPost]
  22566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22567. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  22568. {
  22569. try
  22570. {
  22571. Result groupData = await _customersRep.CustomersInitialize(dto);
  22572. if (groupData.Code != 0)
  22573. {
  22574. return Ok(JsonView(false, groupData.Msg));
  22575. }
  22576. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22577. }
  22578. catch (Exception ex)
  22579. {
  22580. return Ok(JsonView(false, ex.Message));
  22581. }
  22582. }
  22583. /// <summary>
  22584. /// 保险费用操作(Status:1.新增,2.修改)
  22585. /// </summary>
  22586. /// <param name="dto"></param>
  22587. /// <returns></returns>
  22588. [HttpPost]
  22589. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22590. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  22591. {
  22592. Result groupData = await _customersRep.OpCustomers(dto);
  22593. if (groupData.Code != 0)
  22594. {
  22595. return Ok(JsonView(false, groupData.Msg));
  22596. }
  22597. #region 应用推送
  22598. try
  22599. {
  22600. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  22601. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  22602. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  22603. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  22604. //自动审核
  22605. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  22606. //2024-10-21 新增LZ UID
  22607. var userIds = new List<int>() { 21 };
  22608. string title = $"系统通知";
  22609. var diId = dto.DiId;
  22610. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  22611. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  22612. string content = "";
  22613. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  22614. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  22615. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  22616. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  22617. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  22618. }
  22619. catch (Exception ex)
  22620. {
  22621. }
  22622. #endregion
  22623. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22624. }
  22625. /// <summary>
  22626. /// 保险文件上传
  22627. /// </summary>
  22628. /// <param name="file"></param>
  22629. /// <returns></returns>
  22630. [HttpPost]
  22631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22632. public async Task<IActionResult> UploadCus(IFormFile file)
  22633. {
  22634. try
  22635. {
  22636. if (file != null)
  22637. {
  22638. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  22639. //文件名称
  22640. string projectFileName = file.FileName;
  22641. //上传的文件的路径
  22642. string filePath = "";
  22643. if (!Directory.Exists(fileDir))
  22644. {
  22645. Directory.CreateDirectory(fileDir);
  22646. }
  22647. //上传的文件的路径
  22648. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  22649. using (FileStream fs = System.IO.File.Create(filePath))
  22650. {
  22651. file.CopyTo(fs);
  22652. fs.Flush();
  22653. }
  22654. return Ok(JsonView(true, "上传成功!", projectFileName));
  22655. }
  22656. else
  22657. {
  22658. return Ok(JsonView(false, "上传失败!"));
  22659. }
  22660. }
  22661. catch (Exception ex)
  22662. {
  22663. return Ok(JsonView(false, ex.Message));
  22664. }
  22665. }
  22666. /// <summary>
  22667. /// 保险删除指定文件
  22668. /// </summary>
  22669. /// <param name="dto"></param>
  22670. /// <returns></returns>
  22671. [HttpPost]
  22672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22673. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  22674. {
  22675. try
  22676. {
  22677. string filePath = "";
  22678. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  22679. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  22680. //int id = 0;
  22681. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  22682. // 删除该文件
  22683. try
  22684. {
  22685. System.IO.File.Delete(filePath);
  22686. 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()
  22687. {
  22688. Attachment = "",
  22689. }).ExecuteCommandAsync();
  22690. if (result != 0)
  22691. {
  22692. return Ok(JsonView(true, "成功!"));
  22693. }
  22694. else
  22695. {
  22696. return Ok(JsonView(false, "失败!"));
  22697. }
  22698. }
  22699. catch (Exception)
  22700. {
  22701. 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()
  22702. {
  22703. Attachment = "",
  22704. }).ExecuteCommandAsync();
  22705. if (result != 0)
  22706. {
  22707. return Ok(JsonView(true, "成功!"));
  22708. }
  22709. else
  22710. {
  22711. return Ok(JsonView(false, "失败!"));
  22712. }
  22713. }
  22714. }
  22715. catch (Exception ex)
  22716. {
  22717. return Ok(JsonView(false, "程序错误!"));
  22718. throw;
  22719. }
  22720. }
  22721. /// <summary>
  22722. /// 保险费用操作(删除)
  22723. /// </summary>
  22724. /// <param name="dto"></param>
  22725. /// <returns></returns>
  22726. [HttpPost]
  22727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22728. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  22729. {
  22730. try
  22731. {
  22732. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  22733. if (!res)
  22734. {
  22735. return Ok(JsonView(false, "删除失败"));
  22736. }
  22737. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  22738. {
  22739. IsDel = 1,
  22740. DeleteUserId = dto.DeleteUserId,
  22741. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  22742. }).ExecuteCommandAsync();
  22743. return Ok(JsonView(true, "删除成功!"));
  22744. }
  22745. catch (Exception ex)
  22746. {
  22747. return Ok(JsonView(false, "程序错误!"));
  22748. throw;
  22749. }
  22750. }
  22751. #endregion
  22752. #region 接团客户名单 PageId 104
  22753. /// <summary>
  22754. /// 接团客户名单
  22755. /// 迁移数据(慎用!)
  22756. /// </summary>
  22757. /// <returns></returns>
  22758. [HttpPost]
  22759. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22760. public async Task<IActionResult> PostTourClientListChange()
  22761. {
  22762. try
  22763. {
  22764. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  22765. //var groupClinetData1
  22766. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  22767. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  22768. int updateCount = 0;
  22769. if (oldOAClientList.Count > 0)
  22770. {
  22771. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  22772. _sqlSugar.BeginTran();
  22773. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  22774. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  22775. foreach (var item in oldOAClientList)
  22776. {
  22777. int comId = 0;
  22778. string format = "yyyy-MM-dd HH:mm:ss";
  22779. string data11 = "1990-01-01 00:00";
  22780. var data1 = IsValidDate(item.OPdate, format);
  22781. if (data1) data11 = item.OPdate;
  22782. //客户公司验证
  22783. if (!string.IsNullOrEmpty(item.Company))
  22784. {
  22785. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  22786. if (clientComInfo == null) // add
  22787. {
  22788. var addInfo = new Crm_CustomerCompany()
  22789. {
  22790. CompanyAbbreviation = "",
  22791. CompanyFullName = item.Company,
  22792. Address = "",
  22793. PostCodes = "",
  22794. LastedOpUserId = item.OPer,
  22795. LastedOpDt = Convert.ToDateTime(data11),
  22796. CreateUserId = item.OPer,
  22797. CreateTime = Convert.ToDateTime(data11),
  22798. IsDel = 0
  22799. };
  22800. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  22801. if (comId1 > 0) comId = comId1;
  22802. }
  22803. else comId = clientComInfo.Id;
  22804. }
  22805. //客户人员验证
  22806. int clientId = 0;
  22807. string name = item.LastName + item.Name;
  22808. if (!string.IsNullOrEmpty(name))
  22809. {
  22810. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  22811. if (clientInfo == null)
  22812. {
  22813. DateTime? dateTime = null;
  22814. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  22815. if (isDt) dateTime = birthDayDt;
  22816. var addInfo1 = new Crm_DeleClient()
  22817. {
  22818. CrmCompanyId = comId,
  22819. DiId = -1,
  22820. LastName = item.LastName,
  22821. FirstName = item.Name,
  22822. OldName = "",
  22823. Pinyin = item.Pinyin,
  22824. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  22825. Marriage = 0,
  22826. Phone = item.Phone,
  22827. Job = item.Job,
  22828. BirthDay = dateTime
  22829. };
  22830. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  22831. if (clientId1 > 0) clientId = clientId1;
  22832. }
  22833. else clientId = clientInfo.Id;
  22834. }
  22835. if (clientId < 1)
  22836. {
  22837. continue;
  22838. }
  22839. int airType = 0;
  22840. if (item.AirType == "超经舱") airType = 459;
  22841. else if (item.AirType == "公务舱") airType = 458;
  22842. else if (item.AirType == "经济舱") airType = 460;
  22843. else if (item.AirType == "其他") airType = 565;
  22844. else if (item.AirType == "头等舱") airType = 457;
  22845. var _TourClientListEntity = new Grp_TourClientList()
  22846. {
  22847. DiId = item.Diid,
  22848. ClientId = clientId,
  22849. CreateUserId = item.OPer,
  22850. CreateTime = Convert.ToDateTime(data11),
  22851. Remark = item.Remark,
  22852. IsDel = item.Isdel,
  22853. ShippingSpaceTypeId = airType,
  22854. ShippingSpaceSpecialNeeds = item.AirRemark,
  22855. HotelSpecialNeeds = item.RoomType
  22856. };
  22857. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  22858. if (_TourClientList > 0)
  22859. {
  22860. updateCount++;
  22861. }
  22862. }
  22863. _sqlSugar.CommitTran();
  22864. }
  22865. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  22866. }
  22867. catch (Exception ex)
  22868. {
  22869. _sqlSugar.RollbackTran();
  22870. return Ok(JsonView(false, ex.Message));
  22871. }
  22872. //return Ok(JsonView(true));
  22873. }
  22874. private bool IsValidDate(string dateString, string format)
  22875. {
  22876. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  22877. }
  22878. /// <summary>
  22879. /// 接团客户名单
  22880. /// 根据团组Id查询List
  22881. /// </summary>
  22882. /// <param name="_dto"></param>
  22883. /// <returns></returns>
  22884. [HttpPost]
  22885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22886. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  22887. {
  22888. #region 参数验证
  22889. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  22890. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  22891. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  22892. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22893. #region 页面操作权限验证
  22894. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22895. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  22896. #endregion
  22897. #endregion
  22898. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  22899. if (viewData.Code != 0)
  22900. {
  22901. return Ok(JsonView(false, viewData.Msg));
  22902. }
  22903. return Ok(JsonView(viewData.Data));
  22904. }
  22905. /// <summary>
  22906. /// 接团客户名单
  22907. /// 基础数据 Init
  22908. /// </summary>
  22909. /// <param name="_dto"></param>
  22910. /// <returns></returns>
  22911. [HttpPost]
  22912. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22913. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  22914. {
  22915. #region 参数验证
  22916. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  22917. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  22918. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22919. #region 页面操作权限验证
  22920. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22921. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  22922. #endregion
  22923. #endregion
  22924. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  22925. }
  22926. /// <summary>
  22927. /// 接团客户名单
  22928. /// 根据 Id查询 Details
  22929. /// </summary>
  22930. /// <param name="_dto"></param>
  22931. /// <returns></returns>
  22932. [HttpPost]
  22933. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22934. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  22935. {
  22936. #region 参数验证
  22937. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  22938. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  22939. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  22940. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22941. #region 页面操作权限验证
  22942. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22943. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  22944. #endregion
  22945. #endregion
  22946. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  22947. if (viewData.Code != 0)
  22948. {
  22949. return Ok(JsonView(false, viewData.Msg));
  22950. }
  22951. return Ok(JsonView(viewData.Data));
  22952. }
  22953. /// <summary>
  22954. /// 接团客户名单
  22955. /// Add Or Edit
  22956. /// </summary>
  22957. /// <param name="_dto"></param>
  22958. /// <returns></returns>
  22959. [HttpPost]
  22960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22961. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  22962. {
  22963. #region 参数验证
  22964. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  22965. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  22966. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  22967. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22968. #region 页面操作权限验证
  22969. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22970. if (_dto.Id == 0) //添加
  22971. {
  22972. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  22973. }
  22974. else if (_dto.Id >= 0) //修改
  22975. {
  22976. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  22977. }
  22978. #endregion
  22979. #endregion
  22980. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  22981. if (viewData.Code != 0)
  22982. {
  22983. return Ok(JsonView(false, viewData.Msg));
  22984. }
  22985. return Ok(JsonView(true));
  22986. }
  22987. /// <summary>
  22988. /// 接团客户名单
  22989. /// json字符串 AddMultiple(添加多个)
  22990. /// </summary>
  22991. /// <param name="_dto"></param>
  22992. /// <returns></returns>
  22993. [HttpPost]
  22994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22995. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  22996. {
  22997. #region 参数验证
  22998. string jsonLabel = _dto.JsonLabel;
  22999. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23000. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23001. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23002. #region 页面操作权限验证
  23003. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23004. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  23005. #endregion
  23006. #endregion
  23007. var request = new TourClientListAddMultipleDto();
  23008. request.DiId = _dto.DiId;
  23009. request.UserId = _dto.UserId;
  23010. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  23011. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  23012. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  23013. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  23014. var infos = new List<TourClientListInfo>();
  23015. foreach (var data in datas)
  23016. {
  23017. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  23018. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  23019. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  23020. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  23021. {
  23022. continue;
  23023. }
  23024. infos.Add(new TourClientListInfo()
  23025. {
  23026. IsAccompany = 1,
  23027. LastName = lastName,
  23028. FirstName = firstName,
  23029. Pinyin = lastNameEn + @"/" + firstNameEn,
  23030. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  23031. CompanyFullName = data.CompanyFullName,
  23032. Job = data.Job
  23033. });
  23034. }
  23035. if (infos.Any())
  23036. {
  23037. var viewData = await _tourClientListRep._AddMultiple(request);
  23038. if (viewData.Code != 0)
  23039. {
  23040. return Ok(JsonView(false, viewData.Msg));
  23041. }
  23042. return Ok(JsonView(true));
  23043. }
  23044. return Ok(JsonView(false));
  23045. }
  23046. /// <summary>
  23047. /// 接团客户名单
  23048. /// AddMultiple(添加多个)
  23049. /// </summary>
  23050. /// <param name="_dto"></param>
  23051. /// <returns></returns>
  23052. [HttpPost]
  23053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23054. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  23055. {
  23056. #region 参数验证
  23057. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23058. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23059. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23060. #region 页面操作权限验证
  23061. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23062. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  23063. #endregion
  23064. #endregion
  23065. var viewData = await _tourClientListRep._AddMultiple(_dto);
  23066. if (viewData.Code != 0)
  23067. {
  23068. return Ok(JsonView(false, viewData.Msg));
  23069. }
  23070. return Ok(JsonView(true));
  23071. }
  23072. /// <summary>
  23073. /// 接团客户名单
  23074. /// Del
  23075. /// </summary>
  23076. /// <param name="_dto"></param>
  23077. /// <returns></returns>
  23078. [HttpPost]
  23079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23080. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  23081. {
  23082. #region 参数验证
  23083. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23084. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23085. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23086. #region 页面操作权限验证
  23087. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23088. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  23089. #endregion
  23090. #endregion
  23091. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  23092. if (viewData.Code != 0)
  23093. {
  23094. return Ok(JsonView(false, viewData.Msg));
  23095. }
  23096. return Ok(JsonView(true));
  23097. }
  23098. /// <summary>
  23099. /// 接团客户名单
  23100. /// 文件下载 客户名单
  23101. /// </summary>
  23102. /// <param name="_dto"></param>
  23103. /// <returns></returns>
  23104. [HttpPost]
  23105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23106. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  23107. {
  23108. #region 参数验证
  23109. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23110. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23111. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  23112. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23113. #region 页面操作权限验证
  23114. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23115. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  23116. #endregion
  23117. #endregion
  23118. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  23119. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  23120. From Grp_TourClientList tcl
  23121. Left Join
  23122. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  23123. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  23124. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  23125. From Crm_DeleClient dc
  23126. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  23127. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  23128. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  23129. Where dc.IsDel = 0) temp
  23130. On temp.DcId =tcl.ClientId
  23131. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  23132. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  23133. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  23134. //载入模板
  23135. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  23136. if (_dto.Language == 1)
  23137. {
  23138. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  23139. }
  23140. //载入模板
  23141. var doc = new Document(tempPath);
  23142. DocumentBuilder builder = new DocumentBuilder(doc);
  23143. //获取word里所有表格
  23144. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  23145. //获取所填表格的序数
  23146. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  23147. var rowStart = tableOne.Rows[0]; //获取第1行
  23148. if (_dto.Language == 0)
  23149. {
  23150. //循环赋值
  23151. for (int i = 0; i < DcList.Count; i++)
  23152. {
  23153. EncryptionProcessor.DecryptProperties(DcList[i]);
  23154. builder.MoveToCell(0, i + 1, 0, 0);
  23155. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  23156. builder.MoveToCell(0, i + 1, 1, 0);
  23157. int sex = DcList[i].Sex;
  23158. string sexStr = string.Empty;
  23159. if (sex == 0) sexStr = "男";
  23160. else if (sex == 1) sexStr = "女";
  23161. else sexStr = "未设置";
  23162. builder.Write(sexStr);
  23163. builder.MoveToCell(0, i + 1, 2, 0);
  23164. string birthDay = DcList[i].BirthDay;
  23165. string birthDayStr = string.Empty;
  23166. if (!string.IsNullOrEmpty(birthDay))
  23167. {
  23168. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  23169. }
  23170. builder.Write(birthDayStr);
  23171. builder.MoveToCell(0, i + 1, 3, 0);
  23172. string company = "";
  23173. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  23174. {
  23175. company = DcList[i].CompanyFullName.ToString();
  23176. }
  23177. builder.Write(company);
  23178. builder.MoveToCell(0, i + 1, 4, 0);
  23179. builder.Write(DcList[i].Job);
  23180. }
  23181. }
  23182. else if (_dto.Language == 1)
  23183. {
  23184. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  23185. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  23186. List<string> transArrayStr = new List<string>();
  23187. string transStrRes1 = "";
  23188. var clientEnglishs = new List<ClientEnglishView>();
  23189. for (int i = 0; i < DcList.Count; i++)
  23190. {
  23191. var dc = DcList[i];
  23192. EncryptionProcessor.DecryptProperties(dc);
  23193. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  23194. if (dc.Job.Equals("暂无")) dc.Job = "-";
  23195. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  23196. if (DcList.Count - 1 == i) transStrRes1 += str1;
  23197. else transStrRes1 += $"{str1}|";
  23198. clientEnglishs.Add(new()
  23199. {
  23200. Id = dc.Id,
  23201. LastName = dc.LastName,
  23202. FirstName = dc.FirstName,
  23203. Pinyin = dc.Pinyin,
  23204. Sex = dc.Sex,
  23205. CompanyFullName = dc.CompanyFullName,
  23206. Job = dc.Job,
  23207. IDCardNo = dc.IDCardNo,
  23208. BirthDay = dc.BirthDay,
  23209. });
  23210. }
  23211. #region AI转英文
  23212. string jsonValue = JsonConvert.SerializeObject(clientEnglishs);
  23213. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  23214. List<SeedMessages> messages = new List<SeedMessages>()
  23215. {
  23216. new SeedMessages
  23217. {
  23218. Role = KimiRole.user,
  23219. Content = jsonValue + text
  23220. }
  23221. };
  23222. KiMiApiClient client = new KiMiApiClient();
  23223. var kimiApiResult = await client.SeedMessage(messages);
  23224. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  23225. string clients = kimiApiResult_JObject["content"].ToString();
  23226. string startStr = "```json", endStr = "```";
  23227. // 判断并清除开头部分
  23228. if (clients.StartsWith(startStr))
  23229. {
  23230. clients = clients.Remove(0, startStr.Length);
  23231. }
  23232. // 判断并清除结尾部分
  23233. if (clients.EndsWith(endStr))
  23234. {
  23235. clients = clients.Remove(clients.Length - endStr.Length);
  23236. }
  23237. var en_Json = JsonConvert.DeserializeObject<List<ClientEnglishView>>(clients);
  23238. //循环赋值
  23239. for (int i = 0; i < en_Json.Count; i++)
  23240. {
  23241. var dc = en_Json[i];
  23242. var dc1 = DcList.Find(x => x.Id == dc.Id);
  23243. string PYName = dc.FirstName + " " + dc.LastName;
  23244. builder.MoveToCell(0, i + 1, 0, 0);
  23245. builder.Write(PYName);
  23246. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  23247. builder.MoveToCell(0, i + 1, 1, 0);
  23248. builder.Write(sex);
  23249. DateTime birthDt;
  23250. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  23251. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  23252. builder.MoveToCell(0, i + 1, 2, 0);
  23253. builder.Write(birthday);
  23254. string company = string.Empty, job = string.Empty;
  23255. company = dc.CompanyFullName;
  23256. job = dc.Job;
  23257. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  23258. {
  23259. //查询对照表
  23260. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  23261. if (tempCec != null)
  23262. {
  23263. company = tempCec.enName;
  23264. }
  23265. }
  23266. builder.MoveToCell(0, i + 1, 3, 0);
  23267. builder.Write(company);
  23268. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  23269. {
  23270. //查询对照表
  23271. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  23272. if (tempPec != null)
  23273. {
  23274. job = tempPec.enName;
  23275. }
  23276. }
  23277. builder.MoveToCell(0, i + 1, 4, 0);
  23278. builder.Write(job);
  23279. }
  23280. #endregion
  23281. #region 旧翻译英文处理
  23282. ////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";
  23283. //string transStrRes = "";
  23284. //if (transStrRes1.Length > 0)
  23285. //{
  23286. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  23287. //}
  23288. ////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
  23289. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  23290. ////List<string> transArray = new List<string> { };
  23291. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  23292. //if (transStrRes.Contains("|"))
  23293. //{
  23294. // string[] transArray1 = transStrRes.Split('|');
  23295. // if (transArray1.Length > 0)
  23296. // {
  23297. // foreach (var item in transArray1)
  23298. // {
  23299. // if (item.Contains("&"))
  23300. // {
  23301. // string[] transArray2 = item.Split('&');
  23302. // int index = 0;
  23303. // string companyName = "", job = "";
  23304. // if (transArray2.Length > 0)
  23305. // {
  23306. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  23307. // if (1 < transArray2.Length) companyName = transArray2[1];
  23308. // if (2 < transArray2.Length) job = transArray2[2];
  23309. // }
  23310. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  23311. // }
  23312. // }
  23313. // }
  23314. //}
  23315. ////循环赋值
  23316. //for (int i = 0; i < DcList.Count; i++)
  23317. //{
  23318. // string PYName = "";
  23319. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  23320. // {
  23321. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  23322. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  23323. // PYName = PY_First + " " + PY_Last;
  23324. // }
  23325. // else
  23326. // {
  23327. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  23328. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  23329. // PYName = PY_First + " " + PY_Last;
  23330. // }
  23331. // builder.MoveToCell(0, i + 1, 0, 0);
  23332. // builder.Write(PYName);
  23333. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  23334. // builder.MoveToCell(0, i + 1, 1, 0);
  23335. // builder.Write(sex);
  23336. // DateTime birthDt;
  23337. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  23338. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  23339. // builder.MoveToCell(0, i + 1, 2, 0);
  23340. // builder.Write(birthday);
  23341. // string company = string.Empty, job = string.Empty;
  23342. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  23343. // if (dcTransInfo != null)
  23344. // {
  23345. // company = dcTransInfo.CompanyName;
  23346. // job = dcTransInfo.Job;
  23347. // }
  23348. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  23349. // {
  23350. // //查询对照表
  23351. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  23352. // if (tempCec != null)
  23353. // {
  23354. // company = tempCec.enName;
  23355. // }
  23356. // //翻译
  23357. // else
  23358. // {
  23359. // }
  23360. // }
  23361. // builder.MoveToCell(0, i + 1, 3, 0);
  23362. // builder.Write(company);
  23363. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  23364. // {
  23365. // //查询对照表
  23366. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  23367. // if (tempPec != null)
  23368. // {
  23369. // job = tempPec.enName;
  23370. // }
  23371. // //翻译
  23372. // else
  23373. // {
  23374. // }
  23375. // }
  23376. // builder.MoveToCell(0, i + 1, 4, 0);
  23377. // builder.Write(job);
  23378. //}
  23379. #endregion
  23380. }
  23381. //删除多余行
  23382. while (tableOne.Rows.Count > DcList.Count + 1)
  23383. {
  23384. tableOne.Rows.RemoveAt(DcList.Count + 1);
  23385. }
  23386. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  23387. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  23388. doc.Save(fileDir);
  23389. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  23390. return Ok(JsonView(true, "操作成功!", Url));
  23391. }
  23392. private class TranslateInfo
  23393. {
  23394. public int Index { get; set; }
  23395. public string CompanyName { get; set; }
  23396. public string Job { get; set; }
  23397. }
  23398. [HttpPost]
  23399. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  23400. {
  23401. if (files.Count == 0)
  23402. {
  23403. return Ok(JsonView(false, "文件为空"));
  23404. }
  23405. KiMiApiClient KiMiApi = new KiMiApiClient();
  23406. var seedConter = await KiMiApi.UploadFilesAsync(files);
  23407. if (seedConter.Count == 0)
  23408. {
  23409. return Ok(JsonView(false, "上传结果为空!"));
  23410. }
  23411. var messages = new List<SeedMessages>
  23412. {
  23413. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  23414. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  23415. };
  23416. messages.InsertRange(1, seedConter);
  23417. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  23418. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  23419. string clients = kimiApiResult_JObject["content"].ToString();
  23420. string startStr = "```json", endStr = "```";
  23421. // 判断并清除开头部分
  23422. if (clients.StartsWith(startStr))
  23423. {
  23424. clients = clients.Remove(0, startStr.Length);
  23425. }
  23426. // 判断并清除结尾部分
  23427. if (clients.EndsWith(endStr))
  23428. {
  23429. clients = clients.Remove(clients.Length - endStr.Length);
  23430. }
  23431. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  23432. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  23433. {
  23434. {"姓", "LastName" },
  23435. {"名", "FirstName" },
  23436. {"姓名拼音", "Pinyin" },
  23437. {"性别", "Sex" },
  23438. {"单位", "CompanyFullName" },
  23439. {"职务", "Job" },
  23440. {"出生日期", "Birthday" },
  23441. };
  23442. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  23443. foreach (var item in clients_JObject)
  23444. {
  23445. BaiduClientOCRView cdc = new BaiduClientOCRView();
  23446. foreach (var field in clientFieldMap.Keys)
  23447. {
  23448. if (item.TryGetValue(field, out JToken value))
  23449. {
  23450. var getValue = value.ToString();
  23451. System.Type type = cdc.GetType();
  23452. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  23453. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  23454. propertyInfo.SetValue(cdc, propertyValue);
  23455. }
  23456. }
  23457. crmClients.Add(cdc);
  23458. }
  23459. return Ok(JsonView(new
  23460. {
  23461. fileCount = files.Count,
  23462. UploadCount = seedConter.Count,
  23463. ApiResult = clients,
  23464. CrmClients = crmClients
  23465. }));
  23466. }
  23467. #endregion
  23468. #region 团组倒推表
  23469. /// <summary>
  23470. /// 倒推表基础数据
  23471. /// Init
  23472. /// </summary>
  23473. /// <returns></returns>
  23474. [HttpPost]
  23475. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23476. public async Task<IActionResult> PostInvertedListInit()
  23477. {
  23478. var viewData = await _invertedListRep._Init();
  23479. if (viewData.Code != 0)
  23480. {
  23481. return Ok(JsonView(false, viewData.Msg));
  23482. }
  23483. return Ok(JsonView(viewData.Data));
  23484. }
  23485. /// <summary>
  23486. /// 倒推表
  23487. /// Info
  23488. /// </summary>
  23489. /// <param name="dto"></param>
  23490. /// <returns></returns>
  23491. [HttpPost]
  23492. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23493. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  23494. {
  23495. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  23496. if (viewData.Code != 0)
  23497. {
  23498. return Ok(JsonView(false, viewData.Msg));
  23499. }
  23500. return Ok(JsonView(viewData.Data));
  23501. }
  23502. /// <summary>
  23503. /// 倒推表
  23504. /// Create
  23505. /// </summary>
  23506. /// <param name="dto"></param>
  23507. /// <returns></returns>
  23508. [HttpPost]
  23509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23510. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  23511. {
  23512. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  23513. if (viewData.Code != 0)
  23514. {
  23515. return Ok(JsonView(false, viewData.Msg));
  23516. }
  23517. return Ok(JsonView(viewData.Data));
  23518. }
  23519. /// <summary>
  23520. /// 倒推表
  23521. /// Update
  23522. /// </summary>
  23523. /// <param name="dto"></param>
  23524. /// <returns></returns>
  23525. [HttpPost]
  23526. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23527. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  23528. {
  23529. var viewData = await _invertedListRep._Update(dto);
  23530. if (viewData.Code != 0)
  23531. {
  23532. return Ok(JsonView(false, viewData.Msg));
  23533. }
  23534. return Ok(JsonView(viewData.Data));
  23535. }
  23536. /// <summary>
  23537. /// 倒推表
  23538. /// File Download
  23539. /// </summary>
  23540. /// <param name="dto"></param>
  23541. /// <returns></returns>
  23542. [HttpPost]
  23543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23544. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  23545. {
  23546. var info2 = await _invertedListRep._Info(1, dto.DiId);
  23547. if (info2.Code != 0)
  23548. {
  23549. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  23550. }
  23551. var info1 = info2.Data as InvertedListInfoView;
  23552. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  23553. string teamName = "";
  23554. if (info != null) teamName = info.TeamName;
  23555. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  23556. var doc = new Document();
  23557. var builder = new DocumentBuilder(doc);
  23558. #region old insert
  23559. ////载入模板
  23560. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  23561. //Document doc = new Document(tempPath);
  23562. //DocumentBuilder builder = new DocumentBuilder(doc);
  23563. //利用键值对存放数据
  23564. //Dictionary<string, string> dic = new Dictionary<string, string>();
  23565. //dic.Add("TeamName", teamName);
  23566. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  23567. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  23568. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  23569. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  23570. //dic.Add("SQRemark", info1.ApprovalRemark);
  23571. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  23572. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  23573. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  23574. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  23575. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  23576. //dic.Add("QZRemark", info1.VisaInformationRemark);
  23577. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  23578. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  23579. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  23580. //dic.Add("CQRemark", info1.IssueVisaRemark);
  23581. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  23582. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  23583. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  23584. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  23585. //#region 填充word模板书签内容
  23586. //foreach (var key in dic.Keys)
  23587. //{
  23588. // builder.MoveToBookmark(key);
  23589. // builder.Write(dic[key]);
  23590. //}
  23591. //#endregion
  23592. #endregion
  23593. #region New Insert
  23594. string titleFont = $"仿宋",
  23595. contentFont = $"仿宋";
  23596. var fontColor = Color.FromArgb(64, 64, 64);
  23597. //设置标题 团组名称
  23598. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  23599. builder.Font.Name = titleFont;
  23600. builder.Font.Color = fontColor;
  23601. builder.Font.Size = 12;
  23602. builder.Font.Bold = true;
  23603. builder.Writeln(teamName);
  23604. //设置副标题 团组出访时间
  23605. builder.Font.Size = 12;
  23606. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  23607. builder.Writeln();
  23608. var backgroundColor = Color.FromArgb(199, 199, 199);
  23609. var table = builder.StartTable();
  23610. builder.InsertCell();
  23611. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  23612. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  23613. builder.CellFormat.Borders.LineWidth = 1;
  23614. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  23615. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  23616. builder.RowFormat.Height = 40;
  23617. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  23618. builder.Font.Name = contentFont;
  23619. builder.Font.Size = 12;
  23620. builder.Font.Bold = true;
  23621. builder.Font.Color = fontColor;
  23622. builder.Write("时间");
  23623. builder.InsertCell();
  23624. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  23625. builder.Write("流程");
  23626. builder.InsertCell();
  23627. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  23628. builder.Write("说明");
  23629. builder.EndRow();
  23630. //报批资料准备
  23631. if (info1.IsSelectedAirportd)
  23632. {
  23633. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  23634. }
  23635. //报批/提供送签资料
  23636. if (info1.IsSelectedApprovalData)
  23637. {
  23638. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  23639. }
  23640. //出批件护照办理
  23641. if (info1.IsSelectedIssueApproval)
  23642. {
  23643. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  23644. }
  23645. //签证资料准备
  23646. if (info1.IsSelectedVisaInfo)
  23647. {
  23648. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  23649. }
  23650. //送签
  23651. if (info1.IsSelectedSendVisa)
  23652. {
  23653. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  23654. }
  23655. //出签
  23656. if (info1.IsSelectedIssueVisa)
  23657. {
  23658. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  23659. }
  23660. //机票
  23661. if (info1.IsSelectedAirTicket)
  23662. {
  23663. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  23664. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  23665. }
  23666. //酒店
  23667. if (info1.IsSelectedHotel)
  23668. {
  23669. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  23670. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  23671. }
  23672. //开行前会
  23673. if (info1.IsSelectedPreTripMeeting)
  23674. {
  23675. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  23676. }
  23677. //送机
  23678. if (info1.IsSelectedAirportdDropOff)
  23679. {
  23680. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  23681. }
  23682. builder.EndTable();
  23683. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  23684. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  23685. for (int i = 0; i < table.Rows.Count; i++)
  23686. {
  23687. var row = table.Rows[i];
  23688. //设置宽度
  23689. row.Cells[0].CellFormat.Width = 20.00;
  23690. row.Cells[1].CellFormat.Width = 30.00;
  23691. row.Cells[2].CellFormat.Width = 50.00;
  23692. if (i != 0)
  23693. {
  23694. //边框设置
  23695. InvertedListFileDownloadSetBorders(row.Cells, 0);
  23696. InvertedListFileDownloadSetBorders(row.Cells, 1);
  23697. InvertedListFileDownloadSetBorders(row.Cells, 2);
  23698. }
  23699. }
  23700. #region 页脚插入图片
  23701. // 创建页脚
  23702. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  23703. doc.FirstSection.HeadersFooters.Add(footer);
  23704. Paragraph para = new Paragraph(doc);
  23705. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  23706. footer.AppendChild(para);
  23707. builder.MoveTo(para);
  23708. string imagePath = "./Images/FMGJ_Log.png";
  23709. builder.InsertImage(imagePath);
  23710. #endregion
  23711. #endregion
  23712. var fileDir = AppSettingsHelper.Get("WordBasePath");
  23713. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  23714. string filePath = fileDir + $@"InvertedList/{fileName}";
  23715. doc.Save(filePath);
  23716. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  23717. return Ok(JsonView(true, "操作成功!", Url));
  23718. }
  23719. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  23720. {
  23721. var fontColor = Color.FromArgb(64, 64, 64);
  23722. builder.InsertCell();
  23723. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  23724. builder.RowFormat.Height = 40;
  23725. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  23726. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  23727. builder.Font.Name = fontName;
  23728. builder.Font.Size = 8;
  23729. builder.Font.Bold = true;
  23730. builder.Font.Color = fontColor;
  23731. builder.Write(dateTime);
  23732. builder.InsertCell();
  23733. builder.Font.Size = 9;
  23734. builder.Font.Bold = true;
  23735. builder.Font.Color = fontColor;
  23736. builder.Write(content);
  23737. builder.InsertCell();
  23738. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  23739. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  23740. builder.Font.Size = 9;
  23741. builder.Font.Bold = false;
  23742. builder.Font.Color = fontColor;
  23743. builder.Write(reamrk);
  23744. builder.EndRow();
  23745. }
  23746. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  23747. {
  23748. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  23749. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  23750. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  23751. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  23752. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  23753. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  23754. }
  23755. #endregion
  23756. #region 会务倒推表
  23757. /// <summary>
  23758. /// 会务倒推表
  23759. /// Init
  23760. /// </summary>
  23761. /// <returns></returns>
  23762. [HttpPost]
  23763. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23764. public async Task<IActionResult> InforRetrogressTableInit()
  23765. {
  23766. var groupData = await _groupRepository.PostShareGroupInfos(1);
  23767. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  23768. return Ok(JsonView(false, groupData.Msg));
  23769. }
  23770. /// <summary>
  23771. /// 会务倒推表
  23772. /// ExcelDownload
  23773. /// </summary>
  23774. /// <param name="dto"></param>
  23775. /// <returns></returns>
  23776. [HttpPost]
  23777. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  23778. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23779. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  23780. {
  23781. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  23782. var validatorRes = await validator.ValidateAsync(dto);
  23783. if (!validatorRes.IsValid)
  23784. {
  23785. StringBuilder sb = new StringBuilder();
  23786. foreach (var item in validatorRes.Errors)
  23787. {
  23788. sb.AppendLine(item.ErrorMessage);
  23789. }
  23790. return Ok(JsonView(false, sb.ToString()));
  23791. }
  23792. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  23793. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  23794. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  23795. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  23796. #region Excel
  23797. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  23798. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  23799. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  23800. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  23801. var fileNamePrefix = string.Empty;
  23802. if (days >= 30)
  23803. {
  23804. tempPath += $"会务工作倒推进度表(30天).xlsx";
  23805. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  23806. }
  23807. else if (days < 30 && days > 7)
  23808. {
  23809. tempPath += $"会务工作倒推进度表(15天).xlsx";
  23810. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  23811. }
  23812. else if (days <= 7)
  23813. {
  23814. tempPath += $"会务工作倒推进度表(7天).xlsx";
  23815. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  23816. }
  23817. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  23818. fileName = CommonFun.ValidFileName(fileName);
  23819. //载入模板
  23820. WorkbookDesigner designer = new WorkbookDesigner();
  23821. designer.Workbook = new Workbook(tempPath);
  23822. designer.Process();
  23823. if (!Directory.Exists(savePath))
  23824. {
  23825. Directory.CreateDirectory(savePath);
  23826. }
  23827. string serverPath = $"{savePath}{fileName}";
  23828. designer.Workbook.Save(serverPath);
  23829. string rst = $"{servicePath}{ftpPath}{fileName}";
  23830. #endregion
  23831. return Ok(JsonView(new { url = rst }));
  23832. }
  23833. #endregion
  23834. #region 三公签证费用(签证费、代办费)
  23835. /// <summary>
  23836. /// 三公签证费用(签证费、代办费)
  23837. /// List
  23838. /// </summary>
  23839. /// <returns></returns>
  23840. [HttpPost]
  23841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23842. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  23843. {
  23844. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  23845. }
  23846. /// <summary>
  23847. /// 三公签证费用(签证费、代办费)
  23848. /// Add Or Update
  23849. /// </summary>
  23850. /// <returns></returns>
  23851. [HttpPost]
  23852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23853. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  23854. {
  23855. var _view = await _visaFeeInfoRep.Update(_dto);
  23856. if (_view.Code != 0)
  23857. {
  23858. return Ok(JsonView(false, _view.Msg));
  23859. }
  23860. return Ok(JsonView(true, _view.Msg));
  23861. }
  23862. #endregion
  23863. #region 酒店询价
  23864. /// <summary>
  23865. /// 酒店询价
  23866. /// Init
  23867. /// </summary>
  23868. /// <returns></returns>
  23869. [HttpPost]
  23870. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23871. public async Task<IActionResult> PostHotelInquiryInit()
  23872. {
  23873. var res = await _hotelInquiryRep._Init();
  23874. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23875. return Ok(JsonView(true, res.Msg, res.Data));
  23876. }
  23877. /// <summary>
  23878. /// 酒店询价
  23879. /// page Item
  23880. /// </summary>
  23881. /// <param name="_dto"></param>
  23882. /// <returns></returns>
  23883. [HttpPost]
  23884. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23885. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  23886. {
  23887. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  23888. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23889. var view = res.Data as PageDataViewBase;
  23890. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  23891. }
  23892. /// <summary>
  23893. /// 酒店询价
  23894. /// info
  23895. /// </summary>
  23896. /// <param name="_dto"></param>
  23897. /// <returns></returns>
  23898. [HttpPost]
  23899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23900. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  23901. {
  23902. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  23903. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23904. return Ok(JsonView(true, res.Msg, res.Data));
  23905. }
  23906. /// <summary>
  23907. /// 酒店询价
  23908. /// Add Or Edit
  23909. /// </summary>
  23910. /// <param name="_dto"></param>
  23911. /// <returns></returns>
  23912. [HttpPost]
  23913. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23914. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  23915. {
  23916. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  23917. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23918. return Ok(JsonView(true, res.Msg, res.Data));
  23919. }
  23920. /// <summary>
  23921. /// 酒店询价
  23922. /// Del
  23923. /// </summary>
  23924. /// <param name="_dto"></param>
  23925. /// <returns></returns>
  23926. [HttpPost]
  23927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23928. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  23929. {
  23930. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  23931. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23932. return Ok(JsonView(true, res.Msg, res.Data));
  23933. }
  23934. #endregion
  23935. #region 下载匹配op行程单
  23936. /// <summary>
  23937. /// 匹配op行程单
  23938. /// Init
  23939. /// </summary>
  23940. /// <param name="dto">团组列表请求dto</param>
  23941. /// <returns></returns>
  23942. [HttpPost]
  23943. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23944. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  23945. {
  23946. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  23947. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23948. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  23949. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  23950. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23951. .Where(it => it.IsDel == 0)
  23952. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  23953. .OrderByDescending(it => it.VisitStartDate)
  23954. .ToList();
  23955. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  23956. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  23957. var diids = groupInfos.Select(it => it.Id).ToList();
  23958. List<string> countrys = new List<string>();
  23959. foreach (var item in country)
  23960. {
  23961. var data = _groupRepository.FormartTeamName(item);
  23962. var dataArray = _groupRepository.GroupSplitCountry(data);
  23963. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  23964. }
  23965. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  23966. List<string> areaArray = new List<string>(); //GetGroupCityLine
  23967. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  23968. foreach (var item in areaItem)
  23969. {
  23970. string areaStr = item.Value;
  23971. if (!string.IsNullOrEmpty(areaStr))
  23972. {
  23973. string[] str1 = areaStr.Split("-");
  23974. if (str1.Length > 0)
  23975. {
  23976. areaArray.AddRange(str1);
  23977. }
  23978. }
  23979. }
  23980. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  23981. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  23982. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  23983. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  23984. .ToList();
  23985. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  23986. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  23987. .Where(it => countriesIds.Contains(it.Id))
  23988. .Select(it => new { it.Id, Name = it.Name_CN })
  23989. .ToList();
  23990. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  23991. .Select(it => it.TeamName).ToList();
  23992. stopwatch.Stop();
  23993. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  23994. }
  23995. ///// <summary>
  23996. ///// 匹配op行程单
  23997. ///// Init 查询区域数据
  23998. ///// </summary>
  23999. ///// <param name="dto">团组列表请求dto</param>
  24000. ///// <returns></returns>
  24001. //[HttpPost]
  24002. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24003. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  24004. //{
  24005. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  24006. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  24007. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  24008. // if (string.IsNullOrEmpty(countriesDataStr))
  24009. // {
  24010. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  24011. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  24012. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  24013. // }
  24014. // else
  24015. // {
  24016. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  24017. // }
  24018. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  24019. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  24020. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  24021. // List<dynamic> childList = new List<dynamic>();
  24022. // int parentId = dto.CountriesId;
  24023. // if (provinceData.Count > 1)
  24024. // {
  24025. // foreach (var item1 in provinceData)
  24026. // {
  24027. // List<dynamic> childList1 = new List<dynamic>();
  24028. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  24029. // foreach (var item2 in citiesData1)
  24030. // {
  24031. // List<dynamic> childList2 = new List<dynamic>();
  24032. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  24033. // foreach (var item3 in countiesData1)
  24034. // {
  24035. // childList2.Add(new
  24036. // {
  24037. // id = item3.Id,
  24038. // parentId = item2.Id,
  24039. // level = "district",
  24040. // name = item3.Name_CN,
  24041. // });
  24042. // }
  24043. // childList1.Add(new
  24044. // {
  24045. // id = item2.Id,
  24046. // parentId = item1.Id,
  24047. // level = "city",
  24048. // name = item2.Name_CN,
  24049. // childList = childList2
  24050. // });
  24051. // }
  24052. // childList.Add(new
  24053. // {
  24054. // id = item1.Id,
  24055. // parentId = parentId,
  24056. // level = "province",
  24057. // name = item1.Name_CN,
  24058. // childList = childList1
  24059. // });
  24060. // }
  24061. // //城市
  24062. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  24063. // foreach (var item2 in citiesData2)
  24064. // {
  24065. // List<dynamic> childList22 = new List<dynamic>();
  24066. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  24067. // foreach (var item3 in countiesData1)
  24068. // {
  24069. // childList22.Add(new
  24070. // {
  24071. // id = item3.Id,
  24072. // parentId = item2.Id,
  24073. // level = "district",
  24074. // name = item3.Name_CN,
  24075. // });
  24076. // }
  24077. // childList.Add(new
  24078. // {
  24079. // id = item2.Id,
  24080. // parentId = parentId,
  24081. // level = "city",
  24082. // name = item2.Name_CN,
  24083. // childList = childList22
  24084. // });
  24085. // }
  24086. // }
  24087. // else
  24088. // {
  24089. // foreach (var item2 in citiesData)
  24090. // {
  24091. // string cname = item2.Name_CN;
  24092. // List<dynamic> childList1 = new List<dynamic>();
  24093. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  24094. // foreach (var item3 in countiesData1)
  24095. // {
  24096. // childList1.Add(new
  24097. // {
  24098. // Id = item3.Id,
  24099. // parentId = item2.Id,
  24100. // level = "district",
  24101. // name = item3.Name_CN
  24102. // });
  24103. // }
  24104. // childList.Add(new
  24105. // {
  24106. // id = item2.Id,
  24107. // parentId = parentId,
  24108. // level = "city",
  24109. // name = item2.Name_CN,
  24110. // childList = childList1
  24111. // });
  24112. // }
  24113. // }
  24114. // stopwatch.Stop();
  24115. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  24116. //}
  24117. /// <summary>
  24118. /// 匹配op行程单
  24119. /// 接团信息列表 Page
  24120. /// </summary>
  24121. /// <param name="dto">团组列表请求dto</param>
  24122. /// <returns></returns>
  24123. [HttpPost]
  24124. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24125. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  24126. {
  24127. var swatch = new Stopwatch();
  24128. swatch.Start();
  24129. #region 参数验证
  24130. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  24131. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  24132. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  24133. #region 页面操作权限验证
  24134. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  24135. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  24136. #endregion
  24137. #endregion
  24138. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  24139. {
  24140. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  24141. //string sqlWhere = "";
  24142. if (!string.IsNullOrEmpty(dto.Country))
  24143. {
  24144. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  24145. }
  24146. if (!string.IsNullOrEmpty(dto.Area))
  24147. {
  24148. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  24149. }
  24150. if (!string.IsNullOrEmpty(dto.TeamName))
  24151. {
  24152. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  24153. }
  24154. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  24155. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  24156. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  24157. swatch.Stop();
  24158. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  24159. }
  24160. else
  24161. {
  24162. return Ok(JsonView(false, "查询失败"));
  24163. }
  24164. }
  24165. /// <summary>
  24166. /// 匹配op行程单
  24167. /// 行程单下载
  24168. /// </summary>
  24169. /// <param name="dto">团组列表请求dto</param>
  24170. /// <returns></returns>
  24171. [HttpPost]
  24172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24173. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  24174. {
  24175. #region 参数验证
  24176. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  24177. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  24178. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  24179. #region 页面操作权限验证
  24180. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  24181. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  24182. #endregion
  24183. #endregion
  24184. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  24185. {
  24186. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  24187. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  24188. }
  24189. else
  24190. {
  24191. return Ok(JsonView(false, "下载失败!"));
  24192. }
  24193. }
  24194. #endregion
  24195. #region 国家信息 数据 注释
  24196. //[HttpPost]
  24197. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  24198. //{
  24199. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  24200. // foreach (var item in dto)
  24201. // {
  24202. // infos.Add(new Grp_GroupsTaskAssignment()
  24203. // {
  24204. // DIId = item,
  24205. // CTId = 82,
  24206. // UId = 248,
  24207. // IsEnable = 1,
  24208. // CreateUserId = 233,
  24209. // CreateTime = DateTime.Now,
  24210. // IsDel = 0
  24211. // });
  24212. // infos.Add(new Grp_GroupsTaskAssignment()
  24213. // {
  24214. // DIId = item,
  24215. // CTId = 82,
  24216. // UId = 286,
  24217. // IsEnable = 1,
  24218. // CreateUserId = 233,
  24219. // CreateTime = DateTime.Now,
  24220. // IsDel = 0
  24221. // });
  24222. // }
  24223. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  24224. // return Ok("操作成功");
  24225. //}
  24226. //public class paramJsonDto
  24227. //{
  24228. // public List<CountriesInfo> str { get; set; }
  24229. //}
  24230. //[HttpPost]
  24231. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  24232. //{
  24233. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  24234. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  24235. // List<Sys_Cities> cities = new List<Sys_Cities>();
  24236. // List<Sys_Cities> districts = new List<Sys_Cities>();
  24237. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  24238. // _sqlSugar.BeginTran();
  24239. // int countitiesIndex = 0;
  24240. // foreach (var item in dto.str)
  24241. // {
  24242. // dynamic data = item.c;
  24243. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  24244. // if (data != null)
  24245. // {
  24246. // countitiesIndex++;
  24247. // foreach (var item1 in data)
  24248. // {
  24249. // string cnname = item1.cn;
  24250. // string enname = item1.en;
  24251. // Sys_Cities provinceInfo = new Sys_Cities()
  24252. // {
  24253. // CountriesId = countriesId,
  24254. // Name_CN = cnname,
  24255. // Name_EN = enname,
  24256. // ParentId = 0,
  24257. // IsCapital = 1,
  24258. // CreateUserId = 208,
  24259. // CreateTime = DateTime.Now,
  24260. // IsDel = 0
  24261. // };
  24262. // if (item1.lv == "province") //省份
  24263. // {
  24264. // provinceInfo.Level = 1;
  24265. // int provinceId = 0;
  24266. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  24267. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  24268. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  24269. // var data1 = item1.c;
  24270. // foreach (var item2 in data1)
  24271. // {
  24272. // if (item2.lv == "city")
  24273. // {
  24274. // string citycnname = item2.cn;
  24275. // string cityenname = item2.en;
  24276. // Sys_Cities cityInfo = new Sys_Cities()
  24277. // {
  24278. // CountriesId = countriesId,
  24279. // ParentId = provinceId,
  24280. // Level = 2,
  24281. // Name_CN = citycnname,
  24282. // Name_EN = cityenname,
  24283. // IsCapital = 1,
  24284. // CreateUserId = 208,
  24285. // CreateTime = DateTime.Now,
  24286. // IsDel = 0
  24287. // };
  24288. // if (item2.c != null)
  24289. // {
  24290. // int cityId = 0;
  24291. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  24292. // if (citiesInfo != null) cityId = citiesInfo.Id;
  24293. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  24294. // foreach (var item3 in item2.c)
  24295. // {
  24296. // if (item3.lv == "district")
  24297. // {
  24298. // var districtInfo = new Sys_Cities()
  24299. // {
  24300. // CountriesId = countriesId,
  24301. // Name_CN = item3.cn,
  24302. // Name_EN = item3.en,
  24303. // Level = 3,
  24304. // ParentId = cityId,
  24305. // IsCapital = 1,
  24306. // CreateUserId = 208,
  24307. // CreateTime = DateTime.Now,
  24308. // IsDel = 0
  24309. // };
  24310. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  24311. // //{
  24312. // districts.Add(districtInfo);
  24313. // //}
  24314. // }
  24315. // }
  24316. // }
  24317. // else
  24318. // {
  24319. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  24320. // //{
  24321. // cities.Add(cityInfo);
  24322. // //}
  24323. // }
  24324. // }
  24325. // }
  24326. // }
  24327. // else if (item1.lv == "city")//城市
  24328. // {
  24329. // provinceInfo.Level = 2;
  24330. // if (item1.c != null)
  24331. // {
  24332. // int cityId = 0;
  24333. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  24334. // if (citiesInfo != null) cityId = citiesInfo.Id;
  24335. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  24336. // foreach (var item3 in item1.c)
  24337. // {
  24338. // if (item3.lv == "district")
  24339. // {
  24340. // var districtInfo = new Sys_Cities()
  24341. // {
  24342. // CountriesId = countriesId,
  24343. // Name_CN = item3.cn,
  24344. // Name_EN = item3.en,
  24345. // Level = 3,
  24346. // ParentId = cityId,
  24347. // IsCapital = 1,
  24348. // CreateUserId = 208,
  24349. // CreateTime = DateTime.Now,
  24350. // IsDel = 0
  24351. // };
  24352. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  24353. // //{
  24354. // districts.Add(districtInfo);
  24355. // //}
  24356. // }
  24357. // }
  24358. // }
  24359. // else
  24360. // {
  24361. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  24362. // //{
  24363. // cities.Add(provinceInfo);
  24364. // //}
  24365. // }
  24366. // }
  24367. // }
  24368. // }
  24369. // }
  24370. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  24371. // cities = cities.Distinct().ToList();
  24372. // districts = districts.Distinct().ToList();
  24373. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  24374. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  24375. // cities.AddRange(districts);
  24376. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  24377. // //_sqlSugar.RollbackTran();
  24378. // _sqlSugar.CommitTran();
  24379. // return Ok(JsonView(false, "操作成功!"));
  24380. //}
  24381. //[HttpPost]
  24382. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  24383. //{
  24384. // List<CountitiesInfo> infos = dto.MyProperty;
  24385. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  24386. // _sqlSugar.BeginTran();
  24387. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  24388. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  24389. // foreach (var item in infos)
  24390. // {
  24391. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  24392. // if (countryInfo != null)
  24393. // {
  24394. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  24395. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  24396. // if (cityInfo1 != null)
  24397. // {
  24398. // cityInfo1.IsCapital = 0;
  24399. // cityInfos.Add(cityInfo1);
  24400. // }
  24401. // }
  24402. // }
  24403. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  24404. // .UpdateColumns(it => it.IsCapital)
  24405. // .WhereColumns(it => it.Id)
  24406. // .ExecuteCommand();
  24407. // //_sqlSugar.RollbackTran();
  24408. // _sqlSugar.CommitTran();
  24409. // return Ok(JsonView(false, "操作成功!"));
  24410. //}
  24411. //public class CounrtiesDto
  24412. //{
  24413. // public List<CountitiesInfo> MyProperty { get; set; }
  24414. //}
  24415. //public class CountitiesInfo
  24416. //{
  24417. // /// <summary>
  24418. // /// 圣约翰
  24419. // /// </summary>
  24420. // public string capital_name_chinese { get; set; }
  24421. // /// <summary>
  24422. // ///
  24423. // /// </summary>
  24424. // public string capital_name { get; set; }
  24425. // /// <summary>
  24426. // ///
  24427. // /// </summary>
  24428. // public string country_type { get; set; }
  24429. // /// <summary>
  24430. // /// 安提瓜和巴布达
  24431. // /// </summary>
  24432. // public string country_name_chinese { get; set; }
  24433. // /// <summary>
  24434. // /// 安提瓜和巴布达
  24435. // /// </summary>
  24436. // public string country_name_chinese_short { get; set; }
  24437. // /// <summary>
  24438. // /// 安提瓜和巴布达
  24439. // /// </summary>
  24440. // public string country_name_chinese_UN { get; set; }
  24441. // /// <summary>
  24442. // ///
  24443. // /// </summary>
  24444. // public string country_name_english_abbreviation { get; set; }
  24445. // /// <summary>
  24446. // ///
  24447. // /// </summary>
  24448. // public string country_name_english_formal { get; set; }
  24449. // /// <summary>
  24450. // ///
  24451. // /// </summary>
  24452. // public string country_name_english_UN { get; set; }
  24453. // /// <summary>
  24454. // ///
  24455. // /// </summary>
  24456. // public string continent_name { get; set; }
  24457. // /// <summary>
  24458. // ///
  24459. // /// </summary>
  24460. // public string subregion_name { get; set; }
  24461. // /// <summary>
  24462. // ///
  24463. // /// </summary>
  24464. // public string country_code2 { get; set; }
  24465. // /// <summary>
  24466. // ///
  24467. // /// </summary>
  24468. // public string country_code3 { get; set; }
  24469. // /// <summary>
  24470. // ///
  24471. // /// </summary>
  24472. // public string phone_code { get; set; }
  24473. //}
  24474. //public class CountriesInfo : BasicInfo
  24475. //{
  24476. // public List<CitiesInfo> c { get; set; }
  24477. //}
  24478. //public class CitiesInfo : BasicInfo
  24479. //{
  24480. // public List<AreaInfo> c { get; set; }
  24481. //}
  24482. //public class AreaInfo : BasicInfo
  24483. //{
  24484. // public List<AreaInfo> c { get; set; }
  24485. //}
  24486. //public class BasicInfo
  24487. //{
  24488. // public string code { get; set; }
  24489. // public string cn { get; set; }
  24490. // public string lv { get; set; }
  24491. // public string en { get; set; }
  24492. //}
  24493. #endregion
  24494. #region 查看邀请方
  24495. /// <summary>
  24496. /// 查看邀请方
  24497. /// 邀请方信息 Init
  24498. /// </summary>
  24499. /// <param name="dto"></param>
  24500. /// <returns></returns>
  24501. [HttpPost]
  24502. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24503. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  24504. {
  24505. string sqlWhere = string.Empty;
  24506. if (!string.IsNullOrEmpty(dto.Search))
  24507. {
  24508. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  24509. }
  24510. string sql = string.Format($@"Select
  24511. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  24512. Id,
  24513. UnitName
  24514. From Res_InvitationOfficialActivityData
  24515. Where IsDel = 0
  24516. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  24517. RefAsync<int> total = 0;
  24518. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24519. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  24520. }
  24521. /// <summary>
  24522. /// 查看邀请方
  24523. /// 国家信息 Init
  24524. /// </summary>
  24525. /// <param name="dto"></param>
  24526. /// <returns></returns>
  24527. [HttpPost]
  24528. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24529. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  24530. {
  24531. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  24532. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  24533. var diids = groupInfos.Select(it => it.Id).ToList();
  24534. List<string> countrys = new List<string>();
  24535. foreach (var item in country)
  24536. {
  24537. var data = _groupRepository.FormartTeamName(item);
  24538. var dataArray = _groupRepository.GroupSplitCountry(data);
  24539. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  24540. }
  24541. countrys = countrys.Distinct().ToList();
  24542. for (int i = 0; i < countrys.Count; i++)
  24543. {
  24544. string item = countrys[i];
  24545. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  24546. {
  24547. countrys.Remove(item);
  24548. i--;
  24549. }
  24550. }
  24551. RefAsync<int> total = 0;
  24552. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  24553. .Where(it => countrys.Contains(it.Name_CN))
  24554. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  24555. .Select(it => new { id = it.Id, name = it.Name_CN })
  24556. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24557. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  24558. }
  24559. /// <summary>
  24560. /// 查看邀请方
  24561. /// 城市信息 Init
  24562. /// </summary>
  24563. /// <param name="dto"></param>
  24564. /// <returns></returns>
  24565. [HttpPost]
  24566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24567. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  24568. {
  24569. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  24570. RefAsync<int> total = 0;
  24571. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  24572. .Where(it => it.CountriesId == dto.CountiesId)
  24573. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  24574. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  24575. .Select(it => new { id = it.Id, name = it.Name_CN })
  24576. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24577. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  24578. }
  24579. /// <summary>
  24580. /// 查看邀请方
  24581. /// 团组名称 Init
  24582. /// </summary>
  24583. /// <param name="dto"></param>
  24584. /// <returns></returns>
  24585. [HttpPost]
  24586. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24587. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  24588. {
  24589. var watch = new Stopwatch();
  24590. watch.Start();
  24591. RefAsync<int> total = 0;
  24592. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  24593. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  24594. .Where((oa, di) => oa.IsDel == 0)
  24595. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  24596. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  24597. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  24598. .Distinct()
  24599. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24600. watch.Stop();
  24601. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  24602. }
  24603. /// <summary>
  24604. /// 查看邀请方
  24605. /// 团组 & 邀请方信息
  24606. /// </summary>
  24607. /// <param name="dto"></param>
  24608. /// <returns></returns>
  24609. [HttpPost]
  24610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24611. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  24612. {
  24613. var watch = new Stopwatch();
  24614. watch.Start();
  24615. RefAsync<int> total = 0;
  24616. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  24617. .AS("Grp_DelegationInfo")
  24618. .Includes(x => x.InvitingInfos)
  24619. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  24620. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  24621. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  24622. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  24623. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  24624. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  24625. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24626. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  24627. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  24628. infos.ForEach(x =>
  24629. {
  24630. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  24631. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  24632. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  24633. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  24634. });
  24635. watch.Stop();
  24636. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  24637. }
  24638. #endregion
  24639. #region 报批行程
  24640. /// <summary>
  24641. /// 报批行程初始化
  24642. /// </summary>
  24643. /// <param name="dto"></param>
  24644. /// <returns></returns>
  24645. [HttpPost]
  24646. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  24647. {
  24648. const int chiNumber = 5;
  24649. var jw = JsonView(false);
  24650. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  24651. var group = groupList.First();
  24652. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  24653. group = groupList.First(x => x.Id == diid);
  24654. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  24655. .Where(x => x.DiId == diid && x.IsDel == 0)
  24656. .ToArray();
  24657. var count = 1;
  24658. foreach (var item in blackCodeList)
  24659. {
  24660. if (string.IsNullOrWhiteSpace(item.Title))
  24661. {
  24662. item.Title = "未设置名称数据" + count;
  24663. }
  24664. count++;
  24665. }
  24666. ;
  24667. if (group == null)
  24668. {
  24669. jw.Msg = "暂无团组!";
  24670. return Ok(jw);
  24671. }
  24672. var data = new
  24673. {
  24674. groupList = groupList.Select(x => new
  24675. {
  24676. x.TeamName,
  24677. x.Id
  24678. }),
  24679. content = new ArrayList(),
  24680. groupInfo = new
  24681. {
  24682. group.VisitDays,
  24683. group.TourCode,
  24684. group.VisitPNumber,
  24685. group.TeamName,
  24686. group.Id,
  24687. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  24688. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  24689. group.ClientUnit
  24690. },
  24691. blackCodeList = blackCodeList.Select(x => new
  24692. {
  24693. x.Title,
  24694. x.Id
  24695. }),
  24696. FileTempList = new ArrayList()
  24697. {
  24698. new { Index = 1,FileName = "旧模板" },
  24699. new { Index = 2,FileName = "省外办" },
  24700. new { Index = 3,FileName = "市外办" },
  24701. }
  24702. };
  24703. var resultArr = new ArrayList();
  24704. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  24705. #region 默认不生成行程
  24706. //if (content.Count == 0)
  24707. //{
  24708. // var stay = "-";
  24709. // var cityPath = "-";
  24710. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  24711. // .Where(x => x.DiId == diid && x.IsDel == 0)
  24712. // .ToList();
  24713. // //添加城市路径以及住宿地
  24714. // //黑屏代码数据
  24715. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  24716. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  24717. // {
  24718. // jw = JsonView(true, "黑屏代码有误!", data);
  24719. // return Ok(jw);
  24720. // }
  24721. // data = data with
  24722. // {
  24723. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  24724. // {
  24725. // x.Title,
  24726. // x.Id,
  24727. // }).ToArray())
  24728. // };
  24729. // foreach (DataRow row in dtBlack.Rows)
  24730. // {
  24731. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  24732. // {
  24733. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  24734. // return Ok(jw);
  24735. // }
  24736. // }
  24737. // //黑屏代码获取时间区间
  24738. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  24739. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  24740. // _sqlSugar.BeginTran();
  24741. // for (int i = 0; i < timeArr.Count; i++)
  24742. // {
  24743. // stay = "-";
  24744. // cityPath = "-";
  24745. // DateTime NewData = DateTime.Parse(timeArr[i]);
  24746. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  24747. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  24748. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  24749. // if (tbSelect.Length > 0)
  24750. // {
  24751. // List<string> threeCodeStr = new List<string>();
  24752. // foreach (var item in tbSelect)
  24753. // {
  24754. // var threeCode = item["Three"].ToString() ?? "";
  24755. // if (threeCode.Length == 6)
  24756. // {
  24757. // var start = threeCode.Substring(0, 3);
  24758. // var end = threeCode.Substring(3, 3);
  24759. // if (threeCodeStr.Count == 0)
  24760. // {
  24761. // threeCodeStr.Add(start);
  24762. // threeCodeStr.Add(end);
  24763. // }
  24764. // else
  24765. // {
  24766. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  24767. // {
  24768. // threeCodeStr.Add(end);
  24769. // }
  24770. // else
  24771. // {
  24772. // threeCodeStr.Add(start);
  24773. // threeCodeStr.Add(end);
  24774. // }
  24775. // }
  24776. // }
  24777. // }
  24778. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  24779. // var last = threeCodeStr.Last();
  24780. // foreach (var item in threeCodeStr)
  24781. // {
  24782. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  24783. // if (item.Equals(last))
  24784. // {
  24785. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  24786. // }
  24787. // }
  24788. // cityPath = cityPath.Trim('-');
  24789. // }
  24790. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  24791. // appro.Diid = diid ?? -1;
  24792. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  24793. // appro.Id = thisId;
  24794. // appro.CreateUserId = dto.UserId;
  24795. // appro.CreateTime = DateTime.Now;
  24796. // content.Add(appro);
  24797. // }
  24798. // _sqlSugar.CommitTran();
  24799. //}
  24800. #endregion
  24801. foreach (var x in content)
  24802. {
  24803. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  24804. if (chiList.Count < chiNumber)
  24805. {
  24806. for (int i = chiList.Count; i < chiNumber; i++)
  24807. {
  24808. chiList.Add(new Grp_ApprovalTravelDetails());
  24809. }
  24810. }
  24811. resultArr.Add(new
  24812. {
  24813. x.Id,
  24814. x.Date,
  24815. x.Diid,
  24816. chiList = chiList.Select(x1 => new
  24817. {
  24818. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  24819. x1.Details,
  24820. x1.ParentId,
  24821. x1.Id
  24822. })
  24823. });
  24824. }
  24825. data = data with
  24826. {
  24827. content = resultArr,
  24828. };
  24829. jw = JsonView(true, "获取成功!", data);
  24830. return Ok(jw);
  24831. }
  24832. /// <summary>
  24833. /// 报批行程删除
  24834. /// </summary>
  24835. /// <param name="dto"></param>
  24836. /// <returns></returns>
  24837. [HttpPost]
  24838. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  24839. {
  24840. var jw = JsonView(false);
  24841. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  24842. if (group == null)
  24843. {
  24844. jw.Msg = "团组参数有误!";
  24845. return Ok(jw);
  24846. }
  24847. try
  24848. {
  24849. _sqlSugar.BeginTran();
  24850. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  24851. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  24852. {
  24853. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  24854. DeleteUserId = dto.uesrId,
  24855. IsDel = 1
  24856. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  24857. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  24858. {
  24859. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  24860. DeleteUserId = dto.uesrId,
  24861. IsDel = 1
  24862. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  24863. _sqlSugar.CommitTran();
  24864. jw = JsonView(true, "删除成功");
  24865. }
  24866. catch (Exception ex)
  24867. {
  24868. jw = JsonView(false, ex.Message);
  24869. }
  24870. return Ok(jw);
  24871. }
  24872. /// <summary>
  24873. /// 报批行程保存
  24874. /// </summary>
  24875. /// <param name="dto"></param>
  24876. /// <returns></returns>
  24877. [HttpPost]
  24878. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  24879. {
  24880. var jw = JsonView(false);
  24881. var Find = dto.Arr.Find(x => x.id == 0);
  24882. if (Find != null)
  24883. {
  24884. jw.Msg = "生成的ID为0!";
  24885. return Ok(jw);
  24886. }
  24887. foreach (var item in dto.Arr)
  24888. {
  24889. foreach (var chi in item.chiList)
  24890. {
  24891. if (chi.parentId == 0)
  24892. {
  24893. chi.parentId = item.id;
  24894. }
  24895. }
  24896. }
  24897. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  24898. _sqlSugar.BeginTran();
  24899. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  24900. {
  24901. var parentIds = dto.Arr.Select(x => x.id).ToList();
  24902. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  24903. {
  24904. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  24905. DeleteUserId = dto.UserId,
  24906. IsDel = 1
  24907. }).ExecuteCommand();
  24908. }
  24909. try
  24910. {
  24911. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  24912. {
  24913. CreateTime = DateTime.Now,
  24914. CreateUserId = dto.UserId,
  24915. Details = x.details,
  24916. ParentId = x.parentId,
  24917. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  24918. Remark = "",
  24919. IsDel = 0
  24920. }).ToList()).ExecuteCommand();
  24921. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  24922. {
  24923. Id = x.id,
  24924. Details = x.details,
  24925. ParentId = x.parentId,
  24926. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  24927. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  24928. {
  24929. Details = x.Details,
  24930. ParentId = x.ParentId,
  24931. Time = x.Time
  24932. }).ExecuteCommand();
  24933. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  24934. {
  24935. Id = x.id,
  24936. Date = x.date,
  24937. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  24938. {
  24939. Date = x.Date
  24940. }).ExecuteCommand();
  24941. _sqlSugar.CommitTran();
  24942. jw = JsonView(true, "保存成功!");
  24943. }
  24944. catch (Exception ex)
  24945. {
  24946. _sqlSugar.RollbackTran();
  24947. jw = JsonView(false, "保存失败!" + ex.Message);
  24948. }
  24949. return Ok(jw);
  24950. }
  24951. /// <summary>
  24952. /// 报批行程生成
  24953. /// </summary>
  24954. /// <param name="dto"></param>
  24955. /// <returns></returns>
  24956. [HttpPost]
  24957. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  24958. {
  24959. var jw = JsonView(false);
  24960. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  24961. if (group == null)
  24962. {
  24963. jw.Msg = "暂无该团组!";
  24964. return Ok(jw);
  24965. }
  24966. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  24967. //黑屏代码数据
  24968. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  24969. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  24970. {
  24971. jw.Msg = "黑屏代码有误!";
  24972. return Ok(jw);
  24973. }
  24974. foreach (DataRow row in dtBlack.Rows)
  24975. {
  24976. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  24977. {
  24978. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  24979. return Ok(jw);
  24980. }
  24981. }
  24982. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  24983. var resultArr = new ArrayList();
  24984. //if (officialActivitiesArr.Count == 0)
  24985. //{
  24986. // jw.Msg = "暂无公务出访信息!";
  24987. // return Ok(jw);
  24988. //}
  24989. try
  24990. {
  24991. _sqlSugar.BeginTran();
  24992. DeleteApprovalJourney(new
  24993. Domain.Dtos.Groups.DeleteApprovalJourney
  24994. {
  24995. Diid = dto.Diid,
  24996. uesrId = dto.Userid
  24997. });
  24998. var stay = "-";
  24999. var cityPath = "-";
  25000. var arriveCountry = string.Empty;
  25001. //添加城市路径以及住宿地
  25002. //黑屏代码获取时间区间
  25003. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  25004. var empty = "【未收入该三字码!请机票同事录入】";
  25005. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  25006. #region 配置公务活动时间
  25007. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  25008. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  25009. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  25010. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  25011. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  25012. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  25013. {
  25014. 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" }),
  25015. 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"}),
  25016. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  25017. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  25018. };
  25019. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  25020. {
  25021. 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" }),
  25022. 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"}),
  25023. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  25024. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  25025. };
  25026. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  25027. {
  25028. 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" }),
  25029. 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"}),
  25030. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  25031. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  25032. };
  25033. #endregion
  25034. var nextDayNum = 0;
  25035. for (int i = 0; i < timeArr.Count; i++)
  25036. {
  25037. stay = "-";
  25038. cityPath = "-";
  25039. var chiarr = new List<Grp_ApprovalTravelDetails>();
  25040. DateTime NewData = DateTime.Parse(timeArr[i]);
  25041. //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();
  25042. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  25043. if (nextDayNum > 0)
  25044. {
  25045. nextDayNum--;
  25046. }
  25047. if (tbSelect.Length > 0)
  25048. {
  25049. List<string> threeCodeStr = new List<string>();
  25050. bool isTrade = false;
  25051. string trip = string.Empty;
  25052. foreach (var item in tbSelect)
  25053. {
  25054. if (nextDayNum == 0)
  25055. {
  25056. nextDayNum = Convert.ToInt32(item["Sign"]);
  25057. }
  25058. var airStartTime = item["StartTime"].ToString() ?? "0000";
  25059. var airEndTime = item["EndTime"].ToString() ?? "0000";
  25060. var takeOffTime = DateTime.Parse(timeArr[i]);
  25061. var fallToTime = DateTime.Parse(timeArr[i]);
  25062. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  25063. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  25064. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  25065. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  25066. if (nextDayNum > 0)
  25067. {
  25068. fallToTime = fallToTime.AddDays(nextDayNum);
  25069. }
  25070. trip = string.Empty;
  25071. var start = string.Empty;
  25072. var end = string.Empty;
  25073. var threeCode = item["Three"].ToString() ?? "";
  25074. if (threeCode.Length == 6)
  25075. {
  25076. start = threeCode.Substring(0, 3);
  25077. end = threeCode.Substring(3, 3);
  25078. if (threeCodeStr.Count == 0)
  25079. {
  25080. threeCodeStr.Add(start);
  25081. threeCodeStr.Add(end);
  25082. }
  25083. else
  25084. {
  25085. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  25086. {
  25087. threeCodeStr.Add(end);
  25088. }
  25089. else
  25090. {
  25091. threeCodeStr.Add(start);
  25092. threeCodeStr.Add(end);
  25093. }
  25094. }
  25095. }
  25096. //处理机票信息
  25097. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  25098. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  25099. if (start_Object == null)
  25100. {
  25101. start_Object = new Res_ThreeCode()
  25102. {
  25103. AirPort = empty,
  25104. AirPort_En = empty,
  25105. City = empty,
  25106. Country = empty,
  25107. Four = empty,
  25108. Three = empty,
  25109. };
  25110. }
  25111. if (end_Object == null)
  25112. {
  25113. end_Object = new Res_ThreeCode()
  25114. {
  25115. AirPort = empty,
  25116. AirPort_En = empty,
  25117. City = empty,
  25118. Country = empty,
  25119. Four = empty,
  25120. Three = empty,
  25121. };
  25122. }
  25123. //机型判断
  25124. string airModel = item["AirModel"].ToString();
  25125. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  25126. string flightTime = item["FlightTime"].ToString();
  25127. flightTime = ParseBlackTime(flightTime);
  25128. //航班号
  25129. string flightcode = item["Fliagtcode"].ToString();
  25130. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  25131. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  25132. if (aircompany == null)
  25133. {
  25134. aircompany = new Res_AirCompany
  25135. {
  25136. CnName = hsEmpty,
  25137. EnName = hsEmpty,
  25138. ShortCode = hsEmpty,
  25139. };
  25140. }
  25141. //航班前公务安排
  25142. if (tbSelect.First().Equals(item) && i != 0)
  25143. {
  25144. foreach (var takeoff in takeoffTimes)
  25145. {
  25146. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  25147. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  25148. {
  25149. foreach (var addTime in takeoff.Item2)
  25150. {
  25151. chiarr.Add(new Grp_ApprovalTravelDetails
  25152. {
  25153. Time = addTime,
  25154. CreateTime = DateTime.Now,
  25155. CreateUserId = dto.Userid,
  25156. ParentId = 0,
  25157. Details = "公务活动"
  25158. });
  25159. }
  25160. break;
  25161. }
  25162. }
  25163. }
  25164. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  25165. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  25166. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  25167. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  25168. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  25169. if (isTrade)
  25170. {
  25171. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  25172. trip += "(转机不出机场)。";
  25173. }
  25174. //else
  25175. //{
  25176. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  25177. //}
  25178. chiarr.Add(new Grp_ApprovalTravelDetails
  25179. {
  25180. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  25181. CreateTime = DateTime.Now,
  25182. CreateUserId = dto.Userid,
  25183. ParentId = 0,
  25184. Details = trip
  25185. });
  25186. //最后一条到达的时间安排公务
  25187. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  25188. {
  25189. bool isCheckCountry = false;
  25190. if (end_Object.Country != arriveCountry)
  25191. {
  25192. arriveCountry = end_Object.Country;
  25193. isCheckCountry = true;
  25194. }
  25195. if (nextDayNum == 0)
  25196. {
  25197. //需要入境的情况
  25198. if (isCheckCountry)
  25199. {
  25200. foreach (var fallTime in fallTimesCheckCountry)
  25201. {
  25202. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  25203. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  25204. {
  25205. foreach (var addTime in fallTime.Item2)
  25206. {
  25207. chiarr.Add(new Grp_ApprovalTravelDetails
  25208. {
  25209. Time = addTime,
  25210. CreateTime = DateTime.Now,
  25211. CreateUserId = dto.Userid,
  25212. ParentId = 0,
  25213. Details = "公务活动"
  25214. });
  25215. }
  25216. break;
  25217. }
  25218. }
  25219. }
  25220. else
  25221. {
  25222. foreach (var fallTime in fallTimesNotCheckCountry)
  25223. {
  25224. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  25225. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  25226. {
  25227. foreach (var addTime in fallTime.Item2)
  25228. {
  25229. chiarr.Add(new Grp_ApprovalTravelDetails
  25230. {
  25231. Time = addTime,
  25232. CreateTime = DateTime.Now,
  25233. CreateUserId = dto.Userid,
  25234. ParentId = 0,
  25235. Details = "公务活动"
  25236. });
  25237. }
  25238. break;
  25239. }
  25240. }
  25241. }
  25242. }
  25243. }
  25244. }
  25245. //添加乘车语句
  25246. //chiarr.Add(new Grp_ApprovalTravelDetails
  25247. //{
  25248. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  25249. // CreateTime = DateTime.Now,
  25250. // CreateUserId = dto.Userid,
  25251. // ParentId = 0,
  25252. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  25253. //});
  25254. //if (i != timeArr.Count - 1)
  25255. //{
  25256. // fallToTime = fallToTime.AddHours(2.5);
  25257. // foreach (var item in Times)
  25258. // {
  25259. // //排列公务时间
  25260. // if (fallToTime.Hour < item.Item1)
  25261. // {
  25262. // chiarr.Add(new Grp_ApprovalTravelDetails
  25263. // {
  25264. // Time = $"{item.Item2} - {item.Item3}",
  25265. // CreateTime = DateTime.Now,
  25266. // CreateUserId = dto.Userid,
  25267. // ParentId = 0,
  25268. // Details = "公务活动"
  25269. // });
  25270. // }
  25271. // }
  25272. //}
  25273. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  25274. var last = threeCodeStr.Last();
  25275. foreach (var item in threeCodeStr)
  25276. {
  25277. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  25278. if (item.Equals(last))
  25279. {
  25280. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  25281. }
  25282. }
  25283. cityPath = cityPath.Trim('-');
  25284. }
  25285. else
  25286. {
  25287. foreach (var item in Times)
  25288. {
  25289. chiarr.Add(new Grp_ApprovalTravelDetails
  25290. {
  25291. Time = $"{item.Item2} - {item.Item3}",
  25292. CreateTime = DateTime.Now,
  25293. CreateUserId = dto.Userid,
  25294. ParentId = 0,
  25295. Details = "公务活动"
  25296. });
  25297. }
  25298. }
  25299. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  25300. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  25301. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  25302. appro.Diid = dto.Diid;
  25303. appro.CreateUserId = dto.Userid;
  25304. appro.CreateTime = DateTime.Now;
  25305. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  25306. appro.Id = thisId;
  25307. //foreach (var item in gwinfo)
  25308. //{
  25309. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  25310. // chi.Details = "拜访" + item.Client;
  25311. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  25312. // {
  25313. // chi.Details += "," + item.ReqSample;
  25314. // }
  25315. // chi.ParentId = thisId;
  25316. // chi.Time = item.Time;
  25317. // chiarr.Add(chi);
  25318. //}
  25319. if (chiarr.Count < 6)
  25320. {
  25321. for (int j = chiarr.Count; j < 6; j++)
  25322. {
  25323. chiarr.Add(new
  25324. Grp_ApprovalTravelDetails());
  25325. }
  25326. }
  25327. resultArr.Add(new
  25328. {
  25329. appro.Id,
  25330. appro.Date,
  25331. appro.Diid,
  25332. chiList = chiarr.Select(x1 => new
  25333. {
  25334. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  25335. x1.Details,
  25336. x1.ParentId,
  25337. x1.Id
  25338. })
  25339. });
  25340. }
  25341. _sqlSugar.CommitTran();
  25342. jw = JsonView(true, "生成成功!", resultArr);
  25343. }
  25344. catch (Exception ex)
  25345. {
  25346. jw.Code = 400;
  25347. jw.Msg = "生成失败!" + ex.Message;
  25348. }
  25349. return Ok(jw);
  25350. }
  25351. /// <summary>
  25352. /// 报批行程word导出
  25353. /// </summary>
  25354. /// <param name="dto"></param>
  25355. /// <returns></returns>
  25356. [HttpPost]
  25357. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  25358. {
  25359. var jw = JsonView(false);
  25360. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  25361. if (group == null)
  25362. {
  25363. jw.Msg = "暂无该团组!";
  25364. return Ok(jw);
  25365. }
  25366. //模板路径
  25367. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  25368. var fileName = string.Empty;
  25369. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  25370. bool bold = false;
  25371. if (dto.FileIndex == 1)
  25372. {
  25373. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  25374. }
  25375. else if (dto.FileIndex == 2)
  25376. {
  25377. fileName = "省外办-报批.docx";
  25378. bold = false;
  25379. titleFont = "方正黑体简体";
  25380. timeFont = "Times New Roman";
  25381. contentFont = "方正仿宋_GBK";
  25382. }
  25383. else if (dto.FileIndex == 3)
  25384. {
  25385. fileName = "市外办-报批.docx";
  25386. titleFont = "方正黑体简体";
  25387. timeFont = "Times New Roman";
  25388. contentFont = "方正仿宋简体";
  25389. }
  25390. tempPath = tempPath + fileName;
  25391. //载入模板
  25392. Document doc = new Document(tempPath);
  25393. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  25394. //获取所填表格的序数
  25395. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  25396. Aspose.Words.Tables.Row titleRowClone = null;
  25397. Aspose.Words.Tables.Row CenterRowClone = null;
  25398. int index = 0;
  25399. int indexChi = 0;
  25400. int SetIndex = 0;
  25401. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  25402. //获取数据,放到datatable
  25403. foreach (var item in ApprovalTravelArr)
  25404. {
  25405. if (index > 0)
  25406. {
  25407. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  25408. tableOne.AppendChild(titleRowClone);
  25409. }
  25410. var textTime = item.Date;
  25411. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  25412. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  25413. SetIndex++;
  25414. if (ChiRep.Count > 0)
  25415. {
  25416. foreach (var itemChi in ChiRep)
  25417. {
  25418. var txtTime = itemChi.Time;
  25419. var txtDetail = itemChi.Details;
  25420. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  25421. {
  25422. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  25423. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  25424. //indexChi++;
  25425. //SetIndex++;
  25426. break;
  25427. }
  25428. if (indexChi > 0)
  25429. {
  25430. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  25431. tableOne.AppendChild(CenterRowClone);
  25432. }
  25433. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  25434. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  25435. indexChi++;
  25436. SetIndex++;
  25437. }
  25438. }
  25439. //else
  25440. //{
  25441. // if (indexChi > 0)
  25442. // {
  25443. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  25444. // tableOne.AppendChild(CenterRowClone);
  25445. // }
  25446. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  25447. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  25448. // indexChi++;
  25449. // SetIndex++;
  25450. //}
  25451. index++;
  25452. }
  25453. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  25454. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  25455. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  25456. jw.Code = 200;
  25457. jw.Msg = "";
  25458. return Ok(jw);
  25459. }
  25460. private string ParseBlackTime(string time)
  25461. {
  25462. // 匹配可能只有分钟的情况
  25463. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  25464. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  25465. if (match.Success)
  25466. {
  25467. string hours = match.Groups[1].Value;
  25468. string minutes = match.Groups[2].Value;
  25469. // 如果小时部分为空,则只显示分钟
  25470. if (string.IsNullOrEmpty(hours))
  25471. {
  25472. return $"{minutes}分钟";
  25473. }
  25474. // 如果分钟部分为空,则只显示小时
  25475. else if (string.IsNullOrEmpty(minutes))
  25476. {
  25477. return $"{hours}小时";
  25478. }
  25479. // 否则显示完整格式
  25480. else
  25481. {
  25482. return $"{hours}小时{minutes}分钟";
  25483. }
  25484. }
  25485. else
  25486. {
  25487. return "未知时长";
  25488. }
  25489. }
  25490. private string intToString(int numberVal)
  25491. {
  25492. string numberval = numberVal.ToString();
  25493. Dictionary<char, string> Number = new Dictionary<char, string>();
  25494. Number.Add('1', "一");
  25495. Number.Add('2', "二");
  25496. Number.Add('3', "三");
  25497. Number.Add('4', "四");
  25498. Number.Add('5', "五");
  25499. Number.Add('6', "六");
  25500. Number.Add('7', "七");
  25501. Number.Add('8', "八");
  25502. Number.Add('9', "九");
  25503. string stringNumberVal = string.Empty;
  25504. for (int i = 0; i < numberval.Length; i++)
  25505. {
  25506. if (i == 0)
  25507. {
  25508. stringNumberVal += Number[numberval[i]];
  25509. }
  25510. else if (i >= 1)
  25511. {
  25512. if (numberval[i] == '0')
  25513. {
  25514. stringNumberVal = "十";
  25515. }
  25516. else
  25517. {
  25518. stringNumberVal += "十" + Number[numberval[i]];
  25519. }
  25520. }
  25521. }
  25522. return stringNumberVal;
  25523. }
  25524. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  25525. {
  25526. //获取table中的某个单元格,从0开始
  25527. Cell lshCell = table.Rows[rows].Cells[cells];
  25528. //将单元格中段落移除
  25529. foreach (Paragraph item in lshCell.Paragraphs)
  25530. {
  25531. lshCell.Paragraphs.Remove(item);
  25532. }
  25533. if (val.Contains("\r\n"))
  25534. {
  25535. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  25536. foreach (var item in spArr)
  25537. {
  25538. //新建一个段落
  25539. Paragraph p = new Paragraph(doc);
  25540. var r = new Run(doc, item);
  25541. //设置字体
  25542. if (!string.IsNullOrEmpty(font))
  25543. {
  25544. r.Font.Name = font;
  25545. }
  25546. r.Font.Bold = bold;
  25547. //把设置的值赋给之前新建的段落
  25548. p.AppendChild(r);
  25549. //将此段落加到单元格内
  25550. lshCell.AppendChild(p);
  25551. }
  25552. }
  25553. else
  25554. {
  25555. //新建一个段落
  25556. Paragraph p = new Paragraph(doc);
  25557. var r = new Run(doc, val);
  25558. //设置字体
  25559. if (!string.IsNullOrEmpty(font))
  25560. {
  25561. r.Font.Name = font;
  25562. }
  25563. r.Font.Bold = bold;
  25564. //把设置的值赋给之前新建的段落
  25565. p.AppendChild(r);
  25566. //将此段落加到单元格内
  25567. lshCell.AppendChild(p);
  25568. }
  25569. }
  25570. /// <summary>
  25571. /// 报批行程AI续写
  25572. /// </summary>
  25573. /// <returns></returns>
  25574. [HttpPost]
  25575. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  25576. {
  25577. var jw = JsonView(false);
  25578. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  25579. {
  25580. jw.Msg = "参数有误!";
  25581. return Ok(jw);
  25582. }
  25583. KiMiApiClient kiMi = new KiMiApiClient();
  25584. List<SeedMessages> messages = new List<SeedMessages>() {
  25585. new SeedMessages
  25586. {
  25587. Role = KimiRole.system,
  25588. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  25589. },
  25590. new SeedMessages
  25591. {
  25592. Role = KimiRole.user,
  25593. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  25594. }
  25595. };
  25596. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  25597. string data = kimi_result.Choices[0]?.Message.Content;
  25598. if (string.IsNullOrWhiteSpace(data))
  25599. {
  25600. jw.Data = "Ai续写失败!";
  25601. }
  25602. else
  25603. {
  25604. jw = JsonView(true, "success!", data);
  25605. }
  25606. return Ok(jw);
  25607. }
  25608. #endregion
  25609. #region 团组接待意见调查
  25610. /// <summary>
  25611. /// 团组接待意见调查 - 信息管理
  25612. /// 基础数据(团组)
  25613. /// </summary>
  25614. /// <returns></returns>
  25615. [HttpGet]
  25616. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25617. public async Task<IActionResult> OpinionaireInit()
  25618. {
  25619. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  25620. .Select(x => new
  25621. {
  25622. x.Id,
  25623. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  25624. })
  25625. .OrderByDescending(x => x.Id)
  25626. .ToListAsync();
  25627. return Ok(JsonView(groupData, groupData.Count));
  25628. }
  25629. /// <summary>
  25630. /// 团组接待意见调查 - 信息管理
  25631. /// 列表
  25632. /// </summary>
  25633. /// <param name="groupId"></param>
  25634. /// <returns></returns>
  25635. [HttpGet("{groupId}")]
  25636. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25637. public async Task<IActionResult> OpinionaireManageList(int groupId)
  25638. {
  25639. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  25640. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  25641. .Select(x => new
  25642. {
  25643. x.Id,
  25644. x.TourGuideName,
  25645. x.CityName,
  25646. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  25647. x.CreateTime
  25648. })
  25649. .OrderBy(x => x.Id)
  25650. .ToListAsync();
  25651. return Ok(JsonView(data));
  25652. }
  25653. /// <summary>
  25654. /// 团组接待意见调查 - 信息管理
  25655. /// 保存
  25656. /// </summary>
  25657. /// <param name="dto"></param>
  25658. /// <returns></returns>
  25659. [HttpPost]
  25660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25661. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  25662. {
  25663. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  25664. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  25665. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  25666. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  25667. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  25668. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  25669. _opinionaireRep.BeginTran();
  25670. if (addData != null && addData.Count > 0)
  25671. {
  25672. foreach (var item in addData)
  25673. {
  25674. item.CreateUserId = currUserInfo.UserId;
  25675. item.DiId = dto.DiId;
  25676. }
  25677. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  25678. }
  25679. if (updData != null && updData.Count > 0)
  25680. {
  25681. var upd = await _opinionaireRep._sqlSugar
  25682. .Updateable(updData)
  25683. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  25684. .WhereColumns(x => new { x.Id })
  25685. .ExecuteCommandAsync();
  25686. }
  25687. _opinionaireRep.CommitTran();
  25688. return Ok(JsonView("操作成功!"));
  25689. }
  25690. /// <summary>
  25691. /// 团组接待意见调查 - 信息管理
  25692. /// 删除
  25693. /// </summary>
  25694. /// <param name="id"></param>
  25695. /// <returns></returns>
  25696. [HttpDelete("{id}")]
  25697. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25698. public async Task<IActionResult> OpinionaireManageDel(int id)
  25699. {
  25700. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  25701. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  25702. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  25703. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  25704. if (!del) return Ok(JsonView("操作失败!"));
  25705. return Ok(JsonView("操作成功!"));
  25706. }
  25707. /// <summary>
  25708. /// 团组接待意见调查 - 用户
  25709. /// 列表
  25710. /// </summary>
  25711. /// <param name="diId"></param>
  25712. /// <returns></returns>
  25713. [HttpGet("{diId}")]
  25714. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25715. public async Task<IActionResult> OpinionaireUserList(int diId)
  25716. {
  25717. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  25718. var sql = string.Format(@"
  25719. SELECT
  25720. o.Id,
  25721. o.DiId,
  25722. di.TeamName AS 'GroupName',
  25723. di.VisitPNumber AS 'PeopleNumber',
  25724. di.ClientName AS 'LeadGroup',
  25725. di.VisitCountry AS 'Travel',
  25726. di.VisitDays AS 'Days',
  25727. o.CityName,
  25728. o.TourGuideName,
  25729. o.Catering,
  25730. o.CateringReason,
  25731. o.Stay,
  25732. o.StayReason,
  25733. o.[Route],
  25734. o.RouteReason,
  25735. o.OfficialActivity,
  25736. o.OfficialActivityReason,
  25737. o.TourGuide,
  25738. o.TourGuideReason,
  25739. o.[Translate],
  25740. o.TranslateReason,
  25741. o.Trip,
  25742. o.TripReason,
  25743. o.ESFileName,
  25744. o.SignatureDate,
  25745. o.Remark
  25746. FROM
  25747. Grp_Opinionaire o
  25748. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  25749. WHERE
  25750. o.IsDel = 0
  25751. AND o.DiId = {0}
  25752. ORDER BY
  25753. o.Id ASC", diId);
  25754. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  25755. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  25756. return Ok(JsonView(data));
  25757. }
  25758. /// <summary>
  25759. /// 团组接待意见调查 - 用户
  25760. /// 保存
  25761. /// </summary>
  25762. /// <param name="dto"></param>
  25763. /// <returns></returns>
  25764. [HttpPost]
  25765. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25766. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  25767. {
  25768. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  25769. foreach (var item in dto)
  25770. {
  25771. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  25772. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  25773. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  25774. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  25775. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  25776. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  25777. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  25778. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  25779. }
  25780. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  25781. if (!Directory.Exists(filePathBase))
  25782. {
  25783. Directory.CreateDirectory(filePathBase);
  25784. }
  25785. #region 上传文件
  25786. var filePaths = new List<string>();
  25787. foreach (var item in dto)
  25788. {
  25789. var file = item.File;
  25790. // 将文件保存到指定位置
  25791. var filePath = Path.Combine(filePathBase, file.FileName);
  25792. using (var stream = new FileStream(filePath, FileMode.Create))
  25793. {
  25794. await file.CopyToAsync(stream);
  25795. }
  25796. //验证文件是否上传成功
  25797. if (!System.IO.File.Exists(filePath))
  25798. {
  25799. foreach (var filePathStr in filePaths)
  25800. {
  25801. System.IO.File.Delete(filePathStr);
  25802. }
  25803. return Ok(JsonView(false, "文件上传失败!"));
  25804. }
  25805. item.ESFileName = file.FileName;
  25806. }
  25807. #endregion
  25808. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  25809. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  25810. .UpdateColumns(x => new
  25811. {
  25812. x.Catering,
  25813. x.CateringReason,
  25814. x.Stay,
  25815. x.StayReason,
  25816. x.Route,
  25817. x.RouteReason,
  25818. x.OfficialActivity,
  25819. x.OfficialActivityReason,
  25820. x.TourGuide,
  25821. x.TourGuideReason,
  25822. x.Translate,
  25823. x.TranslateReason,
  25824. x.Trip,
  25825. x.TripReason,
  25826. x.ESFileName,
  25827. x.SignatureDate,
  25828. x.Remark
  25829. })
  25830. .WhereColumns(x => new { x.Id })
  25831. .ExecuteCommandAsync();
  25832. if (upd < 1)
  25833. {
  25834. foreach (var filePathStr in filePaths)
  25835. {
  25836. System.IO.File.Delete(filePathStr);
  25837. }
  25838. return Ok(JsonView(false));
  25839. }
  25840. return Ok(JsonView(true));
  25841. }
  25842. #endregion
  25843. #region 团组餐厅相关信息
  25844. /// <summary>
  25845. /// 团组相关餐厅信息
  25846. /// 基础数据(团组)
  25847. /// </summary>
  25848. /// <returns></returns>
  25849. [HttpGet]
  25850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25851. public async Task<IActionResult> RestaurantInit()
  25852. {
  25853. return Ok(await _restaurantRep.InitAsync());
  25854. }
  25855. /// <summary>
  25856. /// 团组相关餐厅信息
  25857. /// Item
  25858. /// </summary>
  25859. /// <param name="dto"></param>
  25860. /// <returns></returns>
  25861. [HttpPost]
  25862. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25863. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  25864. {
  25865. int portType = dto.PortType,
  25866. groupId = dto.GroupId;
  25867. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  25868. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  25869. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  25870. }
  25871. /// <summary>
  25872. /// 团组相关餐厅信息
  25873. /// List
  25874. /// </summary>
  25875. /// <param name="dto"></param>
  25876. /// <returns></returns>
  25877. [HttpPost]
  25878. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25879. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  25880. {
  25881. int portType = dto.PortType,
  25882. groupId = dto.GroupId;
  25883. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  25884. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  25885. var sql = string.Format(@" SELECT
  25886. ri.Id,
  25887. ri.GroupId,
  25888. ri.Date,
  25889. ri.StartTime,
  25890. ri.EndTime,
  25891. CASE WHEN ri.Type = 1 THEN '早餐'
  25892. WHEN ri.Type = 2 THEN '午餐'
  25893. WHEN ri.Type = 3 THEN '晚餐'
  25894. ELSE '其他'
  25895. END AS 'Type',
  25896. ri.Name,
  25897. ri.Address,
  25898. ri.Tel,
  25899. ri.Remark,
  25900. ri.CreateTime,
  25901. u.CnName AS CreateUserName
  25902. FROM
  25903. Grp_RestaurantInfo ri
  25904. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  25905. WHERE
  25906. ri.IsDel = 0
  25907. AND ri.GroupId = {0}
  25908. ORDER BY
  25909. ri.Date ASC
  25910. ", groupId);
  25911. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  25912. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  25913. return Ok(JsonView(infos));
  25914. }
  25915. /// <summary>
  25916. /// 团组相关餐厅信息
  25917. /// Info
  25918. /// </summary>
  25919. /// <param name="dto"></param>
  25920. /// <returns></returns>
  25921. [HttpPost]
  25922. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25923. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  25924. {
  25925. int portType = dto.PortType,
  25926. id = dto.Id;
  25927. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  25928. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  25929. return Ok(await _restaurantRep.InfoAsync(portType, id));
  25930. }
  25931. /// <summary>
  25932. /// 团组相关餐厅信息
  25933. /// Op
  25934. /// </summary>
  25935. /// <param name="dto"></param>
  25936. /// <returns></returns>
  25937. [HttpPost]
  25938. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25939. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  25940. {
  25941. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  25942. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  25943. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  25944. return Ok(await _restaurantRep.OpAsync(dto));
  25945. }
  25946. /// <summary>
  25947. /// 团组相关餐厅信息
  25948. /// Del
  25949. /// </summary>
  25950. /// <param name="dto"></param>
  25951. /// <returns></returns>
  25952. [HttpPost]
  25953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25954. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  25955. {
  25956. int userId = dto.DeleteUserId;
  25957. var id = dto.Id;
  25958. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  25959. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  25960. return Ok(await _restaurantRep.DelAsync(dto));
  25961. }
  25962. #endregion
  25963. #region 团组会务成本
  25964. /// <summary>
  25965. /// 团组会务成本数据初始化
  25966. /// </summary>
  25967. /// <returns></returns>
  25968. [HttpPost]
  25969. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  25970. {
  25971. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  25972. .OrderByDescending(x => x.CreateTime)
  25973. .Where(x => x.IsDel == 0)
  25974. .Select<DelegationEasyView>();
  25975. DelegationEasyView di = Dto.GroupId == 0 ?
  25976. expr.First() :
  25977. expr.First(x => x.Id == Dto.GroupId);
  25978. if (di == null)
  25979. {
  25980. return Ok(JsonView(false, "团组信息不存在!"));
  25981. }
  25982. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  25983. .Where(x => x.IsDel == 0 && x.STid == 21)
  25984. .Select(x => new { x.Id, Text = x.Name })
  25985. .ToListAsync();
  25986. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  25987. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  25988. .Select(x => x.Id)
  25989. .ToList();
  25990. //仅检索会务团组
  25991. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  25992. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  25993. .OrderByDescending(x => x.VisitDate)
  25994. .Select(x => new { x.Id, x.TeamName })
  25995. .ToListAsync();
  25996. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  25997. var userList = await _sqlSugar.Queryable<Sys_Users>()
  25998. .Where(x => x.IsDel == 0)
  25999. .Select(x => new { x.Id, x.CnName })
  26000. .ToListAsync();
  26001. var units = await _sqlSugar.Queryable<Sys_SetData>()
  26002. .Where(x => x.IsDel == 0 && x.STid == 119)
  26003. .Select(x => new { x.Id, Text = x.Name })
  26004. .ToListAsync();
  26005. var FileType = new[]
  26006. {
  26007. new { Id = 0 , Name = "成本下载" },
  26008. new { Id = 1 , Name = "报价下载" },
  26009. new { Id = 2 , Name = "总表下载" },
  26010. };
  26011. var GM = new List<int>();
  26012. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  26013. try
  26014. {
  26015. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  26016. }
  26017. catch (Exception ex)
  26018. {
  26019. GM = new List<int>() { 21 };
  26020. }
  26021. var isReview = Dto.UserId == 21;
  26022. var isGM = GM.Contains(Dto.UserId);
  26023. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  26024. .Where(x => x.IsDel == 0)
  26025. .Select<ConferenceAffairsCostView>()
  26026. .First(x => x.Diid == di.Id);
  26027. if (ConferenceAffairsCost == null)
  26028. {
  26029. ConferenceAffairsCost = new ConferenceAffairsCostView();
  26030. ConferenceAffairsCost.Diid = di.Id;
  26031. }
  26032. #region 权限校验
  26033. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  26034. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  26035. .Select(x => x.UserId)
  26036. .Distinct()
  26037. .ToList();
  26038. if (!ids.Contains(Dto.UserId) && !isGM)
  26039. {
  26040. return Ok(JsonView(201, "暂无权限!", new
  26041. {
  26042. typeData,
  26043. groupList,
  26044. currenyList,
  26045. isGM,
  26046. userList,
  26047. units,
  26048. isReview,
  26049. operatorUser = ids,
  26050. di,
  26051. FileType
  26052. }));
  26053. }
  26054. #endregion
  26055. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  26056. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  26057. .Select<ConferenceAffairsCostChildView>()
  26058. .OrderBy(x => x.Index)
  26059. .ToList();
  26060. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  26061. {
  26062. ConferenceAffairsCostChi[i - 1].Index = i;
  26063. }
  26064. var backData = new
  26065. {
  26066. ConferenceAffairsCost,
  26067. ConferenceAffairsCostChi,
  26068. typeData,
  26069. groupList,
  26070. currenyList,
  26071. isGM,
  26072. userList,
  26073. units,
  26074. isReview,
  26075. operatorUser = ids,
  26076. di,
  26077. FileType
  26078. };
  26079. return Ok(JsonView(true, "SUCCESS", backData));
  26080. }
  26081. /// <summary>
  26082. /// 会务成本保存
  26083. /// </summary>
  26084. /// <returns></returns>
  26085. [HttpPost]
  26086. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  26087. {
  26088. _sqlSugar.BeginTran();
  26089. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  26090. var childResult = new
  26091. {
  26092. success = 0,
  26093. error = 0
  26094. };
  26095. try
  26096. {
  26097. if (data.Id == 0)
  26098. {
  26099. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  26100. .Where(x => x.Diid == Dto.GroupId)
  26101. .SetColumns(x => new Grp_ConferenceAffairsCost
  26102. {
  26103. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26104. DeleteUserId = Dto.UserId
  26105. })
  26106. .ExecuteCommand();
  26107. data.Diid = Dto.GroupId;
  26108. data.CreateTime = DateTime.Now;
  26109. data.CreateUserId = Dto.UserId;
  26110. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  26111. .ExecuteReturnIdentity();
  26112. }
  26113. else
  26114. {
  26115. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  26116. .ExecuteCommand();
  26117. data.Id = data.Id;
  26118. }
  26119. if (Dto.ConferenceAffairsCostChild.Any())
  26120. {
  26121. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  26122. var insertArr = datas.Where(x => x.Id == 0).ToList();
  26123. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  26124. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  26125. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  26126. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  26127. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  26128. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  26129. .ExecuteCommand() : 0;
  26130. childResult = childResult with
  26131. {
  26132. error = notUpdateArr.Count(),
  26133. success = inrsetCount + updateCount
  26134. };
  26135. }
  26136. _sqlSugar.CommitTran();
  26137. }
  26138. catch (Exception ex)
  26139. {
  26140. _sqlSugar.RollbackTran();
  26141. return Ok(JsonView(false, "失败!" + ex.Message));
  26142. }
  26143. return Ok(JsonView(true, "操作成功!", childResult));
  26144. }
  26145. [HttpPost]
  26146. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  26147. {
  26148. var count = 0;
  26149. if (Dto.ConferenceAffairsCostChildids.Any())
  26150. {
  26151. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  26152. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  26153. SetColumns(x => new Grp_ConferenceAffairsCostChild
  26154. {
  26155. ReviewStatus = Dto.ReviewStatus
  26156. }).
  26157. ExecuteCommand();
  26158. }
  26159. return Ok(JsonView(true, "操作成功!", count));
  26160. }
  26161. /// <summary>
  26162. /// 会务成本所有数据清除
  26163. /// </summary>
  26164. /// <param name="Dto"></param>
  26165. /// <returns></returns>
  26166. [HttpPost]
  26167. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  26168. {
  26169. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  26170. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  26171. _sqlSugar.BeginTran();
  26172. try
  26173. {
  26174. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  26175. .Where(x => x.Diid == Dto.GroupId)
  26176. .SetColumns(x => new Grp_ConferenceAffairsCost
  26177. {
  26178. IsDel = 1,
  26179. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26180. DeleteUserId = Dto.UserId
  26181. })
  26182. .ExecuteCommand();
  26183. if (delCount > 0)
  26184. {
  26185. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  26186. .Where(x => x.Diid == Dto.GroupId)
  26187. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  26188. {
  26189. IsDel = 1,
  26190. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26191. DeleteUserId = Dto.UserId
  26192. })
  26193. .ExecuteCommand();
  26194. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  26195. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  26196. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  26197. {
  26198. IsDel = 1,
  26199. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26200. DeleteUserId = Dto.UserId
  26201. })
  26202. .ExecuteCommand();
  26203. }
  26204. _sqlSugar.CommitTran();
  26205. }
  26206. catch (Exception ex)
  26207. {
  26208. _sqlSugar.RollbackTran();
  26209. return Ok(JsonView(false, "操作失败!" + ex.Message));
  26210. }
  26211. return Ok(JsonView(true, "操作成功!"));
  26212. }
  26213. /// <summary>
  26214. /// 子项数据删除
  26215. /// </summary>
  26216. /// <param name="Dto"></param>
  26217. /// <returns></returns>
  26218. [HttpPost]
  26219. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  26220. {
  26221. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  26222. .Any(x => x.ReviewStatus == 1);
  26223. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  26224. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  26225. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  26226. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  26227. {
  26228. IsDel = 1,
  26229. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26230. DeleteUserId = Dto.UserId
  26231. })
  26232. .ExecuteCommand();
  26233. return Ok(JsonView(true, "SUCCESS!", count));
  26234. }
  26235. /// <summary>
  26236. /// 会务成本权限分配
  26237. /// </summary>
  26238. /// <param name="Dto"></param>
  26239. /// <returns></returns>
  26240. [HttpPost]
  26241. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  26242. {
  26243. _sqlSugar.BeginTran();
  26244. var count = 0;
  26245. try
  26246. {
  26247. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  26248. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  26249. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  26250. {
  26251. IsDel = 1,
  26252. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26253. DeleteUserId = Dto.CreateUserId
  26254. })
  26255. .ExecuteCommand();
  26256. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  26257. {
  26258. CreateTime = DateTime.Now,
  26259. CreateUserId = Dto.CreateUserId,
  26260. UserId = x,
  26261. Diid = Dto.GroupId,
  26262. }).ToList()).ExecuteCommand();
  26263. _sqlSugar.CommitTran();
  26264. }
  26265. catch (Exception ex)
  26266. {
  26267. _sqlSugar.RollbackTran();
  26268. return Ok(JsonView(false, "操作失败!" + ex.Message));
  26269. }
  26270. return Ok(JsonView(true, "操作成功!", count));
  26271. }
  26272. /// <summary>
  26273. /// 团组会务成本文件下载
  26274. /// </summary>
  26275. /// <returns></returns>
  26276. [HttpPost]
  26277. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  26278. {
  26279. var FileType = new[]
  26280. {
  26281. new { Id = 0 , Name = "成本下载" },
  26282. new { Id = 1 , Name = "报价下载" },
  26283. new { Id = 2 , Name = "总表下载" },
  26284. };
  26285. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  26286. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  26287. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  26288. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  26289. .Select<DelegationEasyView>()
  26290. .First();
  26291. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  26292. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  26293. if (main == null)
  26294. {
  26295. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  26296. }
  26297. JsonView jw = JsonView(false);
  26298. //总表下载
  26299. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  26300. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  26301. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  26302. var field = string.Empty;
  26303. var fileTypeName = string.Empty;
  26304. field = @$"
  26305. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  26306. b.Name as PriceTypeStr ,
  26307. c.Name as CurrencyStr ,
  26308. d.Name as UnitStr ,
  26309. case a.ReviewStatus
  26310. WHEN 1 THEN '已通过'
  26311. WHEN 0 THEN '未审核'
  26312. WHEN -1 THEN '未通过'
  26313. ELSE '未审核'
  26314. END AS ReviewStatusStr
  26315. ";
  26316. if (Dto.FileTypeId == 0)
  26317. {
  26318. fileTypeName = "会务成本成本表";
  26319. loadPath += $"{fileTypeName}.xlsx";
  26320. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26321. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26322. }
  26323. else if (Dto.FileTypeId == 1)
  26324. {
  26325. fileTypeName = "会务成本报价表";
  26326. loadPath += $"{fileTypeName}.xlsx";
  26327. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26328. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26329. }
  26330. else if (Dto.FileTypeId == 2)
  26331. {
  26332. fileTypeName = "会务成本总表";
  26333. loadPath += $"{fileTypeName}.xlsx";
  26334. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26335. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26336. }
  26337. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  26338. SELECT
  26339. {field}
  26340. FROM Grp_ConferenceAffairsCostChild a
  26341. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  26342. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  26343. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  26344. WHERE a.isdel = 0
  26345. AND a.Diid = {main.Diid}
  26346. AND a.ConferenceAffairsCostId = {main.Id}
  26347. ").ToList();
  26348. var currLists = chiExcelContent.Select(x => new CurrList
  26349. {
  26350. CurrName = x.CurrencyStr,
  26351. CurrRate = x.Rate
  26352. })
  26353. .Distinct()
  26354. .ToList();
  26355. var designer = new WorkbookDesigner
  26356. {
  26357. Workbook = new Workbook(loadPath)
  26358. };
  26359. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  26360. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  26361. designer.SetDataSource("TeamName", di.TeamName);
  26362. designer.SetDataSource("City", main.City);
  26363. designer.SetDataSource("AllCost", main.CostAll);
  26364. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  26365. designer.SetDataSource("Curr", MostCurr.Name);
  26366. designer.SetDataSource("Curr1", MostCurr.Name);
  26367. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  26368. dt.TableName = "TB";
  26369. designer.SetDataSource(dt);
  26370. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  26371. dt1.TableName = "currTb";
  26372. designer.SetDataSource(dt1);
  26373. designer.Process();
  26374. designer.Workbook.Save(outputPath);
  26375. jw = JsonView(true, "操作成功!", new
  26376. {
  26377. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  26378. FilePath = networkPath
  26379. });
  26380. return Ok(jw);
  26381. }
  26382. [HttpPost]
  26383. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  26384. {
  26385. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  26386. .Select(x => x.PriceName).ToList()));
  26387. }
  26388. #endregion
  26389. #region 会务流程
  26390. /// <summary>
  26391. /// 会务流程 - 团组列表
  26392. /// </summary>
  26393. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  26394. [HttpGet]
  26395. public async Task<IActionResult> ConferenceProceduresGroupNames()
  26396. {
  26397. var conferenceTypeIds = new List<int>() {
  26398. 302, // 成都-会务活动
  26399. 691 // 四川-会务活动
  26400. };
  26401. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26402. .Where(x => x.IsDel == 0)
  26403. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  26404. .OrderByDescending(x => x.VisitDate)
  26405. .Select(x => new
  26406. {
  26407. x.Id,
  26408. x.TeamName,
  26409. HasChildData = SqlFunc.Subqueryable<Grp_ConferenceProcedures>()
  26410. .Where(child => child.DiId == x.Id) // 替换关联条件
  26411. .Any() // 判断子表是否存在数据
  26412. })
  26413. .ToListAsync();
  26414. return Ok(JsonView(true, "SUCCESS", groupList));
  26415. }
  26416. /// <summary>
  26417. /// 会务流程 - 数据初始化
  26418. /// </summary>
  26419. /// <param name="dto"></param>
  26420. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  26421. [HttpPost]
  26422. public async Task<IActionResult> ConferenceProceduresInit(ConferenceProceduresInitDto dto)
  26423. {
  26424. try
  26425. {
  26426. var conferenceTypeIds = new List<int>() {
  26427. 302, // 成都-会务活动
  26428. 691 // 四川-会务活动
  26429. };
  26430. Grp_DelegationInfo targetGroup = null;
  26431. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26432. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  26433. .FirstAsync();
  26434. if (targetGroup == null)
  26435. {
  26436. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26437. .Where(x => x.IsDel == 0)
  26438. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  26439. .OrderByDescending(x => x.VisitDate)
  26440. .FirstAsync();
  26441. }
  26442. if (targetGroup == null)
  26443. {
  26444. return Ok(JsonView(false, "未找到任何团组信息"));
  26445. }
  26446. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26447. .Where(x => x.IsDel == 0)
  26448. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  26449. .OrderByDescending(x => x.VisitDate)
  26450. .Select(x => new
  26451. {
  26452. x.Id,
  26453. x.TeamName,
  26454. HasChildData = SqlFunc.Subqueryable<Grp_ConferenceProcedures>()
  26455. .Where(child => child.DiId == x.Id)
  26456. .Any() // 判断子表是否存在数据
  26457. })
  26458. .ToListAsync();
  26459. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  26460. .Where(x => x.DiId == targetGroup.Id && x.IsDel == 0)
  26461. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  26462. .ToListAsync();
  26463. if (!conferenceProceduresList.Any())
  26464. {
  26465. conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  26466. .Where(x => x.DiId == -1 && x.IsDel == 0)
  26467. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  26468. .ToListAsync();
  26469. }
  26470. var conferenceProceduresGroupByTitle = conferenceProceduresList
  26471. .GroupBy(x => x.Title)
  26472. .Select(x => new
  26473. {
  26474. title = x.Key,
  26475. itmes = x.Select(y => new
  26476. {
  26477. y.Id,
  26478. y.DataDetails,
  26479. y.Details,
  26480. y.Remark
  26481. }).ToList()
  26482. })
  26483. .ToList();
  26484. var response = new
  26485. {
  26486. GroupInfo = new
  26487. {
  26488. targetGroup.Id,
  26489. targetGroup.TeamName,
  26490. targetGroup.VisitDate,
  26491. targetGroup.VisitDays,
  26492. targetGroup.VisitPNumber,
  26493. targetGroup.VisitCountry,
  26494. targetGroup.VisitStartDate,
  26495. targetGroup.VisitEndDate,
  26496. targetGroup.ClientName,
  26497. targetGroup.ClientUnit
  26498. },
  26499. GroupList = groupList,
  26500. ConferenceProceduresList = conferenceProceduresList,
  26501. conferenceProceduresGroupByTitle = conferenceProceduresGroupByTitle
  26502. };
  26503. return Ok(JsonView(true, "SUCCESS", response));
  26504. }
  26505. catch (Exception ex)
  26506. {
  26507. _logger.LogError(ex, "数据初始化失败");
  26508. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  26509. }
  26510. }
  26511. /// <summary>
  26512. /// 会务流程 - 保存
  26513. /// </summary>
  26514. /// <param name="dto"></param>
  26515. /// <returns></returns>
  26516. [HttpPost]
  26517. public async Task<IActionResult> ConferenceProceduresSave(ConferenceProceduresSaveDto dto)
  26518. {
  26519. _sqlSugar.BeginTran();
  26520. try
  26521. {
  26522. //删除旧数据
  26523. _sqlSugar.Updateable<Grp_ConferenceProcedures>()
  26524. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  26525. .SetColumns(x => new Grp_ConferenceProcedures
  26526. {
  26527. IsDel = 1,
  26528. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26529. DeleteUserId = dto.UserId
  26530. })
  26531. .ExecuteCommand();
  26532. //添加新数据
  26533. var newData = new List<Grp_ConferenceProcedures>();
  26534. foreach (var item in dto.ConferenceProceduresSaveItem)
  26535. {
  26536. foreach (var item2 in item.itmes)
  26537. {
  26538. newData.Add(new Grp_ConferenceProcedures
  26539. {
  26540. DiId = dto.GroupId,
  26541. Title = item.title,
  26542. DataDetails = item2.DataDetails,
  26543. Details = item2.details,
  26544. Remark = item2.Remark,
  26545. CreateTime = DateTime.Now,
  26546. CreateUserId = dto.UserId
  26547. });
  26548. }
  26549. }
  26550. _sqlSugar.Insertable(newData).ExecuteCommand();
  26551. _sqlSugar.CommitTran();
  26552. }
  26553. catch (Exception ex)
  26554. {
  26555. _sqlSugar.RollbackTran();
  26556. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  26557. }
  26558. return Ok(JsonView(true, "SUCCESS"));
  26559. }
  26560. [HttpPost]
  26561. public async Task<IActionResult> ConferenceProceduresFileDown(ConferenceProceduresFileDownDto dto)
  26562. {
  26563. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26564. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  26565. .FirstAsync();
  26566. if (groupInfo == null)
  26567. {
  26568. return Ok(JsonView(false, "团组信息不存在"));
  26569. }
  26570. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  26571. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  26572. .ToListAsync();
  26573. if (!conferenceProceduresList.Any())
  26574. {
  26575. return Ok(JsonView(false, "会务流程信息不存在"));
  26576. }
  26577. var filePath = $"{AppSettingsHelper.Get("ExcelBasePath")}Template/会务流程.xlsx";
  26578. if (!System.IO.File.Exists(filePath))
  26579. {
  26580. return Ok(JsonView(false, "模板文件不存在"));
  26581. }
  26582. var designer = new WorkbookDesigner();
  26583. designer.Workbook = new Workbook(filePath);
  26584. designer.SetDataSource("TB", conferenceProceduresList);
  26585. designer.Process();
  26586. var sheet = designer.Workbook.Worksheets[0];
  26587. var cells = sheet.Cells;
  26588. int col = 0; // 第一列
  26589. int startRow = 2; // 若第0行为表头,则从第1行开始;无表头请改为0
  26590. int endRow = cells.MaxDataRow;
  26591. if (endRow >= startRow)
  26592. {
  26593. int mergeStart = startRow;
  26594. string prev = cells[mergeStart, col].StringValue?.Trim() ?? string.Empty;
  26595. for (int r = startRow + 1; r <= endRow; r++)
  26596. {
  26597. string cur = cells[r, col].StringValue?.Trim() ?? string.Empty;
  26598. if (!string.Equals(cur, prev, StringComparison.Ordinal))
  26599. {
  26600. int count = r - mergeStart;
  26601. if (count > 1)
  26602. cells.Merge(mergeStart, col, count, 1);
  26603. mergeStart = r;
  26604. prev = cur;
  26605. }
  26606. }
  26607. int tailCount = endRow - mergeStart + 1;
  26608. if (tailCount > 1)
  26609. cells.Merge(mergeStart, col, tailCount, 1);
  26610. }
  26611. // byte[] bytes = null;
  26612. // using (MemoryStream stream = new MemoryStream())
  26613. // {
  26614. // designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  26615. // bytes = stream.ToArray();
  26616. // }
  26617. // return File(bytes, "application/excel", $"{groupInfo.TeamName}_会务流程.xlsx");
  26618. string savePath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceProcedures";
  26619. if (!System.IO.Directory.Exists(savePath))
  26620. {
  26621. System.IO.Directory.CreateDirectory(savePath);
  26622. }
  26623. designer.Workbook.Save($"{savePath}/{groupInfo.TeamName}_会务流程.xlsx");
  26624. string rst = savePath.replace(AppSettingsHelper.Get("ExcelBasePath"),
  26625. AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  26626. return Ok(JsonView(true, "SUCCESS", $"{rst}/{groupInfo.TeamName}_会务流程.xlsx"));
  26627. }
  26628. #endregion
  26629. #region 团组签证流程
  26630. /// <summary>
  26631. /// 团组签证流程 - 团组列表(分页)
  26632. /// </summary>
  26633. /// <returns></returns>
  26634. [HttpPost]
  26635. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  26636. {
  26637. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  26638. string groupName = dto.GroupName.Trim();
  26639. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  26640. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  26641. int portType = dto.PortType;
  26642. RefAsync<int> total = 0;
  26643. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  26644. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  26645. .InnerJoin<Grp_VisaProcessSteps>((x, y, z) => x.DIId == z.GroupId)
  26646. .Where((x, y, z) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId && z.IsDel == 0);
  26647. //构建单字模糊查询
  26648. if (!string.IsNullOrEmpty(groupName))
  26649. {
  26650. var characters = groupName.ToCharArray();
  26651. foreach (var character in characters)
  26652. {
  26653. var charString = character.ToString();
  26654. query = query.Where((x, y) =>
  26655. SqlFunc.Contains(y.TeamName, charString));
  26656. }
  26657. }
  26658. var groups = await query
  26659. .OrderByDescending((x, y) => y.VisitDate)
  26660. .Select((x, y) => new
  26661. {
  26662. y.Id,
  26663. GroupName = y.TeamName,
  26664. y.VisitDate,
  26665. // 加入子查询统计子表条数
  26666. CompletedCount = SqlFunc.Subqueryable<Grp_VisaProcessSteps>()
  26667. .Where(sub => sub.GroupId == y.Id && sub.IsCompleted && sub.IsDel == 0)
  26668. .Count()
  26669. })
  26670. .Distinct()
  26671. .ToPageListAsync(pageIndex, pageSize, total);
  26672. var msg = "SUCCESS";
  26673. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  26674. var groups1 = groups.Select(x => new
  26675. {
  26676. x.Id,
  26677. x.GroupName,
  26678. x.CompletedCount
  26679. }).ToList();
  26680. return Ok(JsonView(true, msg, groups1, total));
  26681. }
  26682. /// <summary>
  26683. /// 团组签证流程 - 详情
  26684. /// </summary>
  26685. /// <returns></returns>
  26686. [HttpPost]
  26687. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  26688. {
  26689. var res = await _visaProcessRep.Info(dto);
  26690. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  26691. return Ok(JsonView(true, res.Msg, res.Data));
  26692. }
  26693. /// <summary>
  26694. /// 团组签证流程 - 流程创建测试
  26695. /// </summary>
  26696. /// <returns></returns>
  26697. [HttpPost]
  26698. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  26699. {
  26700. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  26701. }
  26702. /// <summary>
  26703. /// 团组签证流程 - 流程Top4Init 测试
  26704. /// </summary>
  26705. /// <returns></returns>
  26706. [HttpPost]
  26707. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  26708. {
  26709. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  26710. }
  26711. /// <summary>
  26712. /// 团组签证流程 - 设置状态 完成/未完成
  26713. /// </summary>
  26714. /// <returns></returns>
  26715. [HttpPost]
  26716. public async Task<IActionResult> VisaProcessSetCompleted(VisaProcessSetCompletedDto dto)
  26717. {
  26718. //参数验证
  26719. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).AnyAsync();
  26720. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  26721. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  26722. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26723. var res = await _visaProcessRep.SetCompleted(dto.StepId, dto.CurrUserId, dto.IsCompleted);
  26724. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  26725. return Ok(JsonView(true, res.Msg));
  26726. }
  26727. /// <summary>
  26728. /// 团组签证流程 - 修改各步骤内容
  26729. /// </summary>
  26730. /// <returns></returns>
  26731. [HttpPost]
  26732. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  26733. {
  26734. //参数验证
  26735. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  26736. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  26737. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  26738. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26739. if (dto.StepContents == null && dto.StepContents.Count < 1)
  26740. {
  26741. return Ok(JsonView(false, "步骤内容无效。"));
  26742. }
  26743. //各步骤值处理
  26744. object stepVal;
  26745. if (stepValid.Step == 7) stepVal = dto.StepContents;
  26746. else stepVal = dto.StepContents[0].ToString();
  26747. var stepInfo = new Grp_VisaProcessSteps
  26748. {
  26749. Id = dto.StepId,
  26750. DataType = stepValid.DataType,
  26751. TypedValue = stepVal,
  26752. LastUpdateUserId = dto.CurrUserId
  26753. };
  26754. var res = await _visaProcessRep.Update(stepInfo);
  26755. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  26756. return Ok(JsonView(true, res.Msg));
  26757. }
  26758. /// <summary>
  26759. /// 团组签证流程 - 上传文件
  26760. /// </summary>
  26761. /// <returns></returns>
  26762. [HttpPost]
  26763. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  26764. {
  26765. //参数验证
  26766. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  26767. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  26768. var before = stepValid;
  26769. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  26770. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26771. //验证文件是否存在
  26772. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  26773. //验证该步骤是否可以上传文件
  26774. var uploadSteps = new List<int>() {
  26775. 5, //实际出签时间
  26776. 6, //是否需要开出境证明
  26777. 7, //是否需要办理电子入境卡手续
  26778. };
  26779. if (!uploadSteps.Contains(stepValid.Step))
  26780. {
  26781. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  26782. }
  26783. //验证根目录
  26784. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  26785. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  26786. if (!System.IO.Directory.Exists(rootPath))
  26787. {
  26788. System.IO.Directory.CreateDirectory(rootPath);
  26789. }
  26790. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  26791. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26792. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  26793. .Select(x => $"{x.TeamName}({x.Id})")
  26794. .FirstAsync();
  26795. //创建团组文件夹
  26796. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  26797. if (!System.IO.Directory.Exists(groupPath))
  26798. {
  26799. System.IO.Directory.CreateDirectory(groupPath);
  26800. }
  26801. List<string> filePaths = new List<string>();
  26802. //保存文件
  26803. foreach (var file in dto.Files)
  26804. {
  26805. // 生成存储文件名
  26806. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  26807. var filePath = Path.Combine(groupPath, fileName);
  26808. // 保存文件到磁盘
  26809. using (var stream = new FileStream(filePath, FileMode.Create))
  26810. {
  26811. await file.CopyToAsync(stream);
  26812. }
  26813. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  26814. }
  26815. //数据库存储
  26816. stepValid.TypedFileNameValue = filePaths;
  26817. stepValid.LastUpdateUserId = dto.CurrUserId;
  26818. stepValid.LastUpdateTime = DateTime.Now;
  26819. var res = await _sqlSugar.Updateable(stepValid)
  26820. .UpdateColumns(it => new { it.TypedFileNameValue, it.LastUpdateUserId, it.LastUpdateTime })
  26821. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  26822. .ExecuteCommandAsync();
  26823. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  26824. //记录上传文件
  26825. await _visaProcessRep.LogOperationAsync(before, stepValid, "Upload", dto.CurrUserId);
  26826. return Ok(JsonView(true));
  26827. }
  26828. /// <summary>
  26829. /// 团组签证流程 - step 7 资料下载
  26830. /// </summary>
  26831. /// <returns></returns>
  26832. [HttpGet]
  26833. public async Task<IActionResult> VisaProcessDownload(int groupId, int currUserId)
  26834. {
  26835. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  26836. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26837. //验证根目录
  26838. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  26839. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  26840. if (!System.IO.Directory.Exists(rootPath))
  26841. {
  26842. System.IO.Directory.CreateDirectory(rootPath);
  26843. }
  26844. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  26845. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26846. .Where(x => x.IsDel == 0 && x.Id == groupId)
  26847. .Select(x => $"{x.TeamName}({x.Id})")
  26848. .FirstAsync();
  26849. //创建团组文件夹
  26850. var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
  26851. var randomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  26852. var dirName = $"{groupName}_相关资料_{timestamp}";
  26853. var sourceDirectoryPath = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}";
  26854. var path = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}/{dirName}";
  26855. if (!System.IO.Directory.Exists(path))
  26856. {
  26857. System.IO.Directory.CreateDirectory(path);
  26858. }
  26859. //验证接团客户名单
  26860. string sql = string.Format(@"
  26861. SELECT
  26862. tcl.Id,
  26863. tcl.DiId,
  26864. tcl.IsAccompany,
  26865. temp.*,
  26866. u.CnName AS Operator,
  26867. tcl.CreateTime AS OperatingTime,
  26868. ssd.name AS ShippingSpaceType
  26869. FROM
  26870. Grp_TourClientList tcl
  26871. LEFT JOIN (
  26872. SELECT
  26873. dc.Id AS DcId,
  26874. dc.LastName,
  26875. dc.FirstName,
  26876. ccom.CompanyFullName,
  26877. dc.Job,
  26878. cc.CertNo AS IDCardNo,
  26879. dc.Sex,
  26880. dc.BirthDay
  26881. FROM
  26882. Crm_DeleClient dc
  26883. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  26884. AND ccom.IsDel = 0
  26885. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  26886. AND cc.SdId = 773
  26887. AND cc.IsDel = 0
  26888. WHERE
  26889. dc.IsDel = 0
  26890. ) temp ON temp.DcId = tcl.ClientId
  26891. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  26892. LEFT JOIN sys_setdata ssd ON ssd.isdel = 0 AND ssd.id = tcl.ShippingSpaceTypeid
  26893. WHERE
  26894. tcl.IsDel = 0
  26895. AND tcl.DiId = {0}", groupId);
  26896. var groupClientList = await _sqlSugar.SqlQueryable<TourClientInfosView>(sql).ToListAsync();
  26897. //解密
  26898. foreach (var item in groupClientList)
  26899. {
  26900. EncryptionProcessor.DecryptProperties(item);
  26901. }
  26902. if (groupClientList == null || groupClientList.Count < 1)
  26903. {
  26904. return Ok(JsonView(false, $"团组客户名单未录入客户信息,不可生成相关资料。"));
  26905. }
  26906. #region 生成文件
  26907. //酒店信息
  26908. var hotelInfos = await _sqlSugar.Queryable<Grp_HotelReservations>()
  26909. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  26910. .OrderBy(x => x.CheckInDate)
  26911. .ToListAsync();
  26912. //航班信息
  26913. var airInfos = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  26914. .Where(x => x.IsDel == 0 && x.DIId == groupId)
  26915. .OrderBy(x => x.FlightsDate)
  26916. .ToListAsync();
  26917. foreach (var clientInfo in groupClientList)
  26918. {
  26919. var clientId = clientInfo.DcId;
  26920. var guestName = $"{clientInfo.LastName}{clientInfo.FirstName}";
  26921. #region 个人信息资料
  26922. #endregion
  26923. #region 机票航班信息
  26924. var clientAirInfos = airInfos.Where(x => x.ClientName.Contains(clientId.ToString())).ToList();
  26925. if (clientAirInfos != null && clientAirInfos.Count > 0)
  26926. {
  26927. //创建表格
  26928. Document airDoc = new Document();
  26929. DocumentBuilder airBuilder = new DocumentBuilder(airDoc);
  26930. GeneralMethod.SetupDocumentStyles(airBuilder);
  26931. GeneralMethod.AddTitle(airBuilder, $"{guestName} - 机票信息");
  26932. GeneralMethod.AddAirInfoSections(airBuilder, clientAirInfos, "机票航班信息");
  26933. var airRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  26934. var airFileName = $"{guestName}_机票信息_{airRandomStr}.docx";
  26935. airDoc.Save($"{path}/{airFileName}");
  26936. }
  26937. #endregion
  26938. #region 酒店信息
  26939. var clientHotelInfos = hotelInfos.Where(x => x.GuestName.Contains(clientId.ToString())).ToList();
  26940. if (clientHotelInfos != null && clientHotelInfos.Count > 0)
  26941. {
  26942. //创建表格
  26943. Document hotelDoc = new Document();
  26944. DocumentBuilder HotelBuilder = new DocumentBuilder(hotelDoc);
  26945. GeneralMethod.SetupDocumentStyles(HotelBuilder);
  26946. GeneralMethod.AddTitle(HotelBuilder, $"{guestName} - 酒店信息");
  26947. GeneralMethod.AddHotelInfoSections(HotelBuilder, clientHotelInfos, "酒店信息");
  26948. var hotelRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  26949. var hotelFileName = $"{guestName}_酒店信息_{hotelRandomStr}.docx";
  26950. hotelDoc.Save($"{path}/{hotelFileName}");
  26951. }
  26952. #endregion
  26953. }
  26954. #endregion
  26955. //打包文件夹
  26956. var sourceDirectory = $"{sourceDirectoryPath}/{dirName}";
  26957. var zipFilePath = $"{sourceDirectoryPath}/{dirName}.zip";
  26958. if (System.IO.File.Exists(zipFilePath))
  26959. {
  26960. System.IO.File.Delete(zipFilePath);
  26961. }
  26962. ZipFile.CreateFromDirectory(sourceDirectory, zipFilePath, CompressionLevel.Fastest, false);
  26963. // 等待并验证
  26964. await Task.Delay(100); // 给系统时间完成文件操作
  26965. if (System.IO.File.Exists(zipFilePath))
  26966. {
  26967. var fileInfo = new FileInfo(zipFilePath);
  26968. var url = $"{rootRrl}Office/GrpFile/VisaProcessFiles/{groupName}/{dirName}.zip";
  26969. //记录下载日志
  26970. await _visaProcessRep.LogOperationAsync(null, null, "Download", currUserId);
  26971. return Ok(JsonView(StatusCodes.Status200OK, "操作成功!", url));
  26972. }
  26973. return Ok(JsonView(false));
  26974. }
  26975. /// <summary>
  26976. /// 团组签证流程 - 根据步骤记录ID获取该步骤的所有操作日志
  26977. /// </summary>
  26978. /// <returns></returns>
  26979. [HttpGet]
  26980. public async Task<IActionResult> VisaProcessLogByStepId(int stepId)
  26981. {
  26982. //参数验证
  26983. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == stepId && x.IsDel == 0).FirstAsync();
  26984. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  26985. var logs = await _visaProcessRep.GetStepLogsAsync(stepId);
  26986. return Ok(JsonView(logs));
  26987. }
  26988. /// <summary>
  26989. /// 团组签证流程 - 根据团组ID获取该团组下所有步骤的操作日志
  26990. /// </summary>
  26991. /// <returns></returns>
  26992. [HttpGet]
  26993. public async Task<IActionResult> VisaProcessLogByGroupId(int groupId)
  26994. {
  26995. //参数验证
  26996. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.GroupId == groupId && x.IsDel == 0).FirstAsync();
  26997. if (stepValid == null) return Ok(JsonView(false, "团组ID无效。"));
  26998. var logs = await _visaProcessRep.GetGroupStepLogsAsync(groupId);
  26999. return Ok(JsonView(logs));
  27000. }
  27001. #endregion
  27002. #region 团组总览进程
  27003. /// <summary>
  27004. /// 团组总览进程 - 流程创建测试
  27005. /// </summary>
  27006. /// <returns></returns>
  27007. [HttpGet]
  27008. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27009. public async Task<IActionResult> GroupProcessInitTest(int groupId, int currUserId)
  27010. {
  27011. return Ok(await _processOverviewRep.ProcessInitAsync(groupId, currUserId));
  27012. }
  27013. /// <summary>
  27014. /// 团组总览进程 - 团组名称集合
  27015. /// </summary>
  27016. /// <returns></returns>
  27017. [HttpGet]
  27018. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27019. public async Task<IActionResult> GroupProcessGroupNames()
  27020. {
  27021. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  27022. .Where(x => x.IsDel == 0)
  27023. .OrderByDescending(x => x.VisitDate)
  27024. .Select(x => new
  27025. {
  27026. x.Id,
  27027. GroupName = x.TeamName,
  27028. HasProcess = SqlFunc.Subqueryable<Grp_ProcessOverview>()
  27029. .Where(po => po.GroupId == x.Id && po.IsDel == 0)
  27030. .Any()
  27031. })
  27032. .ToListAsync();
  27033. return Ok(JsonView(groupNames));
  27034. }
  27035. /// <summary>
  27036. /// 团组总览进程 - 流程详情
  27037. /// </summary>
  27038. /// <returns></returns>
  27039. [HttpGet]
  27040. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27041. public async Task<IActionResult> GroupProcessDetails(int groupId)
  27042. {
  27043. var res = await _processOverviewRep.ProcessesDetailsAsync(groupId);
  27044. if (res.Code == StatusCodes.Status200OK)
  27045. {
  27046. return Ok(JsonView(res.Data));
  27047. }
  27048. return Ok(JsonView(false, res.Msg));
  27049. }
  27050. /// <summary>
  27051. /// 团组总览进程 - 更新节点状态
  27052. /// </summary>
  27053. /// <returns></returns>
  27054. [HttpPost]
  27055. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27056. public async Task<IActionResult> GroupProcessUpdateNodeStatus(GroupProcessUpdateNodeStatusDto dto)
  27057. {
  27058. var res = await _processOverviewRep.UpdateNodeStatusAsync(dto.NodeId, dto.CurrUserId);
  27059. if (res.Code == StatusCodes.Status200OK)
  27060. {
  27061. return Ok(JsonView(res.Data));
  27062. }
  27063. return Ok(JsonView(false, res.Msg));
  27064. }
  27065. /// <summary>
  27066. /// 团组总览进程 - 更新签证节点信息
  27067. /// </summary>
  27068. /// <returns></returns>
  27069. [HttpPost]
  27070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27071. public async Task<IActionResult> GroupProcessUpdateVisaNodeDetails(GroupProcessUpdateVisaNodeDetailsDto dto)
  27072. {
  27073. //验证签证信息
  27074. if (dto.VisaSubNodes.Count < 1) return Ok(JsonView(false, "请传入有效的签证节点信息。"));
  27075. var res = await _processOverviewRep.UpdateVisaNodeDetailsAsync(dto);
  27076. if (res.Code == StatusCodes.Status200OK)
  27077. {
  27078. return Ok(JsonView(res.Data));
  27079. }
  27080. return Ok(JsonView(false, res.Msg));
  27081. }
  27082. /// <summary>
  27083. /// 团组总览进程 - 设置实际完成时间
  27084. /// </summary>
  27085. /// <returns></returns>
  27086. [HttpPost]
  27087. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27088. public async Task<IActionResult> GroupProcessSetActualDone(GroupProcessSetActualDoneDto dto)
  27089. {
  27090. //验证签证信息
  27091. var res = await _processOverviewRep.SetActualDoneAsync(dto.NodeId, dto.ActualDone, dto.CurrUserId);
  27092. if (res.Code == StatusCodes.Status200OK)
  27093. {
  27094. return Ok(JsonView(res.Data));
  27095. }
  27096. return Ok(JsonView(false, res.Msg));
  27097. }
  27098. #endregion
  27099. /// <summary>
  27100. /// 123132123
  27101. /// </summary>
  27102. /// <param name="_dto"></param>
  27103. /// <returns></returns>
  27104. [HttpPost]
  27105. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27106. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  27107. {
  27108. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  27109. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  27110. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  27111. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  27112. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  27113. dicDetail.Add(789, 1034);
  27114. dicDetail.Add(790, 1035);
  27115. dicDetail.Add(791, 1036);
  27116. dicDetail.Add(792, 1037);
  27117. dicDetail.Add(793, 1038);
  27118. dicDetail.Add(794, 1039);
  27119. dicDetail.Add(795, 1040);
  27120. dicDetail.Add(796, 1041);
  27121. dicDetail.Add(797, 1042);
  27122. dicDetail.Add(798, 1043);
  27123. dicDetail.Add(801, 1044);
  27124. dicDetail.Add(802, 1045);
  27125. dicDetail.Add(803, 1046);
  27126. Dictionary<int, int> dic = new Dictionary<int, int>();
  27127. dic.Add(806, 1027);
  27128. dic.Add(807, 1028);
  27129. dic.Add(808, 1029);
  27130. dic.Add(809, 1030);
  27131. dic.Add(810, 1031);
  27132. dic.Add(811, 1032);
  27133. dic.Add(812, 1033);
  27134. foreach (var item in list_visa)
  27135. {
  27136. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  27137. temp.Coefficient = item.coefficient;
  27138. DateTime dtCrt;
  27139. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  27140. if (b1)
  27141. {
  27142. temp.CreateTime = dtCrt;
  27143. }
  27144. else
  27145. {
  27146. temp.CreateTime = DateTime.Now;
  27147. }
  27148. temp.CreateUserId = item.Operators;
  27149. temp.DeleteTime = "";
  27150. temp.DeleteUserId = 0;
  27151. temp.DiId = int.Parse(item.DIID);
  27152. temp.FilePath = item.FilePath;
  27153. temp.IsDel = item.IsDel;
  27154. temp.Price = item.Price;
  27155. temp.PriceCount = 1;
  27156. temp.PriceCurrency = item.Currency;
  27157. int detailId = 0;
  27158. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  27159. {
  27160. detailId = dicDetail[item.PriceTypeDetail];
  27161. }
  27162. temp.PriceDetailType = detailId;
  27163. temp.PriceDt = DateTime.Now;
  27164. temp.PriceName = item.PriceName;
  27165. temp.PriceSum = item.Price;
  27166. int tid = 0;
  27167. if (dic.ContainsKey(item.PriceType))
  27168. {
  27169. tid = dic[item.PriceType];
  27170. }
  27171. temp.PriceType = tid;
  27172. temp.Remark = item.Remark;
  27173. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  27174. }
  27175. return Ok(JsonView(true, "操作成功!"));
  27176. }
  27177. [HttpPost]
  27178. public IActionResult TimeTest()
  27179. {
  27180. var jw = JsonView(false, "error");
  27181. _sqlSugar.BeginTran();
  27182. try
  27183. {
  27184. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  27185. .Select(x => new Crm_NewClientData
  27186. {
  27187. Id = x.Id,
  27188. Client = x.Client,
  27189. Contact = x.Contact,
  27190. Location = x.Location,
  27191. })
  27192. .ToList();
  27193. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  27194. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  27195. Stopwatch stopwatch = new Stopwatch();
  27196. // 开始计时
  27197. stopwatch.Start();
  27198. foreach (var item in clientList)
  27199. {
  27200. EncryptionProcessor.DecryptProperties(item);
  27201. }
  27202. stopwatch.Stop();
  27203. jw.Code = 200;
  27204. jw.Data = stopwatch.ElapsedMilliseconds;
  27205. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  27206. }
  27207. catch (Exception ex)
  27208. {
  27209. jw.Code = 400;
  27210. jw.Msg = ex.Message;
  27211. }
  27212. return Ok(jw);
  27213. }
  27214. [HttpPost]
  27215. public async Task<IActionResult> TimeTest1()
  27216. {
  27217. var infos = await _sqlSugar.Queryable<Crm_DeleClient>().ToListAsync();
  27218. return Ok(infos);
  27219. }
  27220. }
  27221. }