GroupsController.cs 1.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506
  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.QiYeWeChatAPI.AppNotice;
  28. using OASystem.Domain.AesEncryption;
  29. using OASystem.Domain.Attributes;
  30. using OASystem.Domain.Dtos.CRM;
  31. using OASystem.Domain.Dtos.FileDto;
  32. using OASystem.Domain.Dtos.Financial;
  33. using OASystem.Domain.Dtos.Groups;
  34. using OASystem.Domain.Dtos.PersonnelModule;
  35. using OASystem.Domain.Dtos.System;
  36. using OASystem.Domain.Entities.Customer;
  37. using OASystem.Domain.Entities.Financial;
  38. using OASystem.Domain.Entities.Groups;
  39. using OASystem.Domain.ViewModels.CRM;
  40. using OASystem.Domain.ViewModels.Financial;
  41. using OASystem.Domain.ViewModels.Groups;
  42. using OASystem.Domain.ViewModels.JuHeExchangeRate;
  43. using OASystem.Domain.ViewModels.OCR;
  44. using OASystem.Domain.ViewModels.SmallFun;
  45. using OASystem.Infrastructure.Logging;
  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. /// <param name="groupSearchService"></param>
  202. public GroupsController(
  203. ILogger<GroupsController> logger,
  204. ITextFileLogger eec_textLogger,
  205. IGroupTextFileLogger groupTextLogger,
  206. IMapper mapper,
  207. IHubContext<ChatHub, IChatClient> hubContext,
  208. SqlSugarClient sqlSugar,
  209. GrpScheduleRepository grpScheduleRep,
  210. DelegationInfoRepository groupRepository,
  211. TaskAssignmentRepository taskAssignmentRep,
  212. AirTicketResRepository airTicketResRep,
  213. DecreasePaymentsRepository decreasePaymentsRep,
  214. InvitationOfficialActivitiesRepository InvitationOfficialActivitiesRep,
  215. DelegationEnDataRepository delegationEnDataRep,
  216. EnterExitCostRepository enterExitCostRep,
  217. DelegationVisaRepository delegationVisaRep,
  218. MessageRepository message,
  219. VisaPriceRepository visaPriceRep,
  220. CarTouristGuideGroundRepository carTouristGuideGroundRep,
  221. CheckBoxsRepository checkBoxs,
  222. GroupCostRepository GroupCostRepository,
  223. CostTypeHotelNumberRepository CostTypeHotelNumberRepository,
  224. GroupCostParameterRepository GroupCostParameterRepository,
  225. HotelPriceRepository hotelPriceRep,
  226. CustomersRepository customersRep,
  227. SetDataRepository setDataRep,
  228. TourClientListRepository tourClientListRep,
  229. TeamRateRepository teamRateRep,
  230. UsersRepository usersRep,
  231. IJuHeApiService juHeApi,
  232. InvertedListRepository invertedListRep,
  233. VisaFeeInfoRepository visaFeeInfoRep,
  234. TicketBlackCodeRepository ticketBlackCodeRep,
  235. HotelInquiryRepository hotelInquiryRep,
  236. ThreeCodeRepository threeCodeRepository,
  237. FeeAuditRepository feeAuditRep,
  238. VisaCommissionRepository visaCommissionRep,
  239. ForeignReceivablesRepository ffrRep,
  240. OpinionaireRepository opinionaireRep,
  241. TableOperationRecordRepository tableorRep,
  242. EnterExitCostDraftRepository enterExitCostDraftRep,
  243. RestaurantRepository restaurantRep,
  244. EnterExitCostQuoteRepository enterExitCostQuoteRep,
  245. GroupOrderPreInfoRepository grpOrderPreInfoRep,
  246. VisaProcessRepository visaProcessRep,
  247. ProcessOverviewRepository processOverviewRep,
  248. DynamicSearchService<Grp_DelegationInfo> groupSearchService
  249. )
  250. {
  251. _logger = logger;
  252. _eec_textLogger = eec_textLogger;
  253. _groupTextLogger = groupTextLogger;
  254. _mapper = mapper;
  255. _grpScheduleRep = grpScheduleRep;
  256. _groupRepository = groupRepository;
  257. _taskAssignmentRep = taskAssignmentRep;
  258. _airTicketResRep = airTicketResRep;
  259. _sqlSugar = sqlSugar;
  260. url = AppSettingsHelper.Get("ExcelBaseUrl");
  261. path = AppSettingsHelper.Get("ExcelBasePath");
  262. if (!System.IO.Directory.Exists(path))
  263. {
  264. System.IO.Directory.CreateDirectory(path);//不存在就创建文件夹
  265. }
  266. _decreasePaymentsRep = decreasePaymentsRep;
  267. _InvitationOfficialActivitiesRep = InvitationOfficialActivitiesRep;
  268. _delegationEnDataRep = delegationEnDataRep;
  269. _enterExitCostRep = enterExitCostRep;
  270. _delegationVisaRep = delegationVisaRep;
  271. _message = message;
  272. _visaPriceRep = visaPriceRep;
  273. _carTouristGuideGroundRep = carTouristGuideGroundRep;
  274. _checkBoxs = checkBoxs;
  275. _GroupCostRepository = GroupCostRepository;
  276. _CostTypeHotelNumberRepository = CostTypeHotelNumberRepository;
  277. _GroupCostParameterRepository = GroupCostParameterRepository;
  278. _hotelPriceRep = hotelPriceRep;
  279. _customersRep = customersRep;
  280. _setDataRep = setDataRep;
  281. _tourClientListRep = tourClientListRep;
  282. _teamRateRep = teamRateRep;
  283. _hubContext = hubContext;
  284. _usersRep = usersRep;
  285. _juHeApi = juHeApi;
  286. _invertedListRep = invertedListRep;
  287. _visaFeeInfoRep = visaFeeInfoRep;
  288. _ticketBlackCodeRep = ticketBlackCodeRep;
  289. _hotelInquiryRep = hotelInquiryRep;
  290. _threeCodeRepository = threeCodeRepository;
  291. _feeAuditRep = feeAuditRep;
  292. _visaCommissionRep = visaCommissionRep;
  293. _ffrRep = ffrRep;
  294. _opinionaireRep = opinionaireRep;
  295. _currencyInit = new List<CurrencyInfo>()
  296. {
  297. new(){ CurrencyCode="USD",CurrencyName = "美元",Rate = 7.5000M },
  298. new(){ CurrencyCode="EUR",CurrencyName = "欧元",Rate = 8.0000M },
  299. new(){ CurrencyCode="GBP",CurrencyName = "英镑",Rate = 9.5000M },
  300. new(){ CurrencyCode="JPY",CurrencyName = "日元",Rate = 0.0500M },
  301. new(){ CurrencyCode="HKD",CurrencyName = "港币",Rate = 0.9500M },
  302. };
  303. _portTypeData = new List<int>() { 2, 3 };
  304. _tableorRep = tableorRep;
  305. _enterExitCostDraftRep = enterExitCostDraftRep;
  306. _restaurantRep = restaurantRep;
  307. _enterExitCostQuoteRep = enterExitCostQuoteRep;
  308. _grpOrderPreInfoRep = grpOrderPreInfoRep;
  309. _visaProcessRep = visaProcessRep;
  310. _processOverviewRep = processOverviewRep;
  311. _groupSearchService = groupSearchService;
  312. }
  313. #region 页面加载弹窗信息
  314. /// <summary>
  315. /// 提示用户录入团组费用信息
  316. /// 根据用户ID获取分配权限内团组名称
  317. /// </summary>
  318. /// <param name="currUserId">用户Id</param>
  319. /// <param name="daysAgo">往前推的天数</param>
  320. /// <returns></returns>
  321. [HttpGet]
  322. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  323. public async Task<IActionResult> GetGroupNamesByUserId(int currUserId, int daysAgo = 5)
  324. {
  325. var stopwatch = Stopwatch.StartNew();
  326. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  327. .Where(x => x.Id == currUserId && x.IsDel == 0)
  328. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  329. .FirstAsync();
  330. if (userInfo == null)
  331. {
  332. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  333. }
  334. var jobId = userInfo.JobPostId;
  335. var feeTypeIds = new List<int>() { };
  336. if (_dataInit.TryGetValue(jobId, out var values))
  337. {
  338. feeTypeIds = values;
  339. }
  340. /*
  341. * 获取今天时间往前推5天查询团组c表里有没有费用
  342. */
  343. var today_startDate = DateTime.Now.Date.AddDays(-daysAgo);
  344. //var today_endDate = DateTime.Now.Date.AddDays(-daysAgo).AddDays(1).AddSeconds(-1);
  345. var today_endDate = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
  346. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  347. .Where(di => di.IsDel == 0)
  348. .Where(di => di.VisitDate >= today_startDate && di.VisitDate <= today_endDate)
  349. // 存在任务分配记录
  350. .Where(di => SqlFunc.Subqueryable<Grp_GroupsTaskAssignment>()
  351. .Where(gta => gta.DIId == di.Id && gta.IsDel == 0 && feeTypeIds.Contains(gta.CTId))
  352. .Any())
  353. // 不存在费用记录
  354. .Where(di => !SqlFunc.Subqueryable<Grp_CreditCardPayment>()
  355. .Where(ccp => ccp.DIId == di.Id && ccp.IsDel == 0 && feeTypeIds.Contains(ccp.CTable))
  356. .Any())
  357. // 新增条件:不在确认记录表中(排除已确认的团组)
  358. .Where(di => !SqlFunc.Subqueryable<Grp_FeeEntryAcknowledge>()
  359. .Where(ack => ack.GroupId == di.Id && ack.IsDel == 0 && ack.UserId == currUserId)
  360. .Where(ack => feeTypeIds.Contains(ack.FeeTypeId))
  361. .Where(ack => ack.IsAcknowledged == AcknowledgeStatusEnum.Acknowledged) // 只排除已确认的记录
  362. .Any())
  363. .Select(di => new
  364. {
  365. di.Id,
  366. di.TeamName,
  367. di.VisitDate
  368. })
  369. .OrderBy(di => di.VisitDate)
  370. .ToListAsync();
  371. stopwatch.Stop();
  372. return Ok(JsonView(true, $"操作成功!【耗时:{stopwatch.ElapsedMilliseconds}ms】", new
  373. {
  374. isTips = groupNames.Any(),
  375. groupNames = groupNames.Select(x => new { x.Id, GroupName = x.TeamName, x.VisitDate }).ToList()
  376. }));
  377. }
  378. /// <summary>
  379. /// 提示用户录入团组费用信息
  380. /// 已知晓确认操作记录(添加) 批量
  381. /// </summary>
  382. /// <param name="dto">请求体</param>
  383. /// <returns></returns>
  384. [HttpPost]
  385. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  386. public async Task<IActionResult> FeeEntryAcknowledgeCrate(FeeEntryAcknowledgeCrateDto dto)
  387. {
  388. // 1. 参数验证
  389. if (dto?.GroupIds == null || !dto.GroupIds.Any())
  390. return Ok(JsonView(false, "请选择需要确认的团组!"));
  391. if (dto.GroupIds.Count > 100)
  392. return Ok(JsonView(false, "一次性确认团组数量不能超过100个!"));
  393. if (dto.CurrUserId <= 0)
  394. return Ok(JsonView(false, "用户ID无效!"));
  395. // 2. 验证用户存在性
  396. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  397. .Where(x => x.Id == dto.CurrUserId && x.IsDel == 0)
  398. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  399. .FirstAsync();
  400. if (userInfo == null)
  401. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  402. // 3. 获取费用类型
  403. if (!_dataInit.TryGetValue(userInfo.JobPostId, out var feeTypeIds) || feeTypeIds?.Count == 0)
  404. return Ok(JsonView(false, "当前用户岗位无对应的费用类型配置!"));
  405. // 4. 验证团组存在性
  406. var validGroupIds = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  407. .Where(x => dto.GroupIds.Contains(x.Id) && x.IsDel == 0)
  408. .Select(x => x.Id)
  409. .ToListAsync();
  410. if (!validGroupIds.Any())
  411. return Ok(JsonView(false, "未找到有效的团组信息!"));
  412. // 5. 检查团组费用表中是否存在对应费用类型的数据
  413. var existingFeeRecords = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  414. .Where(x => validGroupIds.Contains(x.DIId) && x.IsDel == 0)
  415. .Where(x => feeTypeIds.Contains(x.CTable))
  416. .Select(x => new { GroupId = x.DIId, FeeTypeId = x.CTable })
  417. .ToListAsync();
  418. if (existingFeeRecords.Count > 0)
  419. {
  420. // 找出有问题的团组和费用类型
  421. var problematicGroups = existingFeeRecords
  422. .GroupBy(x => x.GroupId)
  423. .Select(g => new
  424. {
  425. GroupId = g.Key,
  426. FeeTypeIds = string.Join(",", g.Select(x => x.FeeTypeId).Distinct())
  427. })
  428. .ToList();
  429. var errorMessage = $"以下团组的费用表中已存在费用数据,不可添加确认记录:";
  430. foreach (var group in problematicGroups)
  431. {
  432. errorMessage += $"\n团组 {group.GroupId} - 费用类型ID: [{group.FeeTypeIds}]";
  433. }
  434. return Ok(JsonView(false, errorMessage));
  435. }
  436. // 6. 检查是否已存在确认记录(避免重复确认)
  437. var existingAcknowledgeRecords = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  438. .Where(x => x.UserId == dto.CurrUserId && x.IsDel == 0)
  439. .Where(x => validGroupIds.Contains(x.GroupId))
  440. .Where(x => feeTypeIds.Contains(x.FeeTypeId))
  441. .Select(x => new { x.GroupId, x.FeeTypeId })
  442. .ToListAsync();
  443. // 7. 准备插入数据(过滤已存在的记录)
  444. var recordsToInsert = new List<Grp_FeeEntryAcknowledge>();
  445. foreach (var groupId in validGroupIds)
  446. {
  447. foreach (var feeTypeId in feeTypeIds)
  448. {
  449. // 检查是否已存在相同记录
  450. var exists = existingAcknowledgeRecords.Any(x => x.GroupId == groupId && x.FeeTypeId == feeTypeId);
  451. if (!exists)
  452. {
  453. recordsToInsert.Add(new Grp_FeeEntryAcknowledge()
  454. {
  455. GroupId = groupId,
  456. UserId = dto.CurrUserId,
  457. JobPostId = userInfo.JobPostId,
  458. FeeTypeId = feeTypeId,
  459. IsAcknowledged = Domain.Enums.AcknowledgeStatusEnum.Acknowledged,
  460. AcknowledgeTime = DateTime.Now,
  461. AcknowledgeType = Domain.Enums.AcknowledgeTypeEnum.WebConfirm,
  462. CreateUserId = 4, // 系统创建
  463. CreateTime = DateTime.Now
  464. });
  465. }
  466. }
  467. }
  468. if (!recordsToInsert.Any())
  469. return Ok(JsonView(true, "所选团组已确认,无需重复操作!"));
  470. // 8. 批量插入数据
  471. var successCount = await _sqlSugar.Insertable(recordsToInsert).ExecuteCommandAsync();
  472. if (successCount <= 0)
  473. return Ok(JsonView(false, "操作失败,未能保存确认记录!"));
  474. // 9. 记录操作日志
  475. _logger.LogInformation("用户 {UserName}(ID:{UserId}) 批量确认了 {GroupCount} 个团组的费用类型,共添加 {RecordCount} 条确认记录",
  476. userInfo.CnName, dto.CurrUserId, validGroupIds.Count, successCount);
  477. // 10. 操作成功 返回成功视图
  478. var result = await GetGroupNamesByUserId(dto.CurrUserId, dto.DaysAgo);
  479. if (result is OkObjectResult okObjectResult)
  480. {
  481. return Ok(okObjectResult.Value);
  482. }
  483. //return Ok(result);
  484. return Ok(JsonView(true, $"操作成功!共为 {validGroupIds.Count} 个团组添加了 {successCount} 条确认记录"));
  485. }
  486. /// <summary>
  487. /// 提示用户录入团组费用信息
  488. /// 已知晓确认操作记录(添加) 单个
  489. /// </summary>
  490. /// <param name="dto">请求体</param>
  491. /// <returns></returns>
  492. [HttpPost]
  493. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  494. public async Task<IActionResult> FeeEntryAcknowledgeSingleCreate(FeeEntryAcknowledgeSingleDto dto)
  495. {
  496. // 1. 参数验证
  497. if (dto.GroupId <= 0)
  498. return Ok(JsonView(false, "请选择有效的团组ID!"));
  499. if (dto.CurrUserId <= 0)
  500. return Ok(JsonView(false, "用户ID无效!"));
  501. // 2. 验证用户存在性
  502. var userInfo = await _sqlSugar.Queryable<Sys_Users>()
  503. .Where(x => x.Id == dto.CurrUserId && x.IsDel == 0)
  504. .Select(x => new { x.Id, x.JobPostId, x.CnName })
  505. .FirstAsync();
  506. if (userInfo == null)
  507. return Ok(JsonView(false, "用户不存在或已被禁用!"));
  508. // 3. 获取费用类型
  509. if (!_dataInit.TryGetValue(userInfo.JobPostId, out var feeTypeIds) || feeTypeIds?.Count == 0)
  510. return Ok(JsonView(false, "当前用户岗位无对应的费用类型配置!"));
  511. // 4. 验证团组存在性
  512. var groupExists = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  513. .AnyAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  514. if (!groupExists)
  515. return Ok(JsonView(false, "未找到有效的团组信息!"));
  516. // 5. 检查团组费用表中是否存在对应费用类型的数据
  517. var existingFeeRecords = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  518. .Where(x => x.DIId == dto.GroupId && x.IsDel == 0)
  519. .Where(x => feeTypeIds.Contains(x.CTable))
  520. .Select(x => new { x.CTable })
  521. .ToListAsync();
  522. if (existingFeeRecords.Count > 0)
  523. {
  524. var existingFeeTypeNames = existingFeeRecords.Select(x => x.CTable).Distinct().ToList();
  525. return Ok(JsonView(false, $"团组费用表中已存在费用类型ID [{string.Join(",", existingFeeTypeNames)}] 的数据,不可添加确认无费用记录!"));
  526. }
  527. // 6. 检查已存在的确认记录
  528. var existingAcknowledgeRecords = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  529. .Where(x => x.UserId == dto.CurrUserId && x.IsDel == 0)
  530. .Where(x => x.GroupId == dto.GroupId)
  531. .Where(x => feeTypeIds.Contains(x.FeeTypeId))
  532. .Select(x => new { x.FeeTypeId })
  533. .ToListAsync();
  534. var existingAcknowledgeFeeTypeIds = existingAcknowledgeRecords.Select(x => x.FeeTypeId).ToHashSet();
  535. // 7. 准备插入数据(过滤已存在的记录)
  536. var recordsToInsert = feeTypeIds
  537. .Where(feeTypeId => !existingAcknowledgeFeeTypeIds.Contains(feeTypeId))
  538. .Select(feeTypeId => new Grp_FeeEntryAcknowledge
  539. {
  540. GroupId = dto.GroupId,
  541. UserId = dto.CurrUserId,
  542. JobPostId = userInfo.JobPostId,
  543. FeeTypeId = feeTypeId,
  544. IsAcknowledged = Domain.Enums.AcknowledgeStatusEnum.Acknowledged,
  545. AcknowledgeTime = DateTime.Now,
  546. AcknowledgeType = Domain.Enums.AcknowledgeTypeEnum.WebConfirm,
  547. CreateUserId = 4, // 系统创建
  548. CreateTime = DateTime.Now
  549. })
  550. .ToList();
  551. if (recordsToInsert.Count == 0)
  552. return Ok(JsonView(true, "所选团组已确认,无需重复操作!"));
  553. // 8. 批量插入数据
  554. var successCount = await _sqlSugar.Insertable(recordsToInsert).ExecuteCommandAsync();
  555. if (successCount <= 0)
  556. return Ok(JsonView(false, "操作失败,未能保存确认记录!"));
  557. // 9. 记录操作日志(可选)
  558. _logger.LogInformation("用户 {UserName}(ID:{UserId}) 确认了团组 {GroupId} 的费用类型",
  559. userInfo.CnName, dto.CurrUserId, dto.GroupId);
  560. return Ok(JsonView(true, $"操作成功!"));
  561. }
  562. #endregion
  563. #region 流程管控
  564. /// <summary>
  565. /// 获取团组流程管控信息
  566. /// </summary>
  567. /// <param name="_jsonDto">查询参数</param>
  568. /// <returns></returns>
  569. [HttpPost]
  570. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  571. public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
  572. {
  573. if (string.IsNullOrEmpty(_jsonDto.Paras))
  574. {
  575. return Ok(JsonView(false, "参数为空"));
  576. }
  577. Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
  578. if (_ScheduleDto != null)
  579. {
  580. if (_ScheduleDto.SearchType == 2)//获取列表
  581. {
  582. List<Grp_ScheduleView> _grpScheduleViewList = await _grpScheduleRep.GetViewList_GrpSchedule(_ScheduleDto);
  583. return Ok(JsonView(_grpScheduleViewList));
  584. }
  585. else//获取对象
  586. {
  587. Grp_ScheduleCombinView _grpScheduleView = await _grpScheduleRep.GetView_GrpSchedule(_ScheduleDto);
  588. if (_grpScheduleView != null)
  589. {
  590. return Ok(JsonView(_grpScheduleView));
  591. }
  592. }
  593. }
  594. else
  595. {
  596. return Ok(JsonView(false, "参数反序列化失败"));
  597. }
  598. return Ok(JsonView(false, "暂无数据!"));
  599. }
  600. /// <summary>
  601. /// 修改团组流程管控详细表数据
  602. /// </summary>
  603. /// <param name="dto"></param>
  604. /// <returns></returns>
  605. [HttpPost]
  606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  607. public async Task<IActionResult> PostUpdateGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  608. {
  609. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  610. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  611. .SetColumns(it => it.Duty == _detail.Duty)
  612. .SetColumns(it => it.ExpectBeginDt == _detail.ExpectBeginDt)
  613. .SetColumns(it => it.ExpectEndDt == _detail.ExpectEndDt)
  614. .SetColumns(it => it.JobContent == _detail.JobContent)
  615. .SetColumns(it => it.Remark == _detail.Remark)
  616. .SetColumns(it => it.StepStatus == _detail.StepStatus)
  617. .Where(s => s.Id == dto.Id)
  618. //.UpdateColumns(s => new { s.Duty, s.ExpectBeginDt, s.ExpectEndDt, s.JobContent, s.Remark, s.StepStatus })
  619. .ExecuteCommandAsync();
  620. if (result > 0)
  621. {
  622. return Ok(JsonView(true, "保存成功!"));
  623. }
  624. return Ok(JsonView(false, "保存失败!"));
  625. }
  626. /// <summary>
  627. /// 删除团组流程管控详细表数据,删除人Id请放在Duty
  628. /// </summary>
  629. /// <param name="dto"></param>
  630. /// <returns></returns>
  631. [HttpPost]
  632. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  633. public async Task<ActionResult> PostDeleteGrpScheduleDetail(Grp_ScheduleDetailUpdDto dto)
  634. {
  635. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  636. _detail.IsDel = 1;
  637. _detail.DeleteUserId = dto.Duty;
  638. _detail.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  639. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_ScheduleDetailInfo>()
  640. .SetColumns(it => it.IsDel == _detail.IsDel)
  641. .SetColumns(it => it.DeleteUserId == _detail.DeleteUserId)
  642. .SetColumns(it => it.DeleteTime == _detail.DeleteTime)
  643. .Where(it => it.Id == dto.Id)
  644. //.UpdateColumns(s => new { s.IsDel, s.DeleteUserId, s.DeleteTime })
  645. //.WhereColumns(s => s.Id == dto.Id)
  646. .ExecuteCommandAsync();
  647. if (result > 0)
  648. {
  649. return Ok(JsonView(true, "删除成功!"));
  650. }
  651. return Ok(JsonView(false, "删除失败!"));
  652. }
  653. /// <summary>
  654. /// 增加团组流程管控详细表数据
  655. /// </summary>
  656. /// <param name="dto"></param>
  657. /// <returns></returns>
  658. [HttpPost]
  659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  660. public async Task<ActionResult> PostInsertGrpScheduleDetail(Grp_ScheduleDetailInsertDto dto)
  661. {
  662. Grp_ScheduleDetailInfo _detail = _mapper.Map<Grp_ScheduleDetailInfo>(dto);
  663. if (DateTime.Now < _detail.ExpectBeginDt)
  664. {
  665. _detail.StepStatus = 0;
  666. }
  667. else
  668. {//若大于设置时间,不考虑设置的预计结束日期,统一视为进行中
  669. _detail.StepStatus = 1;
  670. }
  671. var result = await _grpScheduleRep._sqlSugar.Insertable(_detail).ExecuteReturnIdentityAsync();
  672. if (result > 0)
  673. {
  674. Grp_ScheduleDetailView _result = await _grpScheduleRep.GetInsertBackData(result);
  675. return Ok(JsonView(true, "添加成功!", _result));
  676. }
  677. return Ok(JsonView(false, "添加失败!"));
  678. }
  679. #endregion
  680. #region 团组前期信息
  681. /// <summary>
  682. /// 团组前期信息H5-URL(员工对应地址)
  683. /// </summary>
  684. /// <param name="name">用户名称</param>
  685. /// <returns></returns>
  686. [HttpGet]
  687. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  688. public async Task<IActionResult> GroupOrderPreInfoH5URLList([FromQuery] string name)
  689. {
  690. var userURLs = await _sqlSugar.Queryable<Sys_Users>()
  691. .Where(x => x.IsDel == 0)
  692. .WhereIF(!string.IsNullOrEmpty(name), x => x.CnName.Contains(name))
  693. .OrderBy(x => x.Id)
  694. .Select(x => new
  695. {
  696. name = x.CnName,
  697. url = $"http://oa.pan-american-intl.com:4399/#/MarketplacePick?userid={x.Id}",
  698. })
  699. .ToListAsync();
  700. return Ok(JsonView(true, "操作成功!", userURLs, userURLs.Count));
  701. }
  702. /// <summary>
  703. /// 团组前期信息 List
  704. /// </summary>
  705. /// <returns></returns>
  706. [HttpPost]
  707. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  708. public async Task<IActionResult> GroupOrderPreInfoList(GroupOrderPreInfoListDto dto)
  709. {
  710. var search = dto.Search;
  711. int[] nameTempIds = new int[] { 1, 12, 28 },
  712. countryTempIds = new int[] { 2, 13, 29 },
  713. daysTempIds = new int[] { 4, 15, 31 },
  714. ppNumTempIds = new int[] { 6 };
  715. var list = await _sqlSugar.Queryable<Grp_OrderPreInfo>()
  716. .LeftJoin<Sys_Users>((opi, u) => opi.CreateUserId == u.Id)
  717. .Where((opi, u) => opi.IsDel == 0)
  718. .OrderByDescending((opi, u) => opi.CreateTime)
  719. .Select((opi, u) => new GroupOrderPreInfoListView()
  720. {
  721. Id = opi.Id,
  722. Name = opi.Name,
  723. UnitName = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && nameTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  724. VisitCountryVal = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && countryTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  725. VisitDays = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && daysTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  726. VisiPpNum = SqlFunc.Subqueryable<Grp_OrderPreItem>().Where(x => x.ParentId == opi.Id && ppNumTempIds.Contains(x.FormTempId)).Select(x => x.Value),
  727. Operator = u.CnName,
  728. OperationTime = opi.CreateTime
  729. })
  730. //.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search))
  731. //.ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  732. .ToListAsync();
  733. var listPageData = list.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search) || x.UnitName.Contains(search) || x.VisitCountrys.Contains(search)).ToList();
  734. int total = list.Count;
  735. int totalPageCount = (int)Math.Ceiling(list.Count / (double)dto.PageSize);
  736. var listPageData1 = listPageData
  737. .Skip((dto.PageIndex - 1) * dto.PageSize)
  738. .Take(dto.PageSize)
  739. .ToList();
  740. var infoIds = listPageData1.Select(x => x.Id).ToList();
  741. var typeDatas = await _sqlSugar.Queryable<Sys_SetData>()
  742. .Where(x => x.IsDel == 0 && x.STid == 109)
  743. .ToArrayAsync();
  744. var items = await _sqlSugar.Queryable<Grp_OrderPreItem>()
  745. .LeftJoin<Sys_FormTemp>((opi, ft) => opi.FormTempId == ft.Id)
  746. .Where((opi, ft) => opi.IsDel == 0 && infoIds.Contains(opi.ParentId))
  747. .Select((opi, ft) => new { opi.ParentId, opi.FormTempId, ft.TempId })
  748. .ToListAsync();
  749. foreach (var item in listPageData1)
  750. {
  751. var typeDatas1 = typeDatas.Select(x => new
  752. {
  753. x.Id,
  754. x.Name,
  755. IsNull = !items.Any(x1 => item.Id == x1.ParentId && x.Id == x1.TempId)
  756. }).ToArray();
  757. item.VersionDetails = typeDatas1;
  758. }
  759. return Ok(JsonView(listPageData1, listPageData1.Count));
  760. }
  761. /// <summary>
  762. /// 团组前期信息 Init
  763. /// </summary>
  764. /// <returns></returns>
  765. [HttpGet("{userId}")]
  766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  767. public async Task<IActionResult> GroupOrderPreInfo(int userId)
  768. {
  769. return Ok(await _grpOrderPreInfoRep.DataInit(userId));
  770. }
  771. /// <summary>
  772. /// 国家数据源
  773. /// </summary>
  774. /// <param name="pageIndex">当前页码</param>
  775. /// <param name="pageSize">每页条数</param>
  776. /// <param name="search">查询条件</param>
  777. /// <returns></returns>
  778. [HttpGet]
  779. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  780. public async Task<IActionResult> CountryInit([FromQuery] int pageIndex, [FromQuery] int pageSize, [FromQuery] string search)
  781. {
  782. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => x.Country).Distinct().ToListAsync();
  783. if (pageIndex == 0 && pageSize == 0)
  784. {
  785. //所有数据
  786. return Ok(JsonView(countrys, countrys.Count));
  787. }
  788. //分页
  789. int skip = (pageIndex - 1) * pageSize;
  790. int take = pageSize;
  791. if (!string.IsNullOrEmpty(search))
  792. {
  793. IEnumerable<char> charSequence = search.Select(c => c);
  794. var pageResult1 = countrys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  795. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  796. return Ok(JsonView(pageData, pageResult1.Count));
  797. }
  798. var pageResult2 = countrys.Skip(skip).Take(take).ToList();
  799. return Ok(JsonView(pageResult2, countrys.Count));
  800. }
  801. /// <summary>
  802. /// 城市数据源
  803. /// </summary>
  804. /// <param name="countryLabel">国家名称 多个使用英文逗号隔开</param>
  805. /// <param name="pageIndex">当前页码</param>
  806. /// <param name="pageSize">每页条数</param>
  807. /// <param name="search">查询条件</param>
  808. /// <returns></returns>
  809. [HttpGet("{countryLabel}")]
  810. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  811. public async Task<IActionResult> CityByCountry(
  812. string countryLabel,
  813. [FromQuery] int pageIndex,
  814. [FromQuery] int pageSize,
  815. [FromQuery] string search)
  816. {
  817. countryLabel = HttpUtility.UrlDecode(countryLabel);
  818. var countryList = countryLabel.Split(',', StringSplitOptions.RemoveEmptyEntries).ToArray();
  819. var citys = Array.Empty<string?>();
  820. if (countryList.Any())
  821. {
  822. var cityDatas = await _sqlSugar
  823. .Queryable<Grp_NationalTravelFee>()
  824. .Where(x => x.IsDel == 0 && countryList.Contains(x.Country) && !string.IsNullOrEmpty(x.City))
  825. .ToArrayAsync();
  826. foreach (var item in cityDatas)
  827. {
  828. if (item.City.Contains("城市"))
  829. {
  830. item.City = item.Country + "-所有城市";
  831. }
  832. }
  833. var cityDatas1 = cityDatas.OrderBy(x => x.Country);
  834. citys = cityDatas1.Select(x => x.City).Distinct().ToArray();
  835. }
  836. if (pageIndex == 0 && pageSize == 0)
  837. {
  838. //所有数据
  839. return Ok(JsonView(citys, citys?.Length ?? 0));
  840. }
  841. //分页
  842. int skip = (pageIndex - 1) * pageSize;
  843. int take = pageSize;
  844. if (!string.IsNullOrEmpty(search))
  845. {
  846. IEnumerable<char> charSequence = search.Select(c => c);
  847. var pageResult1 = citys.Where(x => charSequence.All(x1 => x.Contains(x1))).ToList();
  848. var pageData = pageResult1.Skip(skip).Take(take).ToList();
  849. return Ok(JsonView(pageData, pageResult1.Count));
  850. }
  851. var pageResult2 = citys.Skip(skip).Take(take).ToList();
  852. return Ok(JsonView(pageResult2, citys?.Length ?? 0));
  853. }
  854. /// <summary>
  855. /// 团组前期信息 Info
  856. /// </summary>
  857. /// <param name="dto">Id</param>
  858. /// <returns></returns>
  859. [HttpGet("{Id}/{TempId}")]
  860. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  861. public async Task<IActionResult> GroupOrderPreInfo([FromRoute] GroupOrderPreInfoDto dto)
  862. {
  863. return Ok(await _grpOrderPreInfoRep.InfoAsync(dto.Id, dto.TempId));
  864. }
  865. /// <summary>
  866. /// 团组前期信息 移动端 Info
  867. /// </summary>
  868. /// <param name="dto">Id</param>
  869. /// <returns></returns>
  870. [HttpGet("{Id}/{TempId}")]
  871. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  872. public async Task<IActionResult> GroupOrderPreMobileInfo([FromRoute] GroupOrderPreInfoDto dto)
  873. {
  874. return Ok(await _grpOrderPreInfoRep.MobileInfoAsync(dto.Id, dto.TempId));
  875. }
  876. /// <summary>
  877. /// 团组前期信息 Save
  878. /// </summary>
  879. /// <param name="dto">Id</param>
  880. /// <returns></returns>
  881. [HttpPost]
  882. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  883. public async Task<IActionResult> GroupOrderPreInfoSave(GroupOrderPreInfoOpDto dto)
  884. {
  885. return Ok(await _grpOrderPreInfoRep.OpAsync(dto));
  886. }
  887. /// <summary>
  888. /// 团组前期信息 Del
  889. /// </summary>
  890. /// <param name="dto">Id</param>
  891. /// <returns></returns>
  892. [HttpPost]
  893. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  894. public async Task<IActionResult> GroupOrderPreInfoDel(GroupOrderPreInfoDelDto dto)
  895. {
  896. return Ok(await _grpOrderPreInfoRep.DelAsync(dto));
  897. }
  898. /// <summary>
  899. /// 团组前期信息 文件下载
  900. /// </summary>
  901. /// <param name="dto">Id</param>
  902. /// <returns></returns>
  903. [HttpGet("{Id}/{TempId}")]
  904. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  905. public async Task<IActionResult> GroupOrderPreInfoFileDownload([FromRoute] GroupOrderPreInfoDto dto)
  906. {
  907. int id = dto.Id, tempId = dto.TempId;
  908. var view = await _grpOrderPreInfoRep.InfoAsync(id, tempId);
  909. var data = view.Data as GrpOrderPreInfoView;
  910. #region Excel
  911. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  912. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  913. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "GroupOrderPreInfo/";
  914. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "GroupOrderPreInfo/";
  915. var fileNamePrefix = string.Empty;
  916. if (tempId == 1405)
  917. {
  918. tempPath += $"前期需客户提供信息_无商邀版Temp.xlsx";
  919. fileNamePrefix = $"{data.Name}_无商邀版";
  920. }
  921. else if (tempId == 1406)
  922. {
  923. tempPath += $"前期需客户提供信息_有商邀版Temp.xlsx";
  924. fileNamePrefix = $"{data.Name}_有商邀版";
  925. }
  926. else
  927. {
  928. //tempId == 1404 默认下载
  929. tempPath += $"前期需客户提供信息_单接送机Temp.xlsx";
  930. fileNamePrefix = $"{data.Name}_单接送机";
  931. }
  932. foreach (var item in data.Items)
  933. {
  934. var obj = item.NewValue;
  935. if (obj == null) item.OriginVal = "";
  936. else if (obj.Equals("有") || obj.Equals("无"))
  937. {
  938. item.OriginVal = obj.ToString();
  939. }
  940. else if (obj is object[] objArray)
  941. {
  942. string[] stringArray = Array.ConvertAll(objArray, item => item?.ToString() ?? string.Empty);
  943. item.OriginVal = string.Join("、", stringArray);
  944. }
  945. else if (obj is string[] stringArray)
  946. {
  947. item.OriginVal = string.Join("、", stringArray);
  948. }
  949. else if (obj.Equals("-"))
  950. {
  951. item.OriginVal = "";
  952. }
  953. }
  954. var fileName = $"{fileNamePrefix}{CommonFun.GUID}.xlsx";
  955. fileName = CommonFun.ValidFileName(fileName);
  956. //载入模板
  957. var designer = new WorkbookDesigner
  958. {
  959. Workbook = new Workbook(tempPath)
  960. };
  961. if (tempId == 1406)
  962. {
  963. var view1 = data.Items.Where(x => x.Index < 11).ToArray();
  964. var view2 = data.Items.Where(x => x.Index > 10).ToArray();
  965. for (int i = 1; i <= view2.Length; i++)
  966. {
  967. view2[i - 1].Index = i;
  968. }
  969. designer.SetDataSource("View1", view1);
  970. designer.SetDataSource("View2", view2);
  971. }
  972. else
  973. {
  974. designer.SetDataSource("View", data.Items);
  975. }
  976. designer.Process();
  977. if (!Directory.Exists(savePath))
  978. {
  979. Directory.CreateDirectory(savePath);
  980. }
  981. string serverPath = $"{savePath}{fileName}";
  982. designer.Workbook.Save(serverPath);
  983. string rst = $"{servicePath}{ftpPath}{fileName}";
  984. #endregion
  985. return Ok(JsonView(new { url = rst }));
  986. }
  987. #endregion
  988. #region 团组基本信息
  989. /// <summary>
  990. /// 接团信息列表
  991. /// </summary>
  992. /// <param name="dto">团组列表请求dto</param>
  993. /// <returns></returns>
  994. [HttpPost]
  995. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  996. public async Task<IActionResult> GetGroupList(GroupListDto dto)
  997. {
  998. var groupData = await _groupRepository.GetGroupList(dto);
  999. if (groupData.Code != 0)
  1000. {
  1001. return Ok(JsonView(false, groupData.Msg));
  1002. }
  1003. return Ok(JsonView(groupData.Data));
  1004. }
  1005. /// <summary>
  1006. /// 分页查询团组列表
  1007. /// </summary>
  1008. /// <param name="dto"></param>
  1009. /// <returns></returns>
  1010. [HttpPost]
  1011. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1012. public async Task<IActionResult> QueryGroupListOffset(QueryGroupListOffsetDto dto)
  1013. {
  1014. var watch = new Stopwatch();
  1015. watch.Start();
  1016. RefAsync<int> total = 0;
  1017. var countyDatas = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  1018. .Where((di) => di.IsDel == 0 && !string.IsNullOrWhiteSpace(di.TeamName))
  1019. .WhereIF(!string.IsNullOrEmpty(dto.Search), (di) => di.TeamName.Contains(dto.Search))
  1020. .OrderBy((di) => new { id = SqlFunc.Desc(di.Id) })
  1021. .Select((di) => new { id = di.Id, name = di.TeamName, di.ClientName, di.VisitPNumber, di.VisitCountry, di.VisitDays, di.VisitStartDate, di.VisitEndDate, di.TourCode })
  1022. .Distinct()
  1023. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1024. watch.Stop();
  1025. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  1026. }
  1027. /// <summary>
  1028. /// 接团信息列表 Page Init
  1029. /// </summary>
  1030. /// <returns></returns>
  1031. [HttpPost]
  1032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1033. public async Task<IActionResult> PostGroupPageListInit()
  1034. {
  1035. var depDatas = await GeneralMethod.GroupOpAffiliationBranchInit();
  1036. var rankDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 56).Select(x => new { x.Id, x.Name }).ToListAsync();
  1037. rankDatas.Insert(0, new { Id = 0, Name = "全部" });
  1038. var _view = new
  1039. {
  1040. depData = depDatas,
  1041. rankData = rankDatas
  1042. };
  1043. return Ok(JsonView(true, "查询成功!", _view));
  1044. }
  1045. /// <summary>
  1046. /// 接团信息列表 关键字输入提示
  1047. /// </summary>
  1048. /// <param name="keyword">关键字</param>
  1049. /// <returns></returns>
  1050. [HttpGet]
  1051. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1052. public async Task<IActionResult> GroupItemNativeKeywordSearch (string keyword)
  1053. {
  1054. var jw = JsonView(true, "暂无数据");
  1055. if (string.IsNullOrEmpty(keyword)) return Ok(jw);
  1056. var expression = Expressionable
  1057. .Create<Grp_DelegationInfo>()
  1058. .And(x => x.IsDel == 0);
  1059. string field = "TeamName,ClientUnit,ClientName";
  1060. var groupData = _sqlSugar.Queryable<Grp_DelegationInfo>()
  1061. .Where(expression.ToExpression())
  1062. .Select(field)
  1063. .ToList();
  1064. var keywordArray = keyword.ToCharArray();
  1065. var matches = groupData
  1066. .Where(fullString => !string.IsNullOrWhiteSpace(fullString.TeamName) &&
  1067. keywordArray.All(keyword => fullString.TeamName.Contains(keyword)))
  1068. .Select(x => new
  1069. {
  1070. x.TeamName,
  1071. x.ClientUnit,
  1072. x.ClientName
  1073. })
  1074. .DistinctBy(x => x.TeamName)
  1075. .ToList();
  1076. if (matches.Any())
  1077. {
  1078. jw.Code = StatusCodes.Status200OK;
  1079. jw.Msg = "搜索成功";
  1080. jw.Data = matches;
  1081. jw.Count = matches.Count;
  1082. }
  1083. return Ok(jw);
  1084. }
  1085. /// <summary>
  1086. /// 接团信息列表 关键字输入提示(智能版)
  1087. /// </summary>
  1088. /// <param name="keyword">关键字</param>
  1089. /// <returns></returns>
  1090. [HttpGet]
  1091. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1092. public async Task<IActionResult> GroupItemKeywordSearch(string keyword)
  1093. {
  1094. try
  1095. {
  1096. // 验证请求参数
  1097. if (string.IsNullOrEmpty(keyword))
  1098. {
  1099. return Ok(JsonView(true, $"暂无数据!"));
  1100. }
  1101. var searchRequest = new DynamicSearchRequest
  1102. {
  1103. Keyword = keyword,
  1104. RequireAllSingleChars = true,
  1105. PageIndex = 1,
  1106. PageSize = 999999,
  1107. FieldWeights = new Dictionary<string, int>
  1108. {
  1109. { "TeamName", 10 },
  1110. //{ "ClientUnit", 8 },
  1111. //{ "ClientName", 6 }
  1112. },
  1113. Filters = new List<SearchFilter>()
  1114. {
  1115. new(){Field = "IsDel",Operator="eq",Value="0" }
  1116. },
  1117. OrderBy = "TeamName",
  1118. ReturnFields = new List<string>() { "TeamName", "ClientUnit", "ClientName" }
  1119. };
  1120. // 验证字段配置
  1121. var validation = _groupSearchService.ValidateFieldConfig(
  1122. searchRequest.FieldWeights,
  1123. searchRequest.ReturnFields);
  1124. if (!validation.IsValid)
  1125. {
  1126. return Ok(JsonView(true, $"暂无数据!{validation.Message}"));
  1127. }
  1128. var result = await _groupSearchService.SearchAsync(searchRequest);
  1129. if (result.Success)
  1130. {
  1131. var data = new List<dynamic>();
  1132. foreach (var item in result.Items)
  1133. {
  1134. data.Add(new
  1135. {
  1136. item.Data.TeamName,
  1137. item.Data.ClientUnit,
  1138. item.Data.ClientName
  1139. });
  1140. }
  1141. return Ok(JsonView(true, result.Message, data, data.Count));
  1142. }
  1143. return Ok(JsonView(true, result.Message));
  1144. }
  1145. catch (Exception ex)
  1146. {
  1147. return Ok(JsonView(true, $"搜索服务暂时不可用!"));
  1148. }
  1149. }
  1150. /// <summary>
  1151. /// 接团信息列表 Page
  1152. /// </summary>
  1153. /// <param name="dto">团组列表请求dto</param>
  1154. /// <returns></returns>
  1155. [HttpPost]
  1156. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1157. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  1158. {
  1159. // 创建Stopwatch实例
  1160. var stopwatch = new Stopwatch();
  1161. stopwatch.Start();
  1162. #region 参数验证
  1163. if (dto.UserId < 1)
  1164. return Ok(JsonView(false, "员工Id为空"));
  1165. if (dto.PageId < 1)
  1166. return Ok(JsonView(false, "页面Id为空"));
  1167. #region 页面操作权限验证
  1168. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1169. if (pageFunAuthView.CheckAuth == 0)
  1170. return Ok(JsonView(false, "您没有查看权限"));
  1171. #endregion
  1172. #endregion
  1173. //if (dto.PortType != 1 && dto.PortType != 2) // web/Android
  1174. // return Ok(JsonView(false, "不支持的端口类型"));
  1175. // 构建查询条件
  1176. var sqlWhereBuilder = new StringBuilder(" WHERE gdi.IsDel = 0");
  1177. var parameters = new List<SugarParameter>();
  1178. // 完成状态筛选
  1179. if (dto.IsSure == 0 || dto.IsSure == 1)
  1180. {
  1181. sqlWhereBuilder.Append(" AND gdi.IsSure = @IsSure");
  1182. parameters.Add(new SugarParameter("@IsSure", dto.IsSure));
  1183. }
  1184. // 搜索条件
  1185. if (!string.IsNullOrWhiteSpace(dto.SearchCriteria))
  1186. {
  1187. var searchParam = $"%{dto.SearchCriteria.Trim()}%";
  1188. sqlWhereBuilder.Append(@"
  1189. AND (ssd.Name LIKE @SearchCriteria
  1190. OR gdi.TeamName LIKE @SearchCriteria
  1191. OR gdi.ClientName LIKE @SearchCriteria
  1192. OR su.CnName LIKE @SearchCriteria)");
  1193. parameters.Add(new SugarParameter("@SearchCriteria", searchParam));
  1194. }
  1195. // 等级筛选
  1196. if (int.TryParse(dto.Rank, out int rankId) && rankId > 0)
  1197. {
  1198. sqlWhereBuilder.Append(" AND gdi.TeamLevSId = @RankId");
  1199. parameters.Add(new SugarParameter("@RankId", rankId));
  1200. }
  1201. // 部门筛选
  1202. var departmentWhere = string.Empty;
  1203. if (!string.IsNullOrWhiteSpace(dto.Department) && !dto.Department.Equals("全部"))
  1204. {
  1205. departmentWhere = " WHERE Department = @Department";
  1206. parameters.Add(new SugarParameter("@Department", dto.Department));
  1207. }
  1208. // 构建SQL查询
  1209. string sql = $@"
  1210. SELECT Row_Number, Id, SalesQuoteNo, TourCode, TeamTypeId, TeamType, Department,
  1211. TeamLevId, TeamLev, TeamName, ClientName, ClientUnit,
  1212. VisitDate, VisitDays, VisitPNumber, JietuanOperatorId,
  1213. JietuanOperator, IsSure, CreateTime, IsBid, Step
  1214. FROM (
  1215. SELECT ROW_NUMBER() OVER(ORDER BY gdi.VisitStartDate DESC) AS Row_Number,
  1216. CASE
  1217. WHEN gdi.JietuanOperator IN (4, 21) THEN '国交部'
  1218. ELSE (SELECT DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId)
  1219. END AS 'Department',
  1220. gdi.Id, SalesQuoteNo, TourCode, ssd.Id AS TeamTypeId, ssd.Name AS TeamType, gdi.Step,
  1221. ssd1.Id AS TeamLevId, ssd1.Name AS TeamLev, TeamName, ClientName, ClientUnit,
  1222. VisitDate, VisitDays, VisitPNumber, JietuanOperator AS JietuanOperatorId,
  1223. su.CnName AS JietuanOperator, IsSure, gdi.CreateTime, gdi.IsBid
  1224. FROM Grp_DelegationInfo gdi
  1225. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1226. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1227. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1228. {sqlWhereBuilder}
  1229. ) temp {departmentWhere}";
  1230. // 执行分页查询
  1231. RefAsync<int> total = 0;
  1232. var delegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql)
  1233. .AddParameters(parameters)
  1234. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1235. if (!delegationList.Any())
  1236. {
  1237. var emptyView = new
  1238. {
  1239. PageFuncAuth = pageFunAuthView,
  1240. Data = delegationList
  1241. };
  1242. return Ok(JsonView(true, "查询成功,暂无数据", emptyView, total));
  1243. }
  1244. // 批量处理团组模块实际操作人和背景颜色设置
  1245. await ProcessDelegationListData(delegationList);
  1246. var resultView = new
  1247. {
  1248. PageFuncAuth = pageFunAuthView,
  1249. Data = delegationList
  1250. };
  1251. stopwatch.Stop();
  1252. return Ok(JsonView(true, $"查询成功!耗时:{stopwatch.Elapsed.TotalSeconds:F3}s", resultView, total));
  1253. }
  1254. /// <summary>
  1255. /// 批量处理团组数据
  1256. /// </summary>
  1257. private async Task ProcessDelegationListData(List<DelegationListView> delegationList)
  1258. {
  1259. var groupIds = delegationList.Select(x => x.Id).ToList();
  1260. // 批量查询信用卡支付记录
  1261. var creditCardPayments = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  1262. .Where(y => groupIds.Contains(y.DIId) && y.IsDel == 0)
  1263. .Select(y => y.DIId)
  1264. .Distinct()
  1265. .ToListAsync();
  1266. // 批量查询费用确认记录
  1267. var feeAcknowledgements = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  1268. .Where(y => groupIds.Contains(y.GroupId) && y.IsDel == 0)
  1269. .Where(y => y.IsAcknowledged == AcknowledgeStatusEnum.Acknowledged)
  1270. .Select(y => y.GroupId)
  1271. .Distinct()
  1272. .ToListAsync();
  1273. var creditCardPaymentSet = creditCardPayments.ToHashSet();
  1274. var feeAcknowledgementSet = feeAcknowledgements.ToHashSet();
  1275. // 并行处理每个团组
  1276. var tasks = delegationList.Select(async x =>
  1277. {
  1278. // 处理团组模块实际操作人
  1279. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  1280. var operatorNames = new StringBuilder();
  1281. if (operators.Any())
  1282. {
  1283. foreach (var operatorInfo in operators)
  1284. {
  1285. string label = operatorInfo.OperationUsers.Any()
  1286. ? string.Join('、', operatorInfo.OperationUsers.Select(u => u.UserName))
  1287. : "暂未指定";
  1288. operatorNames.AppendLine($"{operatorInfo.CTableName}:{label}");
  1289. operatorNames.AppendLine();
  1290. }
  1291. }
  1292. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  1293. // 设置背景颜色为红色
  1294. // C表没数据并且没点提醒确认按钮(无成本费用按钮)的团组该行显示红色
  1295. bool hasCreditCardPayment = creditCardPaymentSet.Contains(x.Id);
  1296. bool hasFeeAcknowledgement = feeAcknowledgementSet.Contains(x.Id);
  1297. x.UseRedBackground = !hasCreditCardPayment && !hasFeeAcknowledgement;
  1298. });
  1299. await Task.WhenAll(tasks);
  1300. }
  1301. /// <summary>
  1302. /// 团组列表
  1303. /// </summary>
  1304. /// <returns></returns>
  1305. [HttpPost]
  1306. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  1307. {
  1308. #region 参数验证
  1309. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1310. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1311. #region 页面操作权限验证
  1312. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1313. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1314. #endregion
  1315. #endregion
  1316. if (dto.PortType != 1 && dto.PortType != 2)
  1317. {
  1318. return Ok(JsonView(false, "查询失败!"));
  1319. }
  1320. string orderbyStr = "order by gdi.CreateTime Desc";
  1321. string sqlWhere = string.Empty;
  1322. if (dto.IsSure == 0) //未完成
  1323. {
  1324. sqlWhere += string.Format(@" And IsSure = 0");
  1325. }
  1326. else if (dto.IsSure == 1) //已完成
  1327. {
  1328. sqlWhere += string.Format(@" And IsSure = 1");
  1329. }
  1330. //团组类型
  1331. if (dto.TeamDid > 0)
  1332. {
  1333. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  1334. }
  1335. //团组名称
  1336. if (!string.IsNullOrEmpty(dto.TeamName))
  1337. {
  1338. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  1339. }
  1340. //客户名称
  1341. if (!string.IsNullOrEmpty(dto.ClientName))
  1342. {
  1343. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  1344. }
  1345. //客户单位
  1346. if (!string.IsNullOrEmpty(dto.ClientUnit))
  1347. {
  1348. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  1349. }
  1350. //出访时间
  1351. if (!string.IsNullOrEmpty(dto.visitDataTime))
  1352. {
  1353. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  1354. orderbyStr = "order by gdi.VisitDate";
  1355. }
  1356. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1357. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  1358. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  1359. JietuanOperator,IsSure,CreateTime
  1360. From (
  1361. Select row_number() over({0}) as Row_Number,
  1362. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  1363. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  1364. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  1365. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1366. From Grp_DelegationInfo gdi
  1367. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1368. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1369. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1370. Where gdi.IsDel = 0 {1}
  1371. ) temp ", orderbyStr, sqlWhere);
  1372. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1373. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  1374. #region 处理所属部门
  1375. /*
  1376. * 1.sq 和 gyy 等显示 市场部
  1377. * 2.王鸽和主管及张总还有管理员号统一国交部
  1378. * 2-1. 4 管理员 ,21 张海麟
  1379. */
  1380. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  1381. var userIds1 = new List<int>() { 4, 21 };
  1382. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  1383. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1384. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1385. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1386. .ToList();
  1387. foreach (var item in _DelegationList)
  1388. {
  1389. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1390. }
  1391. #endregion
  1392. var _view = new
  1393. {
  1394. PageFuncAuth = pageFunAuthView,
  1395. Data = _DelegationList
  1396. };
  1397. return Ok(JsonView(true, $"查询成功!", _view, total));
  1398. }
  1399. /// <summary>
  1400. /// 接团信息详情
  1401. /// </summary>
  1402. /// <param name="dto">团组info请求dto</param>
  1403. /// <returns></returns>
  1404. [HttpPost]
  1405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1406. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  1407. {
  1408. var groupData = await _groupRepository.GetGroupInfo(dto);
  1409. if (groupData.Code != 0)
  1410. {
  1411. return Ok(JsonView(false, groupData.Msg));
  1412. }
  1413. return Ok(JsonView(groupData.Data));
  1414. }
  1415. /// <summary>
  1416. /// 接团信息 编辑添加
  1417. /// 基础信息数据源
  1418. /// </summary>
  1419. /// <param name="dto"></param>
  1420. /// <returns></returns>
  1421. [HttpPost]
  1422. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1423. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  1424. {
  1425. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  1426. if (groupData.Code != 0)
  1427. {
  1428. return Ok(JsonView(false, groupData.Msg));
  1429. }
  1430. return Ok(JsonView(groupData.Data));
  1431. }
  1432. /// <summary>
  1433. /// 成本修改团组信息
  1434. /// </summary>
  1435. /// <param name="dto"></param>
  1436. /// <returns></returns>
  1437. [HttpPost]
  1438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1439. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  1440. {
  1441. var jw = JsonView(false, "操作失败");
  1442. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  1443. if (di == null)
  1444. {
  1445. jw.Msg = "参数有误!";
  1446. return Ok(jw);
  1447. }
  1448. #region 添加出访起止时间
  1449. var startTime = new DateTime();
  1450. var endTime = new DateTime();
  1451. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1452. {
  1453. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1454. }
  1455. else
  1456. {
  1457. jw.Msg = "参数有误!";
  1458. return Ok(jw);
  1459. }
  1460. #endregion
  1461. di.VisitDate = startTime;
  1462. di.VisitPNumber = dto.VisitPNumber;
  1463. di.VisitDays = dto.VisitDays;
  1464. di.VisitStartDate = startTime;
  1465. di.VisitEndDate = endTime;
  1466. var count = _sqlSugar.Updateable(di)
  1467. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1468. .ExecuteCommand();
  1469. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1470. }
  1471. /// <summary>
  1472. /// 接团信息 编辑添加
  1473. /// 省份-城市 基础信息数据源
  1474. /// </summary>
  1475. /// <param name="dto"></param>
  1476. /// <returns></returns>
  1477. [HttpPost]
  1478. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1479. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1480. {
  1481. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1482. string search = dto.Search;
  1483. var data = await _groupRepository.CityBasicSource();
  1484. int total = data.Length;
  1485. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1486. .Skip((pageIndex - 1) * pageSize)
  1487. .Take(pageSize)
  1488. .ToArray();
  1489. return Ok(JsonView(data, total));
  1490. }
  1491. /// <summary>
  1492. /// 接团信息 操作(增改)
  1493. /// </summary>
  1494. /// <param name="dto"></param>
  1495. /// <returns></returns>
  1496. [HttpPost]
  1497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1498. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1499. {
  1500. // 创建 Stopwatch 实例
  1501. Stopwatch stopwatch = Stopwatch.StartNew();
  1502. decimal ffrPrice = 0.00M;
  1503. DateTime? visitDt = null;
  1504. if (dto.Status == 2)
  1505. {
  1506. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1507. if (groupInfo != null)
  1508. {
  1509. ffrPrice = groupInfo.PaymentMoney;
  1510. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1511. }
  1512. }
  1513. var groupData = await _groupRepository.GroupOperation(dto);
  1514. if (groupData.Code != 0)
  1515. {
  1516. return Ok(JsonView(false, groupData.Msg));
  1517. }
  1518. int diId = 0;
  1519. try
  1520. {
  1521. //添加时 默认加入团组汇率
  1522. if (dto.Status == 1) //添加
  1523. {
  1524. diId = groupData.Data;
  1525. //添加默认币种
  1526. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1527. //默认分配权限
  1528. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1529. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1530. var _managerIds = new List<int>() { 22, 32, 21 };
  1531. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1532. if (userIds.Count > 0)
  1533. {
  1534. userIds.Add(208);
  1535. //创建团组管控
  1536. GroupStepForDelegation.CreateWorkStep(diId);
  1537. //发送消息
  1538. string groupName = dto.TeamName;
  1539. string createGroupUser = string.Empty;
  1540. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1541. if (userInfo != null) createGroupUser = userInfo.CnName;
  1542. string title = $"系统通知";
  1543. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1544. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1545. }
  1546. //默认创建倒推表
  1547. await _invertedListRep._Create(dto.UserId, diId);
  1548. //默认创建签证流程
  1549. await _visaProcessRep.Create(dto.UserId, diId);
  1550. //默认创建团组流程总览信息
  1551. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1552. }
  1553. else if (dto.Status == 2)
  1554. {
  1555. diId = dto.Id;
  1556. }
  1557. #region 签证人员团组时间通知
  1558. #region 计算出访起止时间
  1559. var startTime = new DateTime();
  1560. var endTime = new DateTime();
  1561. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1562. {
  1563. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1564. }
  1565. #endregion
  1566. #endregion
  1567. #region 团组操作默认添加/修改收款账单
  1568. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1569. {
  1570. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1571. .Where(x => x.IsDel == 0 &&
  1572. x.Diid == diId &&
  1573. x.Remark.Equals("预付款")
  1574. )
  1575. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1576. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1577. .FirstAsync();
  1578. ffrInfo = new Fin_ForeignReceivables()
  1579. {
  1580. Diid = diId,
  1581. PriceName = dto.ClientUnit,
  1582. Price = dto.PaymentMoney,
  1583. Count = 1,
  1584. Unit = $"元",
  1585. ItemSumPrice = dto.PaymentMoney,
  1586. Rate = 1.0000M,
  1587. Currency = 836,
  1588. AddingWay = 0,
  1589. CreateUserId = dto.UserId,
  1590. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1591. Remark = $"预付款"
  1592. };
  1593. if (ffrInfo == null) //Add
  1594. {
  1595. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1596. }
  1597. else //修改
  1598. {
  1599. await _sqlSugar.Updateable(ffrInfo)
  1600. .UpdateColumns(x => new
  1601. {
  1602. x.PriceName,
  1603. x.Price,
  1604. x.ItemSumPrice,
  1605. x.CreateTime,
  1606. x.CreateUserId
  1607. })
  1608. .WhereColumns(x => x.Id)
  1609. .ExecuteCommandAsync();
  1610. }
  1611. }
  1612. #endregion
  1613. if (diId > 0)
  1614. {
  1615. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1616. }
  1617. // 停止计时
  1618. stopwatch.Stop();
  1619. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1620. }
  1621. catch (Exception ex)
  1622. {
  1623. // 停止计时
  1624. stopwatch.Stop();
  1625. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1626. Logs(ex.Message);
  1627. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1628. }
  1629. // 停止计时
  1630. stopwatch.Stop();
  1631. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1632. }
  1633. /// <summary>
  1634. /// 接团流程操作(增改)
  1635. /// 安卓端使用 建团时添加客户名单
  1636. /// </summary>
  1637. /// <param name="dto"></param>
  1638. /// <returns></returns>
  1639. [HttpPost]
  1640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1641. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1642. {
  1643. #region 参数验证
  1644. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1645. #region 页面操作权限验证
  1646. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1647. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1648. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1649. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1650. #endregion
  1651. #endregion
  1652. try
  1653. {
  1654. //_sqlSugar.BeginTran();
  1655. decimal ffrPrice = 0.00M;
  1656. DateTime? visitDt = null;
  1657. if (dto.Status == 2)
  1658. {
  1659. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1660. if (groupInfo != null)
  1661. {
  1662. ffrPrice = groupInfo.PaymentMoney;
  1663. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1664. }
  1665. }
  1666. var _dto = new GroupOperationDto();
  1667. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1668. var groupData = await _groupRepository.GroupOperation(_dto);
  1669. if (groupData.Code != 0)
  1670. {
  1671. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1672. }
  1673. int diId = 0;
  1674. //添加时 默认加入团组汇率
  1675. if (dto.Status == 1) //添加
  1676. {
  1677. diId = groupData.Data;
  1678. //添加默认币种
  1679. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1680. //默认分配权限
  1681. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1682. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1683. var _managerIds = new List<int>() { 21, 22, 32 };
  1684. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1685. if (userIds.Count > 0)
  1686. {
  1687. userIds.Add(208);
  1688. //创建团组管控
  1689. GroupStepForDelegation.CreateWorkStep(diId);
  1690. //发送消息
  1691. string groupName = dto.TeamName;
  1692. string createGroupUser = string.Empty;
  1693. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1694. if (userInfo != null) createGroupUser = userInfo.CnName;
  1695. string title = $"系统通知";
  1696. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1697. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1698. }
  1699. #region 应用推送
  1700. try
  1701. {
  1702. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1703. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1704. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1705. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1706. {
  1707. var userList = new List<string>() { users.QiyeChatUserId };
  1708. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1709. }
  1710. }
  1711. catch (Exception ex)
  1712. {
  1713. }
  1714. #endregion
  1715. //默认创建倒推表
  1716. await _invertedListRep._Create(dto.UserId, diId);
  1717. //默认创建签证流程
  1718. await _visaProcessRep.Create(dto.UserId, diId);
  1719. //默认创建团组流程总览信息
  1720. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1721. }
  1722. if (dto.Status == 2)
  1723. {
  1724. diId = dto.Id;
  1725. if (diId == 0)
  1726. {
  1727. //_sqlSugar.RollbackTran();
  1728. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1729. }
  1730. }
  1731. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1732. if (viewData.Code != 0)
  1733. {
  1734. //_sqlSugar.RollbackTran();
  1735. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1736. }
  1737. #region 团组操作默认添加/修改收款账单
  1738. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1739. {
  1740. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1741. .Where(x => x.IsDel == 0 &&
  1742. x.Diid == diId &&
  1743. x.Remark.Equals("预付款")
  1744. )
  1745. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1746. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1747. .FirstAsync();
  1748. ffrInfo = new Fin_ForeignReceivables()
  1749. {
  1750. Diid = diId,
  1751. PriceName = dto.ClientUnit,
  1752. Price = dto.PaymentMoney,
  1753. Count = 1,
  1754. Unit = $"元",
  1755. ItemSumPrice = dto.PaymentMoney,
  1756. Rate = 1.0000M,
  1757. Currency = 836,
  1758. AddingWay = 0,
  1759. CreateUserId = dto.UserId,
  1760. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1761. Remark = $"预付款"
  1762. };
  1763. if (ffrInfo == null) //Add
  1764. {
  1765. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1766. }
  1767. else //修改
  1768. {
  1769. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1770. .UpdateColumns(x => new
  1771. {
  1772. x.PriceName,
  1773. x.Price,
  1774. x.ItemSumPrice,
  1775. x.CreateTime,
  1776. x.CreateUserId
  1777. })
  1778. .WhereColumns(x => x.Id)
  1779. .ExecuteCommandAsync();
  1780. }
  1781. }
  1782. #endregion
  1783. #region 签证人员团组时间通知
  1784. #region 计算出访起止时间
  1785. var startTime = new DateTime();
  1786. var endTime = new DateTime();
  1787. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1788. {
  1789. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1790. }
  1791. #endregion
  1792. if (diId > 0)
  1793. {
  1794. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1795. }
  1796. #endregion
  1797. //_sqlSugar.CommitTran();
  1798. return Ok(JsonView(true, "添加成功"));
  1799. }
  1800. catch (Exception ex)
  1801. {
  1802. _sqlSugar.RollbackTran();
  1803. return Ok(JsonView(false, ex.Message));
  1804. }
  1805. }
  1806. /// <summary>
  1807. /// 接团流程操作(增改)
  1808. /// 安卓端使用 建团时添加客户名单
  1809. /// </summary>
  1810. /// <param name="dto"></param>
  1811. /// <returns></returns>
  1812. [HttpPost]
  1813. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1814. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1815. {
  1816. #region 参数验证
  1817. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1818. #region 页面操作权限验证
  1819. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1820. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1821. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1822. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1823. #endregion
  1824. #endregion
  1825. _sqlSugar.BeginTran();
  1826. decimal ffrPrice = 0.00M;
  1827. DateTime? visitDt = null;
  1828. if (dto.Status == 2)
  1829. {
  1830. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1831. if (groupInfo != null)
  1832. {
  1833. ffrPrice = groupInfo.PaymentMoney;
  1834. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1835. }
  1836. }
  1837. var _dto = new GroupOperationDto();
  1838. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1839. var groupData = await _groupRepository.GroupOperation(_dto);
  1840. if (groupData.Code != 0)
  1841. {
  1842. _sqlSugar.RollbackTran();
  1843. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1844. }
  1845. try
  1846. {
  1847. int diId = 0;
  1848. //添加时 默认加入团组汇率
  1849. if (dto.Status == 1) //添加
  1850. {
  1851. diId = groupData.Data;
  1852. //添加默认币种
  1853. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1854. //默认分配权限
  1855. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1856. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1857. var _managerIds = new List<int>() { 21, 22, 32 };
  1858. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1859. if (userIds.Count > 0)
  1860. {
  1861. userIds.Add(208);
  1862. //创建团组管控
  1863. GroupStepForDelegation.CreateWorkStep(diId);
  1864. //发送消息
  1865. string groupName = dto.TeamName;
  1866. string createGroupUser = string.Empty;
  1867. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1868. if (userInfo != null) createGroupUser = userInfo.CnName;
  1869. string title = $"系统通知";
  1870. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1871. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1872. }
  1873. #region 应用推送
  1874. try
  1875. {
  1876. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1877. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1878. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1879. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1880. {
  1881. var userList = new List<string>() { users.QiyeChatUserId };
  1882. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1883. }
  1884. }
  1885. catch (Exception ex)
  1886. {
  1887. _sqlSugar.CommitTran();
  1888. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1889. }
  1890. #endregion
  1891. //默认创建倒推表
  1892. await _invertedListRep._Create(dto.UserId, diId);
  1893. }
  1894. else if (dto.Status == 2)
  1895. {
  1896. diId = dto.Id;
  1897. if (diId == 0)
  1898. {
  1899. _sqlSugar.RollbackTran();
  1900. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1901. }
  1902. }
  1903. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1904. if (viewData.Code != 0)
  1905. {
  1906. _sqlSugar.RollbackTran();
  1907. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1908. }
  1909. #region 团组操作默认添加/修改收款账单
  1910. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1911. {
  1912. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1913. .Where(x => x.IsDel == 0 &&
  1914. x.Diid == diId &&
  1915. x.Remark.Equals("预付款")
  1916. )
  1917. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1918. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1919. .FirstAsync();
  1920. ffrInfo = new Fin_ForeignReceivables()
  1921. {
  1922. Diid = diId,
  1923. PriceName = dto.ClientUnit,
  1924. Price = dto.PaymentMoney,
  1925. Count = 1,
  1926. Unit = $"元",
  1927. ItemSumPrice = dto.PaymentMoney,
  1928. Rate = 1.0000M,
  1929. Currency = 836,
  1930. AddingWay = 0,
  1931. CreateUserId = dto.UserId,
  1932. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1933. Remark = $"预付款"
  1934. };
  1935. if (ffrInfo == null) //Add
  1936. {
  1937. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1938. }
  1939. else //修改
  1940. {
  1941. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1942. .UpdateColumns(x => new
  1943. {
  1944. x.PriceName,
  1945. x.Price,
  1946. x.ItemSumPrice,
  1947. x.CreateTime,
  1948. x.CreateUserId
  1949. })
  1950. .WhereColumns(x => x.Id)
  1951. .ExecuteCommandAsync();
  1952. }
  1953. }
  1954. #endregion
  1955. #region 签证人员团组时间通知
  1956. #region 计算出访起止时间
  1957. var startTime = new DateTime();
  1958. var endTime = new DateTime();
  1959. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1960. {
  1961. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1962. }
  1963. #endregion
  1964. if (diId > 0)
  1965. {
  1966. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1967. }
  1968. #endregion
  1969. _sqlSugar.CommitTran();
  1970. return Ok(JsonView(true));
  1971. }
  1972. catch (Exception ex)
  1973. {
  1974. _sqlSugar.RollbackTran();
  1975. return Ok(JsonView(false, ex.Message));
  1976. }
  1977. }
  1978. /// <summary>
  1979. /// 接团信息 操作(删除)
  1980. /// </summary>
  1981. /// <param name="dto"></param>
  1982. /// <returns></returns>
  1983. [HttpPost]
  1984. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1985. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1986. {
  1987. var diId = dto.Id;
  1988. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1989. #region 删除 验证
  1990. /*
  1991. * 1、收款账单数据:0 条
  1992. * 2、收款退还数据:0 条
  1993. * 3、机票费用数据:0 条
  1994. * 4、签证费用数据:0 条
  1995. * 5、保险费用数据:0 条
  1996. * 6、酒店费用数据:0 条
  1997. * 7、公务出访数据:1 条
  1998. * 8、邀请公务活动费用数据:1 条
  1999. * 9、OP费用数据:5 条
  2000. * 10、其他费用数据:0 条
  2001. * 11、团组日付报销费用数据:0 条
  2002. *
  2003. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  2004. */
  2005. //收款账单
  2006. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  2007. //收款退还
  2008. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2009. //机票费用
  2010. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  2011. //签证费用
  2012. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  2013. //保险费用
  2014. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2015. //酒店费用
  2016. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2017. //公务出访
  2018. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2019. //邀请公务活动费用
  2020. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2021. //OP费用
  2022. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2023. //其他费用
  2024. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2025. //团组日付报销费用
  2026. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  2027. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  2028. if (feeCount > 0)
  2029. {
  2030. var delMsgTips = new StringBuilder();
  2031. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  2032. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  2033. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  2034. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  2035. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  2036. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  2037. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  2038. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  2039. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  2040. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  2041. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  2042. delMsgTips.AppendLine($"");
  2043. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  2044. return Ok(JsonView(false, delMsgTips.ToString()));
  2045. }
  2046. #endregion
  2047. var groupData = await _groupRepository.GroupDel(dto);
  2048. if (groupData.Code != 0)
  2049. {
  2050. return Ok(JsonView(false, groupData.Msg));
  2051. }
  2052. return Ok(JsonView(true));
  2053. }
  2054. /// <summary>
  2055. /// 获取团组销售报价号
  2056. /// 团组添加时 使用
  2057. /// </summary>
  2058. /// <returns></returns>
  2059. [HttpPost]
  2060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2061. public async Task<IActionResult> GetGroupSalesQuoteNo()
  2062. {
  2063. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  2064. if (groupData.Code != 0)
  2065. {
  2066. return Ok(JsonView(false, groupData.Msg));
  2067. }
  2068. object salesQuoteNo = new
  2069. {
  2070. SalesQuoteNo = groupData.Data
  2071. };
  2072. return Ok(JsonView(salesQuoteNo));
  2073. }
  2074. /// <summary>
  2075. /// 设置确认出团
  2076. /// </summary>
  2077. /// <param name="dto"></param>
  2078. /// <returns></returns>
  2079. [HttpPost]
  2080. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2081. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  2082. {
  2083. var groupData = await _groupRepository.ConfirmationGroup(dto);
  2084. if (groupData.Code != 0)
  2085. {
  2086. return Ok(JsonView(false, groupData.Msg));
  2087. }
  2088. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  2089. #region OA消息推送
  2090. try
  2091. {
  2092. string groupName = groupInfo.TeamName;
  2093. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  2094. string title = $"系统通知";
  2095. string content = $"团组[{groupName}]已确认出团!";
  2096. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  2097. }
  2098. catch (Exception ex)
  2099. {
  2100. }
  2101. #endregion
  2102. #region 应用推送
  2103. try
  2104. {
  2105. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  2106. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  2107. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  2108. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  2109. {
  2110. var userList = new List<string>() { users.QiyeChatUserId };
  2111. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  2112. }
  2113. }
  2114. catch (Exception ex)
  2115. {
  2116. }
  2117. #endregion
  2118. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  2119. return Ok(JsonView(true, "操作成功!", groupData.Data));
  2120. }
  2121. /// <summary>
  2122. /// 获取团组名称data And 签证国别Data
  2123. /// </summary>
  2124. /// <param name="dto"></param>
  2125. /// <returns></returns>
  2126. [HttpPost]
  2127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2128. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  2129. {
  2130. var groupData = await _groupRepository.GetGroupNameAndVisaNationality(dto);
  2131. if (groupData.Code != 0)
  2132. {
  2133. return Ok(JsonView(false, groupData.Msg));
  2134. }
  2135. return Ok(JsonView(groupData.Data));
  2136. }
  2137. /// <summary>
  2138. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  2139. /// </summary>
  2140. /// <returns></returns>
  2141. [HttpPost]
  2142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2143. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  2144. {
  2145. try
  2146. {
  2147. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  2148. if (groupData.Code != 0)
  2149. {
  2150. return Ok(JsonView(false, groupData.Msg));
  2151. }
  2152. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2153. }
  2154. catch (Exception ex)
  2155. {
  2156. return Ok(JsonView(false, ex.Message));
  2157. throw;
  2158. }
  2159. }
  2160. /// <summary>
  2161. /// 团组清单 Excel
  2162. /// </summary>
  2163. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  2164. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  2165. /// <returns></returns>
  2166. [HttpGet]
  2167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2168. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  2169. {
  2170. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  2171. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  2172. if (!beginBool && !endBool)
  2173. {
  2174. return Ok(JsonView(false, "开始或结束时间不正确!"));
  2175. }
  2176. string sql = string.Format(@"
  2177. SELECT
  2178. ROW_NUMBER,
  2179. Id,
  2180. SalesQuoteNo,
  2181. TourCode,
  2182. TeamTypeId,
  2183. TeamType,
  2184. TeamLevId,
  2185. TeamLev,
  2186. TeamName,
  2187. ClientName,
  2188. ClientUnit,
  2189. VisitDate,
  2190. VisitDays,
  2191. VisitPNumber,
  2192. JietuanOperatorId,
  2193. JietuanOperator,
  2194. IsSure,
  2195. CreateUserName,
  2196. IsBid
  2197. FROM
  2198. (
  2199. SELECT
  2200. ROW_NUMBER() OVER(
  2201. ORDER BY
  2202. gdi.VisitDate Desc
  2203. ) AS ROW_NUMBER,
  2204. gdi.Id,
  2205. SalesQuoteNo,
  2206. TourCode,
  2207. ssd.Id TeamTypeId,
  2208. ssd.Name TeamType,
  2209. ssd1.Id TeamLevId,
  2210. ssd1.Name TeamLev,
  2211. TeamName,
  2212. ClientName,
  2213. ClientUnit,
  2214. VisitDate,
  2215. VisitDays,
  2216. VisitPNumber,
  2217. JietuanOperator JietuanOperatorId,
  2218. su.CnName JietuanOperator,
  2219. IsSure,
  2220. gdi.CreateTime,
  2221. su1.CnName As CreateUserName,
  2222. gdi.IsBid
  2223. FROM
  2224. Grp_DelegationInfo gdi
  2225. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  2226. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  2227. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  2228. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  2229. WHERE
  2230. gdi.IsDel = 0
  2231. AND gdi.IsBid = 0
  2232. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  2233. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  2234. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  2235. #region 处理所属部门
  2236. /*
  2237. * 1.sq 和 gyy 等显示 市场部
  2238. * 2.王鸽和主管及张总还有管理员号统一国交部
  2239. * 2-1. 4 管理员 ,21 张海麟
  2240. */
  2241. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  2242. var userIds1 = new List<int>() { 4, 21 };
  2243. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  2244. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  2245. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  2246. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  2247. .ToListAsync();
  2248. var droupIds = groupList.Select(it => it.Id).ToList();
  2249. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  2250. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  2251. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  2252. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  2253. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  2254. {
  2255. DiId = tcl.DiId,
  2256. LastName = dc.LastName,
  2257. FirstName = dc.FirstName,
  2258. Sex = dc.Sex,
  2259. Birthday = dc.BirthDay,
  2260. Company = cc.CompanyFullName,
  2261. Job = dc.Job,
  2262. CreateTime = tcl.CreateTime,
  2263. })
  2264. .ToList();
  2265. foreach (var item in groupList)
  2266. {
  2267. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  2268. string groupFirstName = "";
  2269. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  2270. if (currDatas.Any())
  2271. {
  2272. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  2273. }
  2274. item.GroupFirst = groupFirstName;
  2275. }
  2276. #endregion
  2277. #region Excel
  2278. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  2279. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  2280. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  2281. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  2282. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  2283. //载入模板
  2284. var designer = new WorkbookDesigner
  2285. {
  2286. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  2287. };
  2288. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  2289. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  2290. dt.TableName = "GroupList";
  2291. designer.SetDataSource(dt);
  2292. designer.Process();
  2293. if (!Directory.Exists(savePath))
  2294. {
  2295. Directory.CreateDirectory(savePath);
  2296. }
  2297. string serverPath = $"{savePath}{fileName}";
  2298. designer.Workbook.Save(serverPath);
  2299. string rst = $"{servicePath}{ftpPath}{fileName}";
  2300. #endregion
  2301. return Ok(JsonView(true, "操作成功!", rst));
  2302. }
  2303. /// <summary>
  2304. /// 团组合同下载(1.付款80% 2.付全款)
  2305. /// </summary>
  2306. /// <param name="dto"></param>
  2307. /// <returns></returns>
  2308. /// <exception cref="Exception"></exception>
  2309. [HttpPost]
  2310. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  2311. {
  2312. var jw = JsonView(false);
  2313. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  2314. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  2315. if (di == null)
  2316. {
  2317. jw.Msg = "团组Id有误!";
  2318. return Ok(jw);
  2319. }
  2320. #region 权限校验
  2321. var allDownFile = new List<int>() { 21 };
  2322. try
  2323. {
  2324. var setting = _sqlSugar.Queryable<Sys_SetData>()
  2325. .First(x => x.Id == 1418 && x.IsDel == 0);
  2326. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  2327. }
  2328. catch (Exception)
  2329. { }
  2330. var guojiaoDownFile = new List<int>() { 330, 383 };
  2331. var shichangDownFile = new List<int>() { 95 };
  2332. if (allDownFile.Contains(dto.UserId))
  2333. {
  2334. }
  2335. else if (guojiaoDownFile.Contains(dto.UserId))
  2336. {
  2337. var guojiaobuDi = new List<int>() { 4, 21 };
  2338. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  2339. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  2340. .Where((d, u) => u.Id == di.JietuanOperator)
  2341. .Select((d, u) => d.DepName)
  2342. .First();
  2343. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  2344. {
  2345. jw.Msg = "暂无下载权限!";
  2346. return Ok(jw);
  2347. }
  2348. }
  2349. else if (shichangDownFile.Contains(dto.UserId))
  2350. {
  2351. var dic = new Dictionary<int, int[]>()
  2352. {
  2353. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  2354. };
  2355. try
  2356. {
  2357. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  2358. if (sqSetting != null)
  2359. {
  2360. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  2361. foreach (var item in result.Keys)
  2362. {
  2363. if (dic.ContainsKey(item))
  2364. {
  2365. int[] dilatation = new int[dic[item].Length + result[item].Length];
  2366. Array.Copy(dic[item], dilatation, dic[item].Length);
  2367. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  2368. dic[item] = dilatation;
  2369. }
  2370. else
  2371. {
  2372. dic.Add(item, result[item]);
  2373. }
  2374. }
  2375. }
  2376. if (!dic[95].Contains(di.CreateUserId))
  2377. {
  2378. jw.Msg = "暂无下载权限!";
  2379. return Ok(jw);
  2380. }
  2381. }
  2382. catch (Exception)
  2383. { }
  2384. }
  2385. else if (dto.UserId == di.CreateUserId)
  2386. {
  2387. }
  2388. else
  2389. {
  2390. jw.Msg = "暂无下载权限!";
  2391. return Ok(jw);
  2392. }
  2393. #endregion
  2394. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  2395. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  2396. .ToListAsync();
  2397. if (!blackCodeList.Any())
  2398. {
  2399. jw.Msg = "该团无机票行程代码!";
  2400. return Ok(jw);
  2401. }
  2402. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  2403. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  2404. if (groupEnterExitCost == null)
  2405. {
  2406. jw.Msg = "暂无三公费用信息!";
  2407. return Ok(jw);
  2408. }
  2409. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  2410. rateList ??= new List<CurrencyInfo>();
  2411. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  2412. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  2413. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  2414. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  2415. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  2416. .Select((x, a, b) => new
  2417. {
  2418. x.Index,
  2419. itemName = a.Name,
  2420. CurrencyStr = b.Name,
  2421. x.Cost,
  2422. x.SubTotal,
  2423. x.Remark
  2424. })
  2425. .OrderBy((x) => x.Index)
  2426. .ToList();
  2427. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  2428. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  2429. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  2430. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  2431. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  2432. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  2433. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  2434. decimal subJJC = 0.00M,
  2435. subGWC = 0.00M,
  2436. subTDC = 0.00M;
  2437. //经济舱
  2438. if (groupEnterExitCost.SumJJC == 1)
  2439. {
  2440. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  2441. }
  2442. //公务舱
  2443. if (groupEnterExitCost.SumGWC == 1)
  2444. {
  2445. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  2446. }
  2447. //头等舱
  2448. if (groupEnterExitCost.SumTDC == 1)
  2449. {
  2450. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  2451. }
  2452. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  2453. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  2454. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  2455. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2456. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2457. .Select((x, s, dc, cc) => new GroupClints
  2458. {
  2459. Id = x.Id,
  2460. Name = s.Name,
  2461. IsAccompany = x.IsAccompany,
  2462. CompanyFullName = cc.CompanyFullName
  2463. })
  2464. .ToListAsync();
  2465. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2466. //获取舱位人数
  2467. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2468. .GroupBy(x => x.Name)
  2469. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2470. .ToList();
  2471. string cityPath = string.Empty;
  2472. string startCity = string.Empty;
  2473. string endCity = string.Empty;
  2474. foreach (var item in blackCodeList)
  2475. {
  2476. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2477. cityPath += city + "\r\n";
  2478. if (item.Equals(blackCodeList.First()))
  2479. {
  2480. var sp = city.Split('-');
  2481. startCity = sp[0];
  2482. endCity = sp[^1];
  2483. }
  2484. }
  2485. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2486. var bookMarkDic = new Dictionary<string, string>
  2487. {
  2488. { "ClientUnit", di.ClientUnit },
  2489. { "VisitCountry", di.VisitCountry },
  2490. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2491. { "VisitPNumber", di.VisitPNumber.ToString() },
  2492. { "CityPath", cityPath },
  2493. { "StartCity", startCity },
  2494. { "EndCity", endCity },
  2495. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2496. };
  2497. Document doc = null;
  2498. var percentage = 0.8M;
  2499. var fileNameadd = "预付";
  2500. if (dto.FileType == 1)
  2501. {
  2502. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2503. }
  2504. else if (dto.FileType == 2)
  2505. {
  2506. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2507. percentage = 1;
  2508. fileNameadd = "全款";
  2509. }
  2510. else
  2511. {
  2512. throw new Exception("FileType有误!");
  2513. }
  2514. var builder = new DocumentBuilder(doc);
  2515. decimal totalPrice = 0.00M;
  2516. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2517. if (firstTable != null)
  2518. {
  2519. // 遍历表格的行和单元格
  2520. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2521. {
  2522. for (int i = 0; i < row.Cells.Count; i++)
  2523. {
  2524. var cell = row.Cells[i];
  2525. // 读取单元格内容
  2526. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2527. if (cellTextFirst.Contains("舱位"))
  2528. {
  2529. break;
  2530. }
  2531. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2532. {
  2533. if (i == 2)
  2534. {
  2535. if (cellTextFirst == "经济舱")
  2536. {
  2537. // 设置单元格内容
  2538. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2539. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2540. }
  2541. else
  2542. {
  2543. // 设置单元格内容
  2544. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2545. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2546. }
  2547. }
  2548. if (i == 3)
  2549. {
  2550. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2551. if (count != null)
  2552. {
  2553. // 设置单元格内容
  2554. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2555. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2556. }
  2557. }
  2558. if (i == 4)
  2559. {
  2560. var rowPrice = 0.00M;
  2561. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2562. count ??= 0;
  2563. if (cellTextFirst == "经济舱")
  2564. {
  2565. rowPrice = subJJC * (int)count;
  2566. }
  2567. else
  2568. {
  2569. rowPrice = subGWC * (int)count;
  2570. }
  2571. totalPrice += rowPrice;
  2572. // 设置单元格内容
  2573. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2574. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2575. }
  2576. }
  2577. }
  2578. }
  2579. }
  2580. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2581. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2582. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2583. //--合同表格部分
  2584. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2585. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2586. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2587. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2588. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2589. bookMarkDic.Add("CityPath1", cityPath);
  2590. bookMarkDic.Add("CityPath2", cityPath);
  2591. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2592. if (contractTable != null)
  2593. {
  2594. //数据源
  2595. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2596. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2597. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2598. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2599. .Select((it, y, s) => new
  2600. {
  2601. it.Cost,
  2602. it.SubTotal,
  2603. it.Type,
  2604. y.Id,
  2605. y.City,
  2606. s.Name,
  2607. CurrencyCodeCn = s.Remark
  2608. })
  2609. .ToList()
  2610. .Select(x => new
  2611. {
  2612. CurrencyCode = x.Name,
  2613. CityId = x.Id,
  2614. x.City,
  2615. di.VisitPNumber,
  2616. x.Type,
  2617. x.Cost,
  2618. x.SubTotal,
  2619. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2620. x.CurrencyCodeCn,
  2621. });
  2622. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2623. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2624. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2625. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2626. var tableSettings = new List<tableSetting>()
  2627. {
  2628. new(){ Index = 1 , Property = "City"},
  2629. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2630. new(){ Index = 3 , Property = "Cost"},
  2631. new(){ Index = 4 , Property = "VisitPNumber"},
  2632. //new tableSetting{ Index = 5 , Property = ""},
  2633. //new tableSetting{ Index = 6 , Property = ""},
  2634. new(){ Index = 7 , Property = "Rate"},
  2635. //new tableSetting{ Index = 8 , Property = ""},
  2636. };
  2637. //1.住宿费
  2638. int cloneRow = 8;
  2639. int startDayPrice = 8; //写入index
  2640. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2641. foreach (var dac in dac1)
  2642. {
  2643. var first = dac.First();
  2644. var dayCount = dac.Count();
  2645. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2646. for (int i = 1; i < row.Cells.Count; i++)
  2647. {
  2648. var cell = row.Cells[i];
  2649. var findProperty = tableSettings.Find(x => x.Index == i);
  2650. if (findProperty != null)
  2651. {
  2652. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2653. // 设置单元格内容
  2654. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2655. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2656. }
  2657. else
  2658. {
  2659. switch (i)
  2660. {
  2661. case 5:
  2662. cell.FirstParagraph.Runs.Clear();
  2663. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2664. break;
  2665. case 6:
  2666. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2667. cell.FirstParagraph.Runs.Clear();
  2668. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2669. break;
  2670. case 8:
  2671. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2672. cell.FirstParagraph.Runs.Clear();
  2673. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2674. ZSPriceSum += xiaojiRMB;
  2675. break;
  2676. default:
  2677. break;
  2678. }
  2679. }
  2680. }
  2681. startDayPrice++;
  2682. if (!dac1.Last().Equals(dac))
  2683. {
  2684. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2685. // 将克隆的行追加到原行后面
  2686. contractTable.Rows.Insert(startDayPrice, newRow);
  2687. }
  2688. else
  2689. {
  2690. cloneRow += dac1.Count + 1;
  2691. startDayPrice = cloneRow;
  2692. }
  2693. }
  2694. //2.伙食费
  2695. foreach (var dac in dac2)
  2696. {
  2697. var first = dac.First();
  2698. var dayCount = dac.Count();
  2699. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2700. for (int i = 1; i < row.Cells.Count; i++)
  2701. {
  2702. var cell = row.Cells[i];
  2703. var findProperty = tableSettings.Find(x => x.Index == i);
  2704. if (findProperty != null)
  2705. {
  2706. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2707. // 设置单元格内容
  2708. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2709. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2710. }
  2711. else
  2712. {
  2713. switch (i)
  2714. {
  2715. case 5:
  2716. cell.FirstParagraph.Runs.Clear();
  2717. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2718. break;
  2719. case 6:
  2720. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2721. cell.FirstParagraph.Runs.Clear();
  2722. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2723. break;
  2724. case 8:
  2725. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2726. cell.FirstParagraph.Runs.Clear();
  2727. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2728. HSPriceSum += xiaojiRMB;
  2729. break;
  2730. default:
  2731. break;
  2732. }
  2733. }
  2734. }
  2735. startDayPrice++;
  2736. if (!dac2.Last().Equals(dac))
  2737. {
  2738. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2739. // 将克隆的行追加到原行后面
  2740. contractTable.Rows.Insert(startDayPrice, newRow);
  2741. }
  2742. else
  2743. {
  2744. cloneRow += dac2.Count + 1;
  2745. startDayPrice = cloneRow;
  2746. }
  2747. }
  2748. //3.公杂费
  2749. foreach (var dac in dac3)
  2750. {
  2751. var first = dac.First();
  2752. var dayCount = dac.Count();
  2753. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2754. for (int i = 1; i < row.Cells.Count; i++)
  2755. {
  2756. var cell = row.Cells[i];
  2757. var findProperty = tableSettings.Find(x => x.Index == i);
  2758. if (findProperty != null)
  2759. {
  2760. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2761. // 设置单元格内容
  2762. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2763. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2764. }
  2765. else
  2766. {
  2767. switch (i)
  2768. {
  2769. case 5:
  2770. cell.FirstParagraph.Runs.Clear();
  2771. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2772. break;
  2773. case 6:
  2774. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2775. cell.FirstParagraph.Runs.Clear();
  2776. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2777. break;
  2778. case 8:
  2779. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2780. cell.FirstParagraph.Runs.Clear();
  2781. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2782. GZPriceSum += xiaojiRMB;
  2783. break;
  2784. default:
  2785. break;
  2786. }
  2787. }
  2788. }
  2789. startDayPrice++;
  2790. if (!dac3.Last().Equals(dac))
  2791. {
  2792. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2793. // 将克隆的行追加到原行后面
  2794. contractTable.Rows.Insert(startDayPrice, newRow);
  2795. }
  2796. else
  2797. {
  2798. cloneRow += dac3.Count + 1;
  2799. startDayPrice = cloneRow;
  2800. }
  2801. }
  2802. //合并单元格
  2803. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2804. {
  2805. var currentRow = contractTable.Rows[i];
  2806. var nextRow = contractTable.Rows[i + 1];
  2807. // 获取当前行和下一行的第一个单元格
  2808. Cell currentCell = currentRow.Cells[0];
  2809. Cell nextCell = nextRow.Cells[0];
  2810. // 检查单元格内容是否一致(去除尾部的换行符)
  2811. string currentText = currentCell.GetText().Trim();
  2812. string nextText = nextCell.GetText().Trim();
  2813. if (currentText == nextText)
  2814. {
  2815. // 如果当前单元格已经被合并,找到合并的起始单元格
  2816. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2817. {
  2818. // 找到合并的起始单元格
  2819. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2820. // 将下一行的单元格设置为合并的后续单元格
  2821. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2822. }
  2823. else
  2824. {
  2825. // 如果当前单元格是合并的起始单元格
  2826. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2827. // 将下一行的单元格设置为合并的后续单元格
  2828. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2829. }
  2830. }
  2831. else
  2832. {
  2833. // 如果内容不一致,重置当前单元格的合并属性
  2834. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2835. {
  2836. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2837. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2838. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2839. }
  2840. else
  2841. {
  2842. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2843. }
  2844. }
  2845. }
  2846. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2847. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2848. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2849. }
  2850. foreach (var bookmarkName in bookMarkDic.Keys)
  2851. {
  2852. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2853. if (bookmark != null)
  2854. {
  2855. if (bookmarkName == "ClientUnit")
  2856. {
  2857. // 移动到书签位置
  2858. builder.MoveTo(bookmark.BookmarkStart);
  2859. // 设置字体样式为下划线
  2860. builder.Font.Underline = Aspose.Words.Underline.Single;
  2861. // 插入书签值
  2862. builder.Write(bookMarkDic[bookmarkName]);
  2863. // 清除字体格式,避免影响后续文本
  2864. builder.Font.ClearFormatting();
  2865. }
  2866. else
  2867. {
  2868. builder.MoveToBookmark(bookmarkName);
  2869. builder.Write(bookMarkDic[bookmarkName]);
  2870. }
  2871. }
  2872. }
  2873. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2874. doc.Save(savePaht);
  2875. jw.Msg = "生成成功!";
  2876. jw.Code = 200;
  2877. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2878. return Ok(jw);
  2879. }
  2880. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2881. {
  2882. int index = rowIndex;
  2883. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2884. {
  2885. index--;
  2886. }
  2887. return index;
  2888. }
  2889. /// <summary>
  2890. /// 报批完成企微通知
  2891. /// </summary>
  2892. /// <param name="dto"></param>
  2893. /// <returns></returns>
  2894. [HttpPost]
  2895. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2896. {
  2897. int currUserId = dto.currUserId;
  2898. int diid = dto.diid;
  2899. var jw = JsonView(true);
  2900. var users = new List<string>();
  2901. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2902. .First(x => x.Id == 1460);
  2903. try
  2904. {
  2905. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2906. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2907. //添加分配人员
  2908. // 79 车/导游地接
  2909. // 80 签证
  2910. // 81 邀请/公务活动
  2911. var setdataids = new List<int>() { 79, 81 };
  2912. foreach (var groupModule in groupModuleOperators)
  2913. {
  2914. if (setdataids.Contains(groupModule.CTableId))
  2915. {
  2916. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2917. }
  2918. }
  2919. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2920. //消息通知成功 更改团组step、记录日志
  2921. if (res)
  2922. {
  2923. var groupStep = 0; //0-新建 1-企微消息通知
  2924. //更改团组step
  2925. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2926. .SetColumns(x => new Grp_DelegationInfo()
  2927. {
  2928. Step = 2,
  2929. StepOperationTime = DateTime.Now
  2930. })
  2931. .Where(x => x.Id == diid && x.IsDel == 0)
  2932. .ExecuteCommandAsync();
  2933. if (updStatus > 0) groupStep = 2;
  2934. string groupStepLabel = groupStep switch
  2935. {
  2936. 1 => "新建",
  2937. 2 => "企微消息通知(报批)",
  2938. _ => "未设置"
  2939. };
  2940. //记录日志
  2941. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2942. .Where(x => x.Id == diid && x.IsDel == 0)
  2943. .Select(x => x.TeamName)
  2944. .First() ?? "-";
  2945. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2946. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2947. .Select(x => x.CnName)
  2948. .First() ?? "-";
  2949. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2950. //设置 签证流程初始值
  2951. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2952. }
  2953. }
  2954. catch (Exception ex)
  2955. {
  2956. return Ok(JsonView(false, ex.Message));
  2957. }
  2958. return Ok(jw);
  2959. }
  2960. #endregion
  2961. #region 团组&签证
  2962. #region 团组&签证 New
  2963. /// <summary>
  2964. /// 团组&签证 New
  2965. /// DeepSeek API:测试API连通性
  2966. /// </summary>
  2967. /// <param name="file">请求dto</param>
  2968. /// <returns></returns>
  2969. [HttpPost]
  2970. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2971. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2972. {
  2973. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2974. }
  2975. /// <summary>
  2976. /// 团组&签证 New
  2977. /// DeepSeek API:检查可用端点
  2978. /// </summary>
  2979. /// <param name="file">请求dto</param>
  2980. /// <returns></returns>
  2981. [HttpPost]
  2982. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2983. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2984. {
  2985. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2986. }
  2987. /// <summary>
  2988. /// 团组&签证 New
  2989. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2990. /// </summary>
  2991. /// <param name="visaFile">文件</param>
  2992. /// <param name="fileTypeId">
  2993. /// 1. 澳新签证个人申请表
  2994. /// 2. 出国个人申请表
  2995. /// 3. 美国签证个人申请表格
  2996. /// 4. 沙特个人信息表格
  2997. /// 5. 申根签证个人资料表
  2998. /// 6. 中文个人简历模板
  2999. /// </param>
  3000. /// <returns></returns>
  3001. [HttpPost]
  3002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3003. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  3004. {
  3005. //文件验证
  3006. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3007. //var visaFiles = new VisaUploadFileTypeView();
  3008. //var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  3009. //if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  3010. //服务器存储文件
  3011. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  3012. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  3013. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  3014. using (var stream = new FileStream(filePath, FileMode.Create))
  3015. {
  3016. await visaFile.CopyToAsync(stream);
  3017. }
  3018. //日志记录-上传文件
  3019. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  3020. #region 上传文件到DeepSeekAPI
  3021. //IFormFile localFile = null;
  3022. ////获取项目中的cs文件
  3023. //try
  3024. //{
  3025. // _logger.LogInformation("读取并上传项目文件请求");
  3026. // // 1. 读取项目文件
  3027. // var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  3028. // if (readResponse.SuccessCount == 0)
  3029. // {
  3030. // return Ok(JsonView(false, "读取项目文件失败"));
  3031. // }
  3032. // localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  3033. //}
  3034. //catch (Exception ex)
  3035. //{
  3036. // _logger.LogError(ex, "读取项目文件失败");
  3037. // return Ok(JsonView(false, "读取项目文件失败"));
  3038. //}
  3039. //if (localFile == null)
  3040. //{
  3041. // return Ok(JsonView(false, "读取项目文件失败"));
  3042. //}
  3043. //var fileReq = new DeepSeekFileUploadRequest()
  3044. //{
  3045. // Files = new List<IFormFile> { localFile, visaFile },
  3046. //};
  3047. //var filesResult = new List<FileUploadResult>();
  3048. //try
  3049. //{
  3050. // _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  3051. // filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  3052. // // 需要等待处理完成
  3053. // if (fileReq.WaitForProcessing)
  3054. // {
  3055. // foreach (var result in filesResult)
  3056. // {
  3057. // if (result.Success)
  3058. // {
  3059. // try
  3060. // {
  3061. // var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  3062. // result.Status = processedFile.Status;
  3063. // }
  3064. // catch (Exception ex)
  3065. // {
  3066. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  3067. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  3068. // }
  3069. // }
  3070. // }
  3071. // }
  3072. //}
  3073. //catch (Exception ex)
  3074. //{
  3075. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  3076. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  3077. //}
  3078. //#endregion
  3079. //if (filesResult == null || filesResult.Count < 1)
  3080. //{
  3081. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  3082. //}
  3083. ////
  3084. //try
  3085. //{
  3086. // var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  3087. // _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  3088. // string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  3089. // var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  3090. // return Ok(response);
  3091. //}
  3092. //catch (Exception ex)
  3093. //{
  3094. // _logger.LogError(ex, "使用文件聊天失败");
  3095. // return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  3096. //}
  3097. #endregion
  3098. #region kimi API
  3099. //加载文件OpCarTouristGuideGroundContent
  3100. //kimi AI 识别文档返回json结果
  3101. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  3102. var KiMiApi = new KiMiApiClient();
  3103. var files = new List<IFormFile>() { visaFile };
  3104. var seedConter = await KiMiApi.UploadFilesAsync(files);
  3105. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  3106. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  3107. var seedMessage = string.Format(@"你是领事馆电子材料审核员,只关注 Word 里的表格,正文、页眉页脚、水印、批注全部忽略。
  3108. 任务:把表格里的每个可填字段转换成“标题:值”的键值对,标题用原文,值用原文,不翻译。
  3109. 规则如下:
  3110. 1. 行列对齐:先按视觉补齐所有合并单元格——纵向合并则重复上方单元格内容,横向合并则留空字符串;无线表按对齐虚拟列线。
  3111. 2. 单格内出现多个“□”时,把被勾选(☑、√、×、■)的选项原文输出;若没有任何勾选,该字段输出 null。
  3112. 3. 所有日期统一转 yyyy-mm-dd,原格式“1990年1月1日”→1990-01-01;若缺日/月,用-01补位。
  3113. 4. 电话、传真、手机号:输出连续数字,遇到“(0 )”或“-”一律删除,只保留 7~15 位数字;若缺区号,原样保留。
  3114. 5. 金额:保留原数字,如“3000”。
  3115. 6. 地址:省、市、区、街道、门牌、邮编用空格分隔,不省略。
  3116. 7. 若同一张表出现“现住址”“家庭地址”“单位地址”等多列,依次编号 address_home / address_unit / address_legal。
  3117. 8. 输出顺序:按表格从左到右、从上到下逐行扫描,字段名重复时加序号,如 child_name_1、child_name_2。
  3118. 9. 结果格式:每行一个键值对,字段名与值之间用英文冒号+空格分隔,不要表格 Markdown,不要多余说明。
  3119. 10. 文件命名空间:每份表的最前面加一行 filename 作为起始标记(例:出国个人申请表.doc)。
  3120. 11. 内容为空的字段,显示标题,记空值。
  3121. 12. 只返回json结果,不需要其他内容;json内容去掉换行。");
  3122. var messages = new List<SeedMessages>
  3123. {
  3124. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  3125. new() { Role = KimiRole.user, Content = seedMessage }
  3126. };
  3127. messages.InsertRange(1, seedConter);
  3128. string jsonString = string.Empty;
  3129. object jsonData = null;
  3130. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  3131. while (!isJson)
  3132. {
  3133. kimiAI_API_Index++;
  3134. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  3135. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3136. jsonString += kimiApiResult_JObject["content"].ToString();
  3137. string startStr = "```json", endStr = "```";
  3138. // 判断并清除开头部分
  3139. if (jsonString.StartsWith(startStr))
  3140. {
  3141. jsonString = jsonString.Replace(startStr, "");
  3142. }
  3143. // 判断并清除结尾部分
  3144. if (jsonString.EndsWith(endStr))
  3145. {
  3146. jsonString = jsonString.Replace(endStr, "");
  3147. }
  3148. //验证json格式是否正确
  3149. try
  3150. {
  3151. jsonData = JsonDocument.Parse(jsonString);
  3152. isJson = true; // 如果解析成功,则是json格式
  3153. }
  3154. catch (Exception)
  3155. {
  3156. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  3157. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  3158. }
  3159. }
  3160. if (jsonData == null)
  3161. {
  3162. return Ok(JsonView(false, "kimi识别json转换失败。"));
  3163. }
  3164. var visaDetails = new VisaDetailsView();
  3165. //按照表格类型分别进行参数处理
  3166. // 1. 澳新签证个人申请表
  3167. // 2. 出国个人申请表
  3168. // 3. 美国签证个人申请表格
  3169. // 4. 沙特个人信息表格
  3170. // 5. 申根签证个人资料表
  3171. // 6. 中文个人简历模板
  3172. switch (fileTypeId)
  3173. {
  3174. //澳新签证个人申请表
  3175. case 1:
  3176. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3177. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  3178. break;
  3179. //美国签证个人申请表格
  3180. case 3:
  3181. _logger.LogInformation("【签证上传文件操作信息】【美国签证个人申请表格】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3182. string name = (string)jsonData.GetType().GetProperty("姓名")!.GetValue(jsonData)!;
  3183. string passportNo = (string)jsonData.GetType().GetProperty("护照号码")!.GetValue(jsonData)!;
  3184. string passportPlace = (string)jsonData.GetType().GetProperty("护照签发地")!.GetValue(jsonData)!;
  3185. string idNo = (string)jsonData.GetType().GetProperty("身份证号码")!.GetValue(jsonData)!;
  3186. string maritalStatusText = (string)jsonData.GetType().GetProperty("婚姻状况")!.GetValue(jsonData)!;
  3187. int maritalStatus = maritalStatusText switch
  3188. {
  3189. "未设置" => 0,
  3190. "未婚" => 1,
  3191. "已婚" => 2,
  3192. "离异" => 3,
  3193. "丧偶" => 4,
  3194. _ => -1
  3195. };
  3196. string birthDay = (string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!;
  3197. DateTime.TryParse(birthDay, out DateTime birthDayDt);
  3198. string birthPlace = (string)jsonData.GetType().GetProperty("出生地点")!.GetValue(jsonData)!;
  3199. var birthDay1 = CommonFun.SplitProvinceCity(birthPlace);
  3200. string birthDay_mate = (string)jsonData.GetType().GetProperty("配偶出生日期")!.GetValue(jsonData)!;
  3201. DateTime.TryParse(birthDay_mate, out DateTime birthDayDt_mate);
  3202. string birthPlace_mate = (string)jsonData.GetType().GetProperty("配偶出生地")!.GetValue(jsonData)!;
  3203. var birthDay1_mate = CommonFun.SplitProvinceCity(birthPlace_mate);
  3204. var addressText = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3205. var address = SplitAddressZip(addressText);
  3206. //美国驾照信息
  3207. string driveText = (string)jsonData.GetType().GetProperty("是否有美国驾照")!.GetValue(jsonData)!;
  3208. var driveInfo = LicenseParser(driveText);
  3209. //美国社会安全号或者纳税ID号
  3210. string ssnText = (string)jsonData.GetType().GetProperty("是否有美国社会安全号或者纳税ID号")!.GetValue(jsonData)!;
  3211. //单位信息
  3212. string clientName = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校")!.GetValue(jsonData)!;
  3213. string clientAddr = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校地址")!.GetValue(jsonData)!;//
  3214. var (hasSsnItin, number) = SsnItinParser(ssnText);
  3215. //婚姻相关
  3216. var WeddingText = (string)jsonData.GetType().GetProperty("若离婚,婚姻起止时间")!.GetValue(jsonData)!;
  3217. var (f, t) = WeddingParser(WeddingText);
  3218. //美国联系人电话和邮箱
  3219. var peText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  3220. var usa_phone = Regex.Match(peText ?? "", @"[\d-]+").Value; // 数字和中横线
  3221. var usa_email = Regex.Match(peText ?? "", @"[^@\s]+@[^@\s]+\.[^@\s]+").Value;
  3222. //赴美时间、停留时间处理
  3223. var usa_dateText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  3224. var (usa_d, usa_days) = TravelParser(usa_dateText);
  3225. //赴美同行人
  3226. string usaCmpNameText = (string)jsonData.GetType().GetProperty("赴美同行人")!.GetValue(jsonData)!;
  3227. string usaCmpName = string.Empty;
  3228. if (usaCmpNameText.Contains("是"))
  3229. {
  3230. var usaCmpNameTextSplit = usaCmpNameText.Replace(":", "-").Replace("", "-").Split("-");
  3231. if (usaCmpNameTextSplit.Length > 1)
  3232. {
  3233. usaCmpName = usaCmpNameTextSplit[1];
  3234. }
  3235. }
  3236. //是否丢失过护照
  3237. string loseCodeText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  3238. string loseCode = string.Empty;
  3239. if (loseCodeText.Contains("是"))
  3240. {
  3241. var loseCodeTextSplit = loseCodeText.Replace(":", "-").Replace("", "-").Split("-");
  3242. if (loseCodeTextSplit.Length > 1)
  3243. {
  3244. usaCmpName = loseCodeTextSplit[1];
  3245. }
  3246. }
  3247. //是否获得过美国签证
  3248. string usaVisaText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  3249. string usaVisaDateText = (string)jsonData.GetType().GetProperty("获得日期")!.GetValue(jsonData)!;
  3250. //DateTime usaVisaDate;
  3251. if (!string.IsNullOrEmpty(usaVisaDateText))
  3252. {
  3253. if (DateTime.TryParse(usaVisaDateText, out DateTime usaVisaDate))
  3254. {
  3255. visaDetails.ClientInfo.GetUSAVisaDate = usaVisaDate;
  3256. }
  3257. }
  3258. string usaFingerText = (string)jsonData.GetType().GetProperty("是否留过十指指纹")!.GetValue(jsonData)!;
  3259. int usaFinger = 0;
  3260. if (usaFingerText.Contains('是')) usaFinger = 1;
  3261. string usaLoseText = (string)jsonData.GetType().GetProperty("签证是否曾遗失")!.GetValue(jsonData)!;
  3262. int usaLose = 0;
  3263. if (usaLoseText.Contains("是")) usaLose = 1;
  3264. //是否曾抵达过美国
  3265. string usaHadArrival‌Text = (string)jsonData.GetType().GetProperty("是否曾抵达过美国")!.GetValue(jsonData)!;
  3266. var (usaHadArrivalf, usaHadArrivalD, usaHadArrivalDays) = TravelHadFlagParser(usaHadArrival‌Text);
  3267. //是否有被美国拒发签证的经历
  3268. string usaRejecteVisaTest = (string)jsonData.GetType().GetProperty("是否有被美国拒发签证的经历")!.GetValue(jsonData)!;
  3269. var (denied, rejectedDate, rejectedPlace, rejectedType) = VisaDenialParser(usaRejecteVisaTest);
  3270. if (denied)
  3271. {
  3272. visaDetails.ClientInfo.RejectedDate = rejectedDate;
  3273. visaDetails.ClientInfo.RejectedPlace = rejectedPlace;
  3274. visaDetails.ClientInfo.RejectedVisa = rejectedType;
  3275. }
  3276. //是否在申请或曾经申请过美国移民签证
  3277. string usaImmVisaText‌ = (string)jsonData.GetType().GetProperty("是否在申请或曾经申请过美国移民签证")!.GetValue(jsonData)!;
  3278. var (immDenied, immDate, immPlace, immType) = VisaDenialParser(usaImmVisaText‌);
  3279. if (immDenied)
  3280. {
  3281. visaDetails.ClientInfo.USAImmVisa‌Date = immDate;
  3282. visaDetails.ClientInfo.USAImmVisa‌Place = immPlace;
  3283. visaDetails.ClientInfo.USAImmVisa‌ = immType;
  3284. }
  3285. //在美直系
  3286. string usaImmedText‌ = (string)jsonData.GetType().GetProperty("是否有直系亲属在美国")!.GetValue(jsonData)!;
  3287. var (immedDenied, immedName, immedRel, immedStat) = FourFieldParser(usaImmedText‌);
  3288. if (immedDenied)
  3289. {
  3290. visaDetails.ClientInfo.USAImmedFamName = immedName;
  3291. visaDetails.ClientInfo.USAImmedFamRel = immedRel;
  3292. visaDetails.ClientInfo.USAImmedFamStat = immedStat;
  3293. }
  3294. //在美旁系
  3295. string usaUncleText‌ = (string)jsonData.GetType().GetProperty("是否有旁系亲属在美国")!.GetValue(jsonData)!;
  3296. var (uncleDenied, uncleName, uncleRel, uncleStat) = FourFieldParser(usaUncleText‌);
  3297. if (immedDenied)
  3298. {
  3299. visaDetails.ClientInfo.USAUncleFamName = uncleName;
  3300. visaDetails.ClientInfo.USAUncleFamRel = uncleName;
  3301. visaDetails.ClientInfo.USAUncleFamStat = uncleStat;
  3302. }
  3303. //服役时间 MilitaryParser
  3304. string militaryText‌ = (string)jsonData.GetType().GetProperty("是否曾参过军")!.GetValue(jsonData)!;
  3305. var (militaryH, militaryB, militaryR, militaryS, (militaryStart, militaryEnd)) = MilitaryParser(militaryText‌);
  3306. var militarys = new List<MilitaryInfo>();
  3307. if (militaryH)
  3308. {
  3309. militarys.Add(new()
  3310. {
  3311. MilBranch = militaryB,
  3312. MilRank = militaryR,
  3313. MilSkill = militaryS,
  3314. ServeTimeBegin = militaryStart,
  3315. ServeTimeEnd = militaryEnd,
  3316. });
  3317. }
  3318. //申请人父母信息 ParentParser
  3319. string fthMthText‌ = (string)jsonData.GetType().GetProperty("申请人父母信息")!.GetValue(jsonData)!;
  3320. if (!string.IsNullOrEmpty(fthMthText‌))
  3321. {
  3322. var (fName, fDob, mName, mDob) = ParentParser(fthMthText‌);
  3323. visaDetails.ClientInfo.FthName = fName;
  3324. visaDetails.ClientInfo.FthBirth = fDob;
  3325. visaDetails.ClientInfo.MthName = mName;
  3326. visaDetails.ClientInfo.MthBirth = mDob;
  3327. }
  3328. visaDetails.ClientInfo = new()
  3329. {
  3330. LastName = name.GetLastName(),
  3331. FirstName = name.GetFirstName(),
  3332. Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1,
  3333. OldName = (string)jsonData.GetType().GetProperty("曾用名")!.GetValue(jsonData)!,
  3334. BirthDay = birthDayDt,
  3335. BirthProvince = birthDay1.province,
  3336. BirthCity = birthDay1.city,
  3337. Address = address.address,
  3338. PostCodes = address.zipCode,
  3339. Marriage = maritalStatus,
  3340. MateName = (string)jsonData.GetType().GetProperty("配偶姓名")!.GetValue(jsonData)!,
  3341. MateBirthDay = birthDayDt_mate,
  3342. MateBirthCountry = birthDay1_mate.province,
  3343. MateBirthCity = birthDay1_mate.city,
  3344. USA_DLNo = driveInfo.number,
  3345. USA_DLPlace = driveInfo.place,
  3346. USA_SSNOrITIN = number,
  3347. Resident = CleanPrefix((string)jsonData.GetType().GetProperty("是否是其他国家的永久居民")!.GetValue(jsonData)!),
  3348. HasSocialAcc‌ = CleanPrefix((string)jsonData.GetType().GetProperty("近五年内是否使用过任何社交账号")!.GetValue(jsonData)!),
  3349. WeddingDate = f,
  3350. DivorceDate = t,
  3351. DivorceRsn = (string)jsonData.GetType().GetProperty("离婚原因")!.GetValue(jsonData)!,
  3352. Job = (string)jsonData.GetType().GetProperty("职务")!.GetValue(jsonData)!,
  3353. Wage = (string)jsonData.GetType().GetProperty("月薪")!.GetValue(jsonData)!,
  3354. WorkState = (string)jsonData.GetType().GetProperty("工作职责")!.GetValue(jsonData)!,
  3355. WorkDate = (string)jsonData.GetType().GetProperty("入职/入学时间(详细到月)")!.GetValue(jsonData)!,
  3356. USAAddress = (string)jsonData.GetType().GetProperty("请提供美国详细住址")!.GetValue(jsonData)!,
  3357. USAPurpose = (string)jsonData.GetType().GetProperty("赴美目的")!.GetValue(jsonData)!,
  3358. CostBearers = (string)jsonData.GetType().GetProperty("费用谁付")!.GetValue(jsonData)!,
  3359. USAContact = (string)jsonData.GetType().GetProperty("美国联系人或组织")!.GetValue(jsonData)!,
  3360. USAContactTel = usa_phone,
  3361. USAContactEmail = usa_email,
  3362. USADate = usa_d,
  3363. USADays = usa_days,
  3364. USAArrivalCity‌ = (string)jsonData.GetType().GetProperty("赴美的到达城市")!.GetValue(jsonData)!,
  3365. USADepartCity‌ = (string)jsonData.GetType().GetProperty("赴美的离开城市")!.GetValue(jsonData)!,
  3366. USAVisitSites‌ = (string)jsonData.GetType().GetProperty("计划在美国访问的景点")!.GetValue(jsonData)!,
  3367. USACmpName = usaCmpName,
  3368. USACmpRelation = (string)jsonData.GetType().GetProperty("同行人关系")!.GetValue(jsonData)!,
  3369. Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!,
  3370. ClientPhone = (string)jsonData.GetType().GetProperty("单位电话")!.GetValue(jsonData)!,
  3371. Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!,
  3372. Cntry5Y‌ = (string)jsonData.GetType().GetProperty("过去5年内到过的国家")!.GetValue(jsonData)!,
  3373. LangSkill‌ = (string)jsonData.GetType().GetProperty("面签时能流利交流的语言")!.GetValue(jsonData)!,
  3374. LoseCode = loseCode,
  3375. DenyNationRsn = (string)jsonData.GetType().GetProperty("曾被哪些国家拒签/拒签原因")!.GetValue(jsonData)!,
  3376. USAVisaCode = (string)jsonData.GetType().GetProperty("签证号码")!.GetValue(jsonData)!,
  3377. USAVisaCate = (string)jsonData.GetType().GetProperty("获签类型")!.GetValue(jsonData)!,
  3378. //GetUSAVisaDate = usaVisaDate,
  3379. USAFinger = usaFinger,
  3380. IsLose = usaLose,
  3381. USAHadArrival = usaHadArrivalD,
  3382. USAHadDays = usaHadArrivalDays,
  3383. ArmyState = JsonConvert.SerializeObject(militarys)
  3384. };
  3385. visaDetails.ClientCerts = new() {
  3386. new(){ SdId = 74,CertNo = passportNo,IDCardAddress = passportPlace },
  3387. new(){ SdId = 73,CertNo = idNo},
  3388. };
  3389. visaDetails.ClientCompany = new() { CompanyFullName = clientName, Address = clientAddr };
  3390. break;
  3391. //中文个人简历模板
  3392. case 6:
  3393. _logger.LogInformation("【签证上传文件操作信息】【中文个人简历模板】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3394. visaDetails.ClientInfo.LastName = (string)jsonData.GetType().GetProperty("姓名(中英文拼音)")!.GetValue(jsonData)!;
  3395. visaDetails.ClientInfo.Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1;
  3396. DateTime.TryParse((string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!, out DateTime birthDay11);
  3397. visaDetails.ClientInfo.BirthDay = birthDay11;
  3398. visaDetails.ClientInfo.BirthProvince = (string)jsonData.GetType().GetProperty("出生地")!.GetValue(jsonData)!;
  3399. visaDetails.ClientInfo.Address = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3400. visaDetails.ClientInfo.Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!;
  3401. visaDetails.ClientInfo.TableOpTel = (string)jsonData.GetType().GetProperty("工作电话")!.GetValue(jsonData)!;
  3402. visaDetails.ClientInfo.Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!;
  3403. visaDetails.ClientInfo.Email = (string)jsonData.GetType().GetProperty("电子邮件")!.GetValue(jsonData)!;
  3404. //学校信息
  3405. visaDetails.ClientSchools.Add(new()
  3406. {
  3407. School = (string)jsonData.GetType().GetProperty("教育学校名称")!.GetValue(jsonData)!,
  3408. Education = (string)jsonData.GetType().GetProperty("教育学位")!.GetValue(jsonData)!,
  3409. Subject = (string)jsonData.GetType().GetProperty("教育专业")!.GetValue(jsonData)!,
  3410. Remark = (string)jsonData.GetType().GetProperty("教育论文题目/研究重点(硕士、博士)")!.GetValue(jsonData)!,
  3411. });
  3412. //工作信息
  3413. visaDetails.ClientCompany = new()
  3414. {
  3415. CompanyFullName = (string)jsonData.GetType().GetProperty("工作经历雇主")!.GetValue(jsonData)!,
  3416. };
  3417. visaDetails.ClientInfo.Job = (string)jsonData.GetType().GetProperty("工作经历职位或头衔职责")!.GetValue(jsonData)!;
  3418. break;
  3419. default:
  3420. break;
  3421. }
  3422. //数据提交
  3423. #region 数据提交
  3424. _sqlSugar.BeginTran();
  3425. // 客户公司表
  3426. var compId = UpsertReturnId<Crm_CustomerCompany>(visaDetails.ClientCompany, o => o.CompanyFullName);
  3427. if (compId < 1)
  3428. {
  3429. _sqlSugar.RollbackTran();
  3430. return Ok(JsonView(false, "公司信息更新失败!"));
  3431. }
  3432. visaDetails.ClientInfo.CrmCompanyId = compId;
  3433. // 客户资料表
  3434. var clientId = UpsertReturnId<Crm_DeleClient>(visaDetails.ClientInfo, o => new { o.LastName, o.FirstName });
  3435. if (clientId < 1)
  3436. {
  3437. _sqlSugar.RollbackTran();
  3438. return Ok(JsonView(false, "客户信息更新失败!"));
  3439. }
  3440. for (int i = 0; i < visaDetails.ClientFamilys.Count(); i++)
  3441. {
  3442. visaDetails.ClientFamilys[i].DcId = clientId;
  3443. }
  3444. for (int i = 0; i < visaDetails.ClientCerts.Count(); i++)
  3445. {
  3446. visaDetails.ClientCerts[i].DcId = clientId;
  3447. }
  3448. for (int i = 0; i < visaDetails.ClientSchools.Count(); i++)
  3449. {
  3450. visaDetails.ClientSchools[i].DcId = clientId;
  3451. }
  3452. // 客户家庭表
  3453. foreach (var item in visaDetails.ClientFamilys)
  3454. {
  3455. var famId = UpsertReturnId<Crm_VisaCustomerFamily>(item, o => o.Name);
  3456. if (famId < 1)
  3457. {
  3458. _sqlSugar.RollbackTran();
  3459. return Ok(JsonView(false, "客户家庭信息更新失败!"));
  3460. }
  3461. }
  3462. // 客户证件表
  3463. foreach (var item in visaDetails.ClientCerts)
  3464. {
  3465. var certId = UpsertReturnId<Crm_CustomerCert>(item, o => o.CertNo);
  3466. if (certId < 1)
  3467. {
  3468. _sqlSugar.RollbackTran();
  3469. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3470. }
  3471. }
  3472. // 客户学历表
  3473. foreach (var item in visaDetails.ClientSchools)
  3474. {
  3475. var schoolId = UpsertReturnId<Crm_VisaCustomerSchool>(item, o => o.School);
  3476. if (schoolId < 1)
  3477. {
  3478. _sqlSugar.RollbackTran();
  3479. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3480. }
  3481. }
  3482. _sqlSugar.CommitTran();
  3483. #endregion
  3484. #endregion
  3485. return Ok(JsonView(true, jsonString));
  3486. }
  3487. #region 扩展处理
  3488. // 从 Expression<Func<T,object>> 里取出属性名
  3489. static string GetPropName<T>(Expression<Func<T, object>> expr)
  3490. {
  3491. if (expr.Body is UnaryExpression ue) expr = Expression.Lambda<Func<T, object>>(ue.Operand, expr.Parameters);
  3492. return ((MemberExpression)expr.Body).Member.Name;
  3493. }
  3494. /// <summary>
  3495. /// 5.1.4.193 可用:存在更新(非NULL非空串),不存在插入,返回主键ID
  3496. /// </summary>
  3497. public int UpsertReturnId<T>(T entity, Expression<Func<T, object>> whereExpr) where T : class, new()
  3498. {
  3499. // 1. 空字符串→NULL,让后续忽略
  3500. foreach (var pi in typeof(T).GetProperties())
  3501. if (pi.PropertyType == typeof(string) &&
  3502. pi.GetValue(entity) is string s &&
  3503. string.IsNullOrWhiteSpace(s))
  3504. pi.SetValue(entity, null);
  3505. // 2. 从表达式里拿属性名
  3506. string propName = GetPropName(whereExpr);
  3507. var propValue = typeof(T).GetProperty(propName)?.GetValue(entity);
  3508. // 3. 判断存在
  3509. bool exists = _sqlSugar.Queryable<T>().Where(propName, propValue).Any();
  3510. // 4. 执行 Upsert
  3511. if (exists)
  3512. {
  3513. _sqlSugar.Updateable(entity)
  3514. .WhereColumns(propName) // 指定条件列
  3515. .IgnoreColumns(ignoreAllNullColumns: true) // 忽略 NULL
  3516. .ExecuteCommand();
  3517. }
  3518. else
  3519. {
  3520. _sqlSugar.Insertable(entity).ExecuteReturnIdentity();
  3521. }
  3522. // 5. 返回主键值(自增/雪花已回填)
  3523. var idProp = typeof(T).GetProperties()
  3524. .First(p => p.GetCustomAttributes<SugarColumn>()
  3525. .Any(a => a.IsPrimaryKey));
  3526. return (int)idProp.GetValue(entity)!;
  3527. }
  3528. /// <summary>
  3529. /// 地址喊邮编 相关处理
  3530. /// </summary>
  3531. public static (string address, string zipCode) SplitAddressZip(string? s)
  3532. {
  3533. if (string.IsNullOrWhiteSpace(s))
  3534. return ("", "");
  3535. ReadOnlySpan<char> src = s.AsSpan();
  3536. int i = src.IndexOf("邮编".AsSpan());
  3537. if (i < 0) // 没有“邮编”字样
  3538. return (src.Trim().ToString(), "");
  3539. ReadOnlySpan<char> addr = src[..i].TrimEnd();
  3540. ReadOnlySpan<char> zip = src[(i + 3)..].Trim(); // 跳过“邮编:”
  3541. // 可能只有“邮编:”而没有数字
  3542. return (addr.IsEmpty ? "" : addr.ToString(),
  3543. zip.IsEmpty ? "" : zip.ToString());
  3544. }
  3545. /// <summary>
  3546. /// 驾照相 关处理
  3547. /// </summary>
  3548. /// <param name="raw"></param>
  3549. /// <returns></returns>
  3550. public static (bool hasLicense, string number, string place) LicenseParser(string? raw)
  3551. {
  3552. if (string.IsNullOrWhiteSpace(raw))
  3553. return (false, "", "");
  3554. // 1. 是否持有
  3555. bool has = raw.StartsWith("是", System.StringComparison.OrdinalIgnoreCase) ||
  3556. raw.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3557. // 2. 去掉前缀,按空格切
  3558. ReadOnlySpan<char> s = raw.AsSpan();
  3559. int colon = s.IndexOf(':');
  3560. ReadOnlySpan<char> after = colon < 0 ? s : s[(colon + 1)..];
  3561. after = after.Trim();
  3562. int space = after.IndexOf(' ');
  3563. ReadOnlySpan<char> num = space < 0 ? after : after[..space];
  3564. ReadOnlySpan<char> st = space < 0 ? ReadOnlySpan<char>.Empty : after[(space + 1)..];
  3565. return (has, num.ToString().Trim(), st.ToString().Trim());
  3566. }
  3567. /// <summary>
  3568. /// 美国社会安全号或者纳税ID号 相关处理
  3569. /// </summary>
  3570. /// <param name="raw"></param>
  3571. /// <returns></returns>
  3572. public static (bool hasSsnItin, string number) SsnItinParser(string? raw)
  3573. {
  3574. if (string.IsNullOrWhiteSpace(raw))
  3575. return (false, "");
  3576. ReadOnlySpan<char> s = raw.AsSpan();
  3577. // 1. 是否持有
  3578. bool has = s.StartsWith("是", System.StringComparison.Ordinal) ||
  3579. s.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3580. // 2. 取号码(去掉前缀和空格)
  3581. int colon = s.IndexOf(':');
  3582. ReadOnlySpan<char> num = colon < 0
  3583. ? ReadOnlySpan<char>.Empty
  3584. : s[(colon + 1)..].Trim();
  3585. return (has, num.ToString());
  3586. }
  3587. /// <summary>
  3588. /// 取消开始的“是:”或者“是”或者“ :”
  3589. /// </summary>
  3590. /// <param name="raw"></param>
  3591. /// <returns></returns>
  3592. public static string CleanPrefix(string? raw)
  3593. {
  3594. if (string.IsNullOrWhiteSpace(raw)) return "";
  3595. // 跳过第一个“是”或“Y”
  3596. ReadOnlySpan<char> s = raw.AsSpan();
  3597. int start = 0;
  3598. if (s.StartsWith("是") || s.StartsWith("Y", StringComparison.OrdinalIgnoreCase))
  3599. start = 1;
  3600. // 跳过连续 : 或空格
  3601. while (start < s.Length && (s[start] == ':' || s[start] == ' '))
  3602. start++;
  3603. return s[start..].Trim().ToString();
  3604. }
  3605. /// <summary>
  3606. /// 婚姻起止时间处理
  3607. /// </summary>
  3608. /// <param name="raw"></param>
  3609. /// <returns></returns>
  3610. public static (DateTime? fromDate, DateTime? toDate) WeddingParser(string? raw)
  3611. {
  3612. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3613. Regex _clean = new(@"[\s~至]+", RegexOptions.Compiled);
  3614. // 1. 把所有“空格~至”统一成 '-'
  3615. string normalized = _clean.Replace(raw, "-");
  3616. // 2. 切两段
  3617. string[] parts = normalized.Split('-', StringSplitOptions.RemoveEmptyEntries);
  3618. if (parts.Length != 2) return (null, null);
  3619. // 3. 解析
  3620. bool ff = DateTime.TryParse(parts[0].Trim(), out var from);
  3621. bool tf = DateTime.TryParse(parts[1].Trim(), out var to);
  3622. return (tf ? from : null, tf ? to : null);
  3623. }
  3624. /// <summary>
  3625. /// 出行日期和天数处理
  3626. /// </summary>
  3627. /// <param name="raw"></param>
  3628. /// <returns></returns>
  3629. public static (DateTime? travelDate, int? days) TravelParser(string? raw)
  3630. {
  3631. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3632. // 切成两段:第一段日期,第二段天数
  3633. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3634. string[] parts = sep.Split(raw.Trim());
  3635. if (parts.Length < 2) return (null, null);
  3636. bool okDate = DateTime.TryParse(parts[0], out DateTime date);
  3637. bool okDays = int.TryParse(parts[1], out int days) && days > 0;
  3638. return (okDate ? date : null, okDays ? days : null);
  3639. }
  3640. /// <summary>
  3641. /// 是否曾抵达过美国
  3642. /// </summary>
  3643. /// <param name="raw"></param>
  3644. /// <returns></returns>
  3645. public static (bool hasTravel, string date, string days) TravelHadFlagParser(string? raw)
  3646. {
  3647. if (string.IsNullOrWhiteSpace(raw)) return (false, string.Empty, string.Empty);
  3648. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3649. // 1. 是否持有
  3650. bool has = raw.AsSpan().TrimStart().StartsWith("是") ||
  3651. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3652. // 2. 用非数字分隔符切成三段:第一段空,第二段日期,第三段天数
  3653. string[] parts = sep.Split(raw.Trim());
  3654. if (parts.Length < 3) return (has, string.Empty, string.Empty);
  3655. return (has, parts[1], parts[2]);
  3656. }
  3657. /// <summary>
  3658. /// 是否有被美国拒发签证的经历
  3659. /// </summary>
  3660. /// <param name="raw"></param>
  3661. /// <returns></returns>
  3662. public static (bool wasDenied, DateTime? date, string place, string visaType) VisaDenialParser(string? raw)
  3663. {
  3664. if (string.IsNullOrWhiteSpace(raw)) return (false, null, "", "");
  3665. bool denied = raw.AsSpan().TrimStart().StartsWith("有") ||
  3666. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3667. var parts = Regex.Split(raw.Trim(), @"[^0-9A-Za-z-]+");
  3668. if (parts.Length < 4) return (denied, null, "", "");
  3669. DateTime.TryParse(parts[1], out var dt); // ← 这里改为 DateTime
  3670. return (denied, dt, parts[2], parts[3]);
  3671. }
  3672. /// <summary>
  3673. /// 在美直系、旁系 处理
  3674. /// </summary>
  3675. /// <param name="raw"></param>
  3676. /// <returns></returns>
  3677. public static (bool flag, string name, string rel, string stat) FourFieldParser(string? raw)
  3678. {
  3679. if (string.IsNullOrWhiteSpace(raw)) return (false, "", "", "");
  3680. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3681. if (parts.Length < 4) return (false, "", "", "");
  3682. bool flag = parts[0] is "有" or "是" or "Y" or "Yes";
  3683. string name = parts[1];
  3684. string rel = parts[2];
  3685. string stat = parts[3];
  3686. return (flag, name, rel, stat);
  3687. }
  3688. /// <summary>
  3689. /// 服役时间处理
  3690. /// </summary>
  3691. /// <param name="raw"></param>
  3692. /// <returns></returns>
  3693. public static (bool hasService, string branch, string rank, string specialty, (DateTime? start, DateTime? end) period) MilitaryParser(string? raw)
  3694. {
  3695. const string fmt = "yyyy年MM月dd日";
  3696. if (string.IsNullOrWhiteSpace(raw))
  3697. return (false, "", "", "", (null, null));
  3698. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3699. if (parts.Length < 5) return (false, "", "", "", (null, null));
  3700. bool has = parts[0] is "是" or "Y" or "Yes";
  3701. string branch = parts[1];
  3702. string rank = parts[2];
  3703. string specialty = parts[3];
  3704. // 拼回时间字符串
  3705. string periodRaw = string.Join(" ", parts[4..]);
  3706. var span = periodRaw.AsSpan();
  3707. int zhi = span.IndexOf("至");
  3708. if (zhi < 0) return (has, branch, rank, specialty, (null, null));
  3709. var startStr = span.Slice(0, zhi).Trim();
  3710. var endStr = span.Slice(zhi + 1).Trim();
  3711. bool okStart = DateTime.TryParseExact(startStr.ToString(), fmt, null, DateTimeStyles.None, out var start);
  3712. bool okEnd = DateTime.TryParseExact(endStr.ToString(), fmt, null, DateTimeStyles.None, out var end);
  3713. return (has, branch, rank, specialty, (okStart ? start : null, okEnd ? end : null));
  3714. }
  3715. /// <summary>
  3716. /// 申请人父母信息
  3717. /// </summary>
  3718. /// <param name="raw"></param>
  3719. /// <returns></returns>
  3720. public static (string fatherName, DateTime? fatherDob, string motherName, DateTime? motherDob) ParentParser(string? raw)
  3721. {
  3722. const string fmt = "yyyy年MM月dd日";
  3723. if (string.IsNullOrWhiteSpace(raw)) return ("", null, "", null);
  3724. // 按空格切,去掉空元素
  3725. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3726. if (parts.Length < 4) return ("", null, "", null);
  3727. // 父亲
  3728. string fName = parts[0];
  3729. DateTime.TryParseExact(parts[1], fmt, null, DateTimeStyles.None, out var fDob);
  3730. // 母亲
  3731. string mName = parts[2];
  3732. DateTime.TryParseExact(parts[3], fmt, null, DateTimeStyles.None, out var mDob);
  3733. return (fName, fDob, mName, mDob);
  3734. }
  3735. public class VisaDetailsView
  3736. {
  3737. /// <summary>
  3738. /// 客户资料表
  3739. /// </summary>
  3740. public Crm_DeleClient ClientInfo { get; set; }
  3741. /// <summary>
  3742. /// 客户家庭表
  3743. /// </summary>
  3744. public List<Crm_VisaCustomerFamily> ClientFamilys { get; set; }
  3745. /// <summary>
  3746. /// 客户公司表
  3747. /// </summary>
  3748. public Crm_CustomerCompany ClientCompany { get; set; }
  3749. /// <summary>
  3750. /// 客户证件表
  3751. /// </summary>
  3752. public List<Crm_CustomerCert> ClientCerts { get; set; }
  3753. /// <summary>
  3754. /// 客户学历表
  3755. /// </summary>
  3756. public List<Crm_VisaCustomerSchool> ClientSchools { get; set; }
  3757. }
  3758. private int GetSuccessCount(List<FileUploadResult> results)
  3759. {
  3760. var count = 0;
  3761. foreach (var result in results)
  3762. {
  3763. if (result.Success) count++;
  3764. }
  3765. return count;
  3766. }
  3767. #endregion
  3768. #region 文件下载
  3769. /// <summary>
  3770. /// 签证下载类型初始化
  3771. /// </summary>
  3772. private readonly static Dictionary<int, string> _visaTypeInit = new()
  3773. {
  3774. { 1, "美国" },
  3775. { 2, "日本" },
  3776. { 3, "韩国" },
  3777. { 4, "瑞典" },
  3778. { 5, "波兰" },
  3779. };
  3780. //申根国
  3781. private readonly static string[] _shenGenGuos = new string[] { "奥地利", "比利时", "丹麦", "芬兰", "法国", "德国", "冰岛", "意大利", "希腊", "卢森堡", "荷兰", "挪威", "葡萄牙", "西班牙",
  3782. "瑞典", "匈牙利", "捷克", "斯洛伐克", "斯洛文尼亚","波兰","爱沙尼亚","拉脱维亚","立陶宛","马耳他","瑞士","列支敦士登" };
  3783. //欧盟国家
  3784. private readonly static string[] _eucountries = new string[] { "奥地利", "比利时", "丹麦", "芬兰", "法国", "德国", "意大利", "希腊", "卢森堡", "荷兰", "葡萄牙", "西班牙","爱尔兰","罗马尼亚",
  3785. "保加利亚","匈牙利", "捷克", "斯洛伐克", "斯洛文尼亚","波兰","爱沙尼亚","拉脱维亚","立陶宛","马耳他","瑞士","列支敦士登" };
  3786. //欧洲国家
  3787. private readonly static string[] _aBC = new string[] { "英国", "爱尔兰" };
  3788. /// <summary>
  3789. /// 团组&签证 New
  3790. /// 签证文申请表下载
  3791. /// </summary>
  3792. /// <param name="groupId">
  3793. /// <param name="fileTypeId">
  3794. /// </param>
  3795. /// <returns></returns>
  3796. [HttpGet]
  3797. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3798. public async Task<IActionResult> VisaFileDownload(int groupId, int fileTypeId)
  3799. {
  3800. if (!_visaTypeInit.TryGetValue(fileTypeId, out _))
  3801. {
  3802. return Ok(JsonView(false, "请选择正确的文件类型!"));
  3803. }
  3804. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == groupId).First();
  3805. if (groupInfo == null)
  3806. {
  3807. return Ok(JsonView(false, "团组信息不存在!"));
  3808. }
  3809. //访问路径
  3810. var serverPath = $"http://132.232.92.186:24/Word/VisaClientData/Downloads/{groupInfo.TeamName}/";
  3811. //模板存储位置
  3812. var tempPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Template/";
  3813. //服务器存储文件位置
  3814. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Downloads/{groupInfo.TeamName}/";
  3815. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  3816. //文件生成路径
  3817. string url = string.Empty;
  3818. //基础数据
  3819. //团组客户名单
  3820. var groupClients = await _sqlSugar.Queryable<Grp_TourClientList>()
  3821. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  3822. .Select(x => x.ClientId)
  3823. .ToListAsync();
  3824. if (groupClients.Count < 1)
  3825. {
  3826. return Ok(JsonView(false, "该团组下暂无团组名单!"));
  3827. }
  3828. //团组客户详细信息
  3829. var groupCustInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.IsDel == 0 && groupClients.Contains(x.Id)).ToList();
  3830. //家庭成员资料
  3831. var familyInfos = _sqlSugar.Queryable<Crm_VisaCustomerFamily>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3832. //公司资料
  3833. var companyInfo‌‌s = _sqlSugar.Queryable<Crm_VisaCustomerCompany>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3834. //学校资料
  3835. var schoolInfos = _sqlSugar.Queryable<Crm_VisaCustomerSchool>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3836. /* 证件类型
  3837. *
  3838. * 773 身份证
  3839. * 774 护照
  3840. * 775 学生证
  3841. * 776 军人证
  3842. * 777 回乡证
  3843. * 778 台胞证
  3844. * 779 港澳通行证
  3845. * 780 国际海员证
  3846. * 781 外国人永久居留证
  3847. * 782 旅行证
  3848. * 783 台湾通行证
  3849. * 784 港澳台居住证
  3850. * 785 其他
  3851. */
  3852. //证件资料
  3853. var certInfos = _sqlSugar.Queryable<Crm_CustomerCert>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3854. //利用字典创建书签与书签的值的键值对,第一个string为键,第二个string为值
  3855. var applyDate = DateTime.Now.ToString("yyyy-MM-dd");
  3856. var filePaths = new List<string>();
  3857. var visaTypeName = string.Empty;
  3858. var currTempPath = string.Empty;
  3859. switch (fileTypeId)
  3860. {
  3861. case 1: // 美国
  3862. visaTypeName = $"美国签证申请表";
  3863. currTempPath = $"{tempPath}{visaTypeName}.doc";
  3864. var usaSavePath = $"{fileServerPath}{visaTypeName}/";
  3865. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(usaSavePath);
  3866. foreach (var custInfo in groupCustInfos)
  3867. {
  3868. //解密
  3869. EncryptionProcessor.DecryptProperties(custInfo);
  3870. Dictionary<string, string> dics = new();
  3871. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  3872. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  3873. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  3874. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  3875. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  3876. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  3877. #region 美国签证模板书签值处理
  3878. dics.Add("LastNameEn", custInfo?.LastName ?? "");//名拼音
  3879. dics.Add("FirstNameEn", custInfo?.FirstName ?? "");//姓拼音
  3880. dics.Add("LastName", custInfo?.LastName ?? "");//名
  3881. dics.Add("FirstName", custInfo?.FirstName ?? "");//姓
  3882. dics.Add("OldNameEn", custInfo?.OldName ?? "");//曾用姓名拼音
  3883. dics.Add("OldName", custInfo?.FirstName ?? "");//曾用姓名
  3884. //未设置、未婚、已婚、离异、丧偶
  3885. var marriage = custInfo.Marriage switch
  3886. {
  3887. 0 => "未设置",
  3888. 1 => "未婚",
  3889. 2 => "已婚",
  3890. 3 => "离异",
  3891. 4 => "丧偶",
  3892. _ => "未知"
  3893. };
  3894. dics.Add("Marriage", marriage);//婚姻状况
  3895. dics.Add("Phone", custInfo?.Phone ?? "");//家庭电话
  3896. dics.Add("BirthCity", custInfo?.BirthCity ?? "");//出生城市
  3897. dics.Add("BirthProvince", custInfo?.BirthProvince ?? "");//出生省份
  3898. string m_idCard = idInfo?.CertNo ?? "";
  3899. string m_birthday = string.Empty;
  3900. if (!string.IsNullOrEmpty(m_idCard))
  3901. {
  3902. string m_year = m_idCard.Substring(6, 4);
  3903. string m_month = m_idCard.Substring(10, 2);
  3904. string m_day = m_idCard.Substring(12, 2);
  3905. m_birthday = m_year + "." + m_month + "." + m_day;
  3906. }
  3907. dics.Add("BirthDay", m_birthday);//出生日期
  3908. dics.Add("Tel", custInfo?.Tel ?? "");//移动电话
  3909. dics.Add("Email", custInfo?.Email ?? "");//电子信箱
  3910. dics.Add("IdCard", m_idCard);//身份证号码
  3911. dics.Add("Address", custInfo?.Address ?? "");//现居家庭地址
  3912. dics.Add("PostCodes", custInfo?.PostCodes ?? "");//邮编
  3913. dics.Add("Client", clinetInfo?.Company ?? "");//单位名称
  3914. dics.Add("ClientAddress", clinetInfo?.CompanyAddress ?? "");//单位地址
  3915. dics.Add("ClientPostCodes", custInfo?.PostCodes ?? "");//单位邮编
  3916. dics.Add("Job", custInfo?.Job ?? "");//职务
  3917. dics.Add("WorkDate", custInfo?.WorkDate ?? "");//入职时间
  3918. dics.Add("Wage", custInfo?.Wage ?? "");//月薪
  3919. dics.Add("ClientPhone", custInfo?.ClientPhone ?? "");//单位电话
  3920. dics.Add("ClientFax", custInfo?.ClientFax ?? "");//单位传真
  3921. dics.Add("ClientEmail", custInfo?.ClientEmail ?? "");//单位邮箱
  3922. dics.Add("ClientLeader", custInfo?.ClientLeader ?? "");//单位主管姓名
  3923. dics.Add("ClientLeaderJob", custInfo?.ClientLeaderJob ?? "");//单位主管职务
  3924. dics.Add("WorkState", custInfo?.WorkState ?? "");//工作内容简单介绍
  3925. dics.Add("IsGetSchengen", custInfo?.IsGetSchengen == 0 ? "否" : "是");//是否有获批的申根签证
  3926. dics.Add("StartTime", custInfo?.StartTime.ToString("yyyy-MM-dd") ?? "");//申根签证有效期开始
  3927. dics.Add("EndTime", custInfo?.EndTime.ToString("yyyy-MM-dd") ?? "");//申根签证有效期结束
  3928. dics.Add("IsFinger", custInfo.IsFinger == 0 ? "否" : "是");//申根签证是否有指纹记录
  3929. dics.Add("FingerDate", custInfo?.FingerDate.ToString("yyyy-MM-dd") ?? "");//申根签指纹采集时间
  3930. dics.Add("TableOpName", custInfo?.TableOpName ?? "");//填表经办人
  3931. dics.Add("TableOpTel", custInfo?.TableOpTel ?? "");//填表经办人联系电话
  3932. dics.Add("TableDate", custInfo?.TableDate.ToString("yyyy-MM-dd") ?? "");//填表日期
  3933. dics.Add("Party", custInfo?.Party ?? "");//所属党派或宗教
  3934. dics.Add("Nationality", custInfo?.Nationality ?? "");//国籍
  3935. var sex = custInfo.Sex switch
  3936. {
  3937. 0 => "男",
  3938. 1 => "女",
  3939. _ => "未知"
  3940. };
  3941. dics.Add("Sex", sex);//性别
  3942. dics.Add("WeddingDate", custInfo?.WeddingDate?.ToString("yyyy-MM-dd") ?? "");//结婚日期
  3943. dics.Add("DivorceDate", custInfo?.DivorceDate?.ToString("yyyy-MM-dd") ?? "");//离婚日期
  3944. dics.Add("MateName", custInfo?.MateName ?? "");//配偶姓名
  3945. dics.Add("MateBirthDay", custInfo?.MateBirthDay.ToString("yyyy-MM-dd") ?? "");//配偶出生日期
  3946. dics.Add("MateBirthCity", custInfo?.MateBirthCity ?? "");//配偶出生城市
  3947. dics.Add("MateBirthCountry", custInfo?.MateBirthCountry ?? "");//配偶出生省份
  3948. dics.Add("MateAddress", custInfo?.MateAddress ?? "");//配偶住址
  3949. dics.Add("MateClient", custInfo?.MateClient ?? "");//配偶工作单位名称
  3950. dics.Add("MateClientAddress", custInfo?.MateClientAddress ?? "");//配偶工作单位地址
  3951. dics.Add("MateJob", custInfo?.MateJob ?? "");//配偶职务
  3952. dics.Add("VisitCountry", custInfo?.VisitCountry ?? "");//因公出访的国家
  3953. dics.Add("Paper", custInfo?.Paper ?? "");//发表的期刊、论文
  3954. dics.Add("Papent", custInfo?.Papent ?? "");//专利
  3955. dics.Add("PhD", custInfo?.PhD ?? "");//博士论文
  3956. dics.Add("IsVisitUC", custInfo?.IsVisitUC == 0 ? "否" : "是" ?? "");//是否因公去过美国/加拿大
  3957. dics.Add("USADate", custInfo?.USADate?.ToString("yyyy-MM-dd") ?? "");//美国抵达日期
  3958. dics.Add("USADays", custInfo?.USADays.ToString() ?? "");//美国停留天数
  3959. dics.Add("CanDate", custInfo?.CanDate.ToString("yyyy-MM-dd") ?? "");//加拿大抵达日期
  3960. dics.Add("CanDays", custInfo?.CanDays.ToString() ?? "");//加拿大停留天数
  3961. dics.Add("IsUSAVia", custInfo?.IsUSAVia == 0 ? "否" : "是" ?? "");//是否获得过因公美国签证
  3962. dics.Add("GetUSAVisaDate", custInfo?.GetUSAVisaDate.ToString("yyyy-MM-dd") ?? "");//因公美国签证时间
  3963. dics.Add("GetUPPlace", custInfo?.GetUPPlace ?? "");//因公美国签证地点
  3964. dics.Add("USAVisaCate", custInfo?.USAVisaCate ?? "");//因公美国签证种类
  3965. dics.Add("USAVisaCode", custInfo?.USAVisaCode ?? "");//因公美国签证编码
  3966. dics.Add("USAFinger", custInfo?.USAFinger == 0 ? "否" : "是" ?? "");//是否在使馆留过十指的指纹
  3967. dics.Add("IsRejected", custInfo?.IsRejected == 0 ? "否" : "是" ?? "");//是否被拒
  3968. dics.Add("RejectedDate", custInfo?.RejectedDate?.ToString("yyyy-MM-dd") ?? "");//被拒时间
  3969. dics.Add("RejectedPlace", custInfo?.RejectedPlace ?? "");//被拒地点
  3970. dics.Add("RejectedVisa", custInfo?.RejectedVisa ?? "");//被拒签证种类
  3971. dics.Add("IsRevoke", custInfo?.IsRevoke == 0 ? "否" : "是" ?? "");//美国签证是否被吊销
  3972. dics.Add("IsLose", custInfo?.IsLose == 0 ? "否" : "是" ?? "");//护照是否丢失
  3973. dics.Add("LoseDate", custInfo?.LoseDate.ToString("yyyy-MM-dd") ?? "");//丢失的护照时间
  3974. dics.Add("LoseCode", custInfo?.LoseCode ?? "");//丢失的护照号码
  3975. dics.Add("IsUSAVisa", custInfo?.IsUSAVisa == 0 ? "否" : "是" ?? "");//丢失的护照是否有美国签证
  3976. dics.Add("MateUSA", custInfo?.MateUSA == 0 ? "否" : "是" ?? "");//夫/妻是否已在美国
  3977. dics.Add("MateIden", custInfo?.MateIden ?? "");//夫/妻身份
  3978. dics.Add("WHUSA", custInfo?.WHUSA == 0 ? "否" : "是" ?? "");//未婚夫/妻是否已在美国
  3979. dics.Add("WHIden", custInfo?.WHIden ?? "");//未婚夫/妻身份
  3980. dics.Add("ParentUSA", custInfo?.ParentUSA == 0 ? "否" : "是" ?? "");//父/母是否已在美国
  3981. dics.Add("ParentIden", custInfo?.ParentIden ?? "");//父/母身份
  3982. dics.Add("ChildUSA", custInfo?.ChildUSA == 0 ? "否" : "是" ?? "");//儿子/女儿是否已在美国
  3983. dics.Add("ChildIden", custInfo?.ChildIden ?? "");//儿子/女儿身份
  3984. dics.Add("BroUSA", custInfo?.BroUSA == 0 ? "否" : "是" ?? "");//兄弟/姐妹是否已在美国
  3985. dics.Add("BroIden", custInfo?.BroIden ?? "");//兄弟/姐妹身份
  3986. dics.Add("Social", custInfo?.Social ?? "");//所属/捐助/工作过的职业协会、社会团体和慈善机构
  3987. dics.Add("IsArmy", custInfo?.IsArmy == 0 ? "否" : "是" ?? "");//是否参军
  3988. dics.Add("ArmyState", custInfo?.ArmyState ?? "");//参军详情
  3989. dics.Add("ApplyDate", applyDate);//申请日期
  3990. //公司信息书签
  3991. if (currCompanyInfos.Count > 0)
  3992. {
  3993. for (int i = 0; i < currCompanyInfos.Count; i++)
  3994. {
  3995. var compnayInfo = currCompanyInfos[i];
  3996. if (!string.IsNullOrEmpty(compnayInfo.Company))
  3997. {
  3998. dics.Add("Company", compnayInfo?.Company ?? "");//公司名称
  3999. dics.Add("CompanyAddress", compnayInfo?.CompanyAddress ?? "");//公司地址
  4000. dics.Add("CompanyPhone", compnayInfo?.Phone ?? "");//公司电话
  4001. dics.Add("CompanyJob", compnayInfo?.Job ?? "");//职务
  4002. dics.Add("CompanyLeaderName", compnayInfo?.LeaderName ?? "");//主管名字
  4003. dics.Add("CompanyWorkStart", compnayInfo?.WorkStart.ToString("yyyy-MM-dd") ?? "");//雇佣起始年月日
  4004. dics.Add("CompanyWorkEnd", compnayInfo?.WorkEnd.ToString("yyyy-MM-dd") ?? "");//雇佣结束年月日
  4005. dics.Add("CompanyWorkState", compnayInfo?.WorkState ?? "");//工作职责及内容简述
  4006. }
  4007. else break;
  4008. }
  4009. }
  4010. //学校信息书签
  4011. if (currSchoolInfos.Count > 0)
  4012. {
  4013. for (int i = 0; i < currSchoolInfos.Count; i++)
  4014. {
  4015. var schoolInfo = currSchoolInfos[i];
  4016. if (!string.IsNullOrEmpty(schoolInfo.School))
  4017. {
  4018. dics.Add("School", schoolInfo?.School ?? "");//学校名称和学历
  4019. dics.Add("SchoolAddress", schoolInfo?.Address ?? "");//学校地址
  4020. dics.Add("SchoolTeacher", schoolInfo?.Teacher ?? "");//指导老师
  4021. dics.Add("SchoolSubject", schoolInfo?.Subject ?? "");//所学课程或专业名称
  4022. dics.Add("SchoolStudyStart", schoolInfo?.StudyStart.ToString("yyyy-MM-dd") ?? "");//就读起始日
  4023. dics.Add("SchoolStudyEnd", schoolInfo?.StudyEnd.ToString("yyyy-MM-dd") ?? "");//就读结束日
  4024. }
  4025. else break;
  4026. }
  4027. }
  4028. //家人信息书签
  4029. if (currFamilyInfos.Count > 0)
  4030. {
  4031. for (int i = 0; i < currFamilyInfos.Count; i++)
  4032. {
  4033. var familyInfo = currFamilyInfos[i];
  4034. if (!string.IsNullOrEmpty(familyInfo.Appellation))
  4035. {
  4036. dics.Add("FamilyAppellation", familyInfo?.Appellation ?? "");//家庭成员称谓
  4037. dics.Add("FamilyName", familyInfo?.Name ?? "");//家庭成员姓名
  4038. dics.Add("FamilyBirthDay", familyInfo?.BirthDay.ToString("yyyy-MM-dd") ?? "");//家庭成员出生日期
  4039. dics.Add("FamilyBirthPlace", familyInfo?.BirthPlace ?? "");// 家庭成员出生地
  4040. dics.Add("FamilyPolitics", familyInfo?.Politics ?? "");//家庭成员政治面貌
  4041. dics.Add("FamilyClient", familyInfo?.Client ?? "");//家庭成员工作单位
  4042. dics.Add("FamilyAddress", familyInfo?.Address ?? "");// 家庭地址
  4043. dics.Add("IsEu", familyInfo?.IsEu == 0 ? "No" : "Yes" ?? "");// 欧盟公民
  4044. dics.Add("FamilyNameSnd", familyInfo?.NameSnd ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员姓名
  4045. dics.Add("FamilyBirthDaySnd", familyInfo?.BirthDaySnd.ToString("yyyy-MM-dd") ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员生日
  4046. dics.Add("FamilyNationality", familyInfo?.Nationality ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员国籍
  4047. dics.Add("FamilyIDCard", familyInfo?.IDCard ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员旅行证件编号或身份证号码
  4048. dics.Add("FamilyReletionship", familyInfo?.Reletionship ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员与申请人的关系
  4049. dics.Add("IsUSA", familyInfo?.IsUSA == 1 ? "是" : "否" ?? "");// 家庭成员是否在美国
  4050. }
  4051. else break;
  4052. }
  4053. }
  4054. #endregion
  4055. #region 生成文件
  4056. try
  4057. {
  4058. _logger.LogInformation("模板位置:{currTempPath}", currTempPath);
  4059. Document doc = new(currTempPath);
  4060. Aspose.Words.DocumentBuilder builder = new(doc);
  4061. string strTemp = "";
  4062. //循环键值对
  4063. foreach (var key in dics.Keys)
  4064. {
  4065. //将光标移入书签的位置
  4066. builder.MoveToBookmark(key);
  4067. //判断书签值是否为空
  4068. if (!string.IsNullOrEmpty(dics[key]))
  4069. {
  4070. strTemp = dics[key];
  4071. }
  4072. else strTemp = "";
  4073. //填充书签
  4074. builder.Write(strTemp.Replace("\\N", "\n"));
  4075. }
  4076. var custName = custInfo.LastName + custInfo.FirstName;
  4077. string fileName = $"{custName}_{visaTypeName}.doc";
  4078. var currFilePath = $"{usaSavePath}{fileName}";
  4079. doc.Save(currFilePath);
  4080. filePaths.Add(currFilePath);
  4081. }
  4082. catch (Exception ex)
  4083. {
  4084. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4085. }
  4086. #endregion
  4087. }
  4088. break;
  4089. case 2: // 日本
  4090. visaTypeName = $"日本签证申请表";
  4091. currTempPath = $"{tempPath}/{visaTypeName}.doc";
  4092. var jpnSavePath = $"{fileServerPath}/{visaTypeName}/";
  4093. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(jpnSavePath);
  4094. foreach (var custInfo in groupCustInfos)
  4095. {
  4096. EncryptionProcessor.DecryptProperties(custInfo);
  4097. Dictionary<string, string> dics = new();
  4098. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  4099. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  4100. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  4101. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4102. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4103. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4104. #region 日本签证模板书签
  4105. dics.Add("LastNameEn", CommonFun.ConvertToPinyin(custInfo?.LastName?.Trim() ?? "")?.ToLower() ?? "");//姓
  4106. dics.Add("FirstNameEn", CommonFun.ConvertToPinyin(custInfo?.FirstName?.Trim() ?? "")?.ToLower() ?? "");//名
  4107. if (!string.IsNullOrEmpty(custInfo.OldName)) dics.Add("OldNameEn", custInfo?.OldName ?? "");//名
  4108. else dics.Add("OldNameEn", "无");//名
  4109. dics.Add("LastName", custInfo?.LastName ?? "");//姓
  4110. dics.Add("FirstName", custInfo?.FirstName ?? "");//名
  4111. if (!string.IsNullOrEmpty(custInfo.OldName)) dics.Add("OldName", custInfo?.OldName ?? "");//名
  4112. else dics.Add("OldName", "无");//名
  4113. string idCard = idInfo?.CertNo?.Trim() ?? "";
  4114. string birthday = string.Empty;
  4115. if (!string.IsNullOrEmpty(idCard))
  4116. {
  4117. string year = idCard.Substring(6, 4);
  4118. string month = idCard.Substring(10, 2);
  4119. string day = idCard.Substring(12, 2);
  4120. birthday = year + "/" + month + "/" + day;
  4121. }
  4122. dics.Add("BirthDay", birthday); //出生日期
  4123. dics.Add("BirthProvince", custInfo?.BirthProvince ?? "");//出生省
  4124. dics.Add("BirthCity", custInfo?.BirthCity ?? "");//出生城市
  4125. dics.Add("Nationality", "中国");//国籍
  4126. dics.Add("Address", custInfo?.Address ?? "");//现居家庭地址
  4127. dics.Add("IdCard", idCard);//身份证号码
  4128. dics.Add("OldNationality", "无");//默认没有
  4129. dics.Add("Tel11", custInfo?.Phone ?? "");//座机
  4130. //护照
  4131. if (passportInfo != null)
  4132. {
  4133. dics.Add("PassprotNo", passportInfo?.CertNo ?? "");// 护照編號
  4134. dics.Add("PassprotIssuePlase", passportInfo?.Area ?? "");// 护照签发地
  4135. dics.Add("PassprotStartTime", passportInfo?.IssueDt?.ToString("yyyy/MM/dd") ?? "");//护照开始时间
  4136. dics.Add("PassprotEndTime", passportInfo?.ExpiryDt?.ToString("yyyy/MM/dd") ?? "");// 护照过期时间
  4137. }
  4138. //得到签证国家下的城市
  4139. string city = "";
  4140. string county = "";
  4141. //ResidenceTime1 机票三字码信息
  4142. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  4143. if (atbc != null)
  4144. {
  4145. string startTime = ""; //开始停留时间
  4146. string endTime = ""; //离开时间
  4147. string three = ""; //航司
  4148. string threeCode = ""; //入境口岸
  4149. for (int i = 0; i < atbc.Rows.Count; i++)
  4150. {
  4151. if (i == 0) //得到抵达日期
  4152. {
  4153. three = atbc.Rows[i]["Fliagtcode"].ToString();
  4154. startTime = atbc.Rows[i]["Day"].ToString();
  4155. threeCode = atbc.Rows[i]["Three"].ToString();
  4156. continue;
  4157. }
  4158. if (i == 1)
  4159. endTime = atbc.Rows[i]["Day"].ToString();
  4160. }
  4161. dics.Add("ResidenceTime1", startTime);
  4162. dics.Add("ResidenceTime2", endTime);
  4163. dics.Add("EntryTime", startTime);
  4164. if (!string.IsNullOrEmpty(three))
  4165. {
  4166. //查询航司名称
  4167. var threeCodeTwo = three.Substring(0, 2);
  4168. var ac = _sqlSugar.Queryable<Res_AirCompany>().Where(x => x.ShortCode == threeCodeTwo).First();
  4169. if (ac != null)
  4170. {
  4171. dics.Add("AirName", $"{ac?.EnName ?? ""} {three}"); //入境口岸
  4172. }
  4173. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == threeCodeTwo).First();
  4174. if (tc != null)
  4175. {
  4176. county = tc.Country;
  4177. city = tc.City;
  4178. dics.Add("PortOfEntry", tc?.City ?? ""); //入境口岸
  4179. }
  4180. }
  4181. }
  4182. //团组信息
  4183. if (groupInfo != null)
  4184. {
  4185. dics.Add("Destination", groupInfo?.VisitPurpose ?? ""); //出访目的 Destination2
  4186. //DickeyValue.Add("Destination2", dgi.VisitCountry); //出访目的地
  4187. }
  4188. if (!string.IsNullOrEmpty(city))
  4189. {
  4190. //得到当前国家下的城市酒店信息
  4191. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  4192. .Where(x => x.DiId == groupId)
  4193. .Where(x => x.City.contains(city))
  4194. .First();
  4195. //酒店住址
  4196. if (hotelInfo != null)
  4197. {
  4198. dics.Add("HotalName", hotelInfo?.HotelName ?? ""); //酒店名称
  4199. dics.Add("HotalAddress", hotelInfo?.HotelAddress ?? ""); //酒店地址
  4200. dics.Add("HotalTel", hotelInfo?.HotelTel ?? ""); //酒店电话
  4201. }
  4202. }
  4203. dics.Add("Tel", custInfo?.Tel ?? "");//移动电话
  4204. dics.Add("Client", companyInfos?.FirstOrDefault()?.Company ?? "");//单位名称
  4205. dics.Add("ClientPhone", companyInfos?.FirstOrDefault()?.Phone ?? "");//单位电话
  4206. dics.Add("ClientAddress", companyInfos?.FirstOrDefault()?.CompanyAddress ?? "");//单位地址
  4207. dics.Add("Job", custInfo?.Job ?? "");//职务
  4208. dics.Add("MateJob", custInfo?.MateJob ?? "");//配偶职务
  4209. //InvitingPartyInfo RB_IP = new InvitingPartyInfoService().GetAddSelect(int.Parse(ddlTeamNames.SelectedValue), RB_County, RB_City);
  4210. if (!string.IsNullOrEmpty(county) && !string.IsNullOrEmpty(city))
  4211. {
  4212. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  4213. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  4214. .Where(x => x.Country.Contains(county))
  4215. .Where(x => x.Area.Contains(city))
  4216. .First();
  4217. //邀请 接待单位
  4218. if (oa != null)
  4219. {
  4220. dics.Add("OA12", oa?.Contact ?? ""); //接待单位联系人
  4221. dics.Add("OAJob", oa?.Job ?? ""); //接待联系人职务
  4222. dics.Add("OATel", oa?.Tel ?? ""); //接待单位电话
  4223. dics.Add("OAAddress", oa?.Address ?? "");//接待单位地址
  4224. dics.Add("ApplicantGuanxi", "邀请方"); //和申请人关系
  4225. dics.Add("OACountry", "日本"); //邀请方国家
  4226. dics.Add("OADan", "同上"); // 同上
  4227. dics.Add("OAJob1", "同上"); //接待联系人职务
  4228. dics.Add("OATel1", "同上"); // 同上
  4229. dics.Add("OAAddress1", "同上"); // 同上
  4230. dics.Add("ApplicantGuanxi1", "同上"); // 同上
  4231. dics.Add("OACountry1", "同上"); //邀请方国家
  4232. }
  4233. }
  4234. dics.Add("NowTime", DateTime.Now.ToString("yyyy/MM/dd")); //获取当前系统时间
  4235. #endregion
  4236. #region 生成文件
  4237. try
  4238. {
  4239. Document doc = new(currTempPath);
  4240. Aspose.Words.DocumentBuilder builder = new(doc);
  4241. string strTemp = "";
  4242. //循环键值对
  4243. foreach (var key in dics.Keys)
  4244. {
  4245. //将光标移入书签的位置
  4246. builder.MoveToBookmark(key);
  4247. //判断书签值是否为空
  4248. if (!string.IsNullOrEmpty(dics[key]))
  4249. {
  4250. strTemp = dics[key];
  4251. }
  4252. else strTemp = "";
  4253. //填充书签
  4254. builder.Write(strTemp.Replace("\\N", "\n"));
  4255. }
  4256. var custName = custInfo?.LastName + custInfo?.FirstName;
  4257. string fileName = $"{custName}_{visaTypeName}.doc";
  4258. var currFilePath = $"{jpnSavePath}{fileName}";
  4259. doc.Save(currFilePath);
  4260. filePaths.Add(currFilePath);
  4261. }
  4262. catch (Exception ex)
  4263. {
  4264. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4265. }
  4266. #endregion
  4267. }
  4268. break;
  4269. case 3: // 韩国
  4270. visaTypeName = $"韩国签证申请表";
  4271. currTempPath = $"{tempPath}{visaTypeName}.doc";
  4272. var korSavePath = $"{fileServerPath}{visaTypeName}/";
  4273. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(korSavePath);
  4274. foreach (var custInfo in groupCustInfos)
  4275. {
  4276. EncryptionProcessor.DecryptProperties(custInfo);
  4277. Dictionary<string, string> dics = new();
  4278. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  4279. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  4280. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  4281. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4282. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4283. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4284. #region 韩国签证模板书签
  4285. dics.Add("LastNameEn", custInfo?.LastName ?? "");//姓
  4286. dics.Add("FirstNameEn", custInfo?.FirstName ?? "");//名
  4287. var userName = $"{custInfo?.LastName ?? ""}{custInfo?.FirstName ?? ""}";
  4288. dics.Add("User", userName);//姓名
  4289. //判断性别
  4290. if (custInfo.Sex == 0)
  4291. dics.Add("SexMale", "√");
  4292. else if (custInfo.Sex == 1)
  4293. dics.Add("SexFemale", "√");
  4294. string idCard = idInfo.CertNo;
  4295. string birthday = string.Empty;
  4296. if (!string.IsNullOrEmpty(idCard))
  4297. {
  4298. string year = idCard.Substring(6, 4);
  4299. string month = idCard.Substring(10, 2);
  4300. string day = idCard.Substring(12, 2);
  4301. birthday = year + "/" + month + "/" + day;
  4302. }
  4303. dics.Add("BirthDay", birthday);//出生日期
  4304. dics.Add("Nationality", "中国");//国籍
  4305. dics.Add("NationalityCountry", "中国");//出生国
  4306. dics.Add("IdCard", idCard);//身份证号码
  4307. dics.Add("OtherPassProt", "√"); //默认没有其他护照
  4308. //判断是否否曾用名 是否申请过该国家
  4309. string isGetSchengenStr = custInfo.IsGetSchengen == 0 ? "否" : "是";
  4310. if (!string.IsNullOrEmpty(custInfo.OldName) && isGetSchengenStr.equals("是"))
  4311. {
  4312. dics.Add("IsGetSchengenYes", "√");
  4313. string oldName = custInfo?.OldName ?? "";
  4314. if (!string.IsNullOrEmpty(oldName))
  4315. {
  4316. dics.Add("OldLastName", oldName.Substring(0, 1));
  4317. dics.Add("OldFirstName", oldName.Remove(0, 1));
  4318. }
  4319. }
  4320. else
  4321. dics.Add("IsGetSchengenNo", "√");
  4322. dics.Add("IsDoubleNationality", "√"); //默认没有双重国籍
  4323. //护照
  4324. if (passportInfo != null)
  4325. {
  4326. dics.Add("PassprotNo", passportInfo?.CertNo ?? ""); // 护照編號
  4327. dics.Add("PassprotCountry", passportInfo?.Country ?? ""); // 护照签发国
  4328. dics.Add("PassprotIssuePlase", passportInfo?.Area ?? ""); // 护照签发地
  4329. dics.Add("PassprotStartTime", passportInfo?.IssueDt?.ToString("yyyy-MM-dd") ?? ""); //护照开始时间
  4330. dics.Add("PassprotEndTime", passportInfo?.ExpiryDt?.ToString("yyyy-MM-dd") ?? ""); // 护照过期时间
  4331. }
  4332. dics.Add("Address", custInfo?.Address ?? "");//现居家庭地址
  4333. dics.Add("Tel1", custInfo?.Tel ?? "");//移动电话 /家庭电话 /电子信箱
  4334. //dics.Add("Tel2", );//电子信箱
  4335. dics.Add("Email", custInfo?.Email ?? "");//电子信箱
  4336. //判断婚姻状况
  4337. var marriage = custInfo.Marriage switch
  4338. {
  4339. 1 => "未婚",
  4340. 2 => "已婚",
  4341. 3 => "离异",
  4342. 4 => "丧偶",
  4343. _ => "未设置"
  4344. };
  4345. if (marriage.Contains("未婚") || marriage == null || marriage == "")
  4346. dics.Add("Single", "√");
  4347. else if (marriage == "已婚")
  4348. dics.Add("Married", "√");
  4349. else if (marriage == "离婚" || marriage == "离异")
  4350. dics.Add("Divorced", "√");
  4351. //判断是否已婚 已婚则输出配偶信息
  4352. if (marriage == "已婚")
  4353. {
  4354. string mateName = custInfo?.MateName ?? "";
  4355. if (!string.IsNullOrEmpty(mateName))
  4356. {
  4357. try
  4358. {
  4359. string mateFirstName = mateName.Remove(0, 1);
  4360. dics.Add("MateLastName", mateName.Substring(0, 1)); //配偶姓
  4361. dics.Add("MateFirstName", mateFirstName); //配偶名
  4362. //dics.Add("MateLastName", MateName.Substring(0, 1)); //配偶姓
  4363. //dics.Add("MateFirstName", MateName.Substring(1, MateName.Length - 1)); //配偶名
  4364. }
  4365. catch { }
  4366. dics.Add("MateBirthDay", custInfo?.MateBirthDay.ToString("yyyy-MM-dd")); //配偶生日
  4367. //dics.Add("MateNationality", custInfo.ma.ToString()); //配偶国籍
  4368. //dics.Add("MateTel", custInfo..ToString()); //配偶联系电话
  4369. dics.Add("MateAddress", custInfo.MateAddress.ToString()); //配偶居住地址
  4370. //家人信息书签
  4371. if (currFamilyInfos.Count > 0)
  4372. {
  4373. //定义接受子女人数
  4374. int children = currFamilyInfos.Where(x => x.Appellation.contains("儿子") || x.Appellation.contains("女儿")).ToList().Count;
  4375. //判断子女人数
  4376. if (children == 0) //无子女
  4377. dics.Add("NoChildren", "√"); //未查询出 则无子女
  4378. else
  4379. {
  4380. dics.Add("HaveChildren", "√");
  4381. dics.Add("ChildrenNum", children.ToString());//有子女则输出人数
  4382. }
  4383. }
  4384. else
  4385. dics.Add("NoChildren", "√"); //未查询出 则无子女
  4386. }
  4387. }
  4388. else
  4389. dics.Add("NoChildren", "√"); //未婚则无子女
  4390. //学历
  4391. if (custInfo.HighestEducation.Contains("硕士") || custInfo.HighestEducation.Contains("博士"))
  4392. dics.Add("Master", "√");
  4393. else if (custInfo.HighestEducation.Contains("学士"))
  4394. dics.Add("Bachelor", "√");
  4395. else if (custInfo.HighestEducation.Contains("高中"))
  4396. dics.Add("HighSchool", "√");
  4397. else
  4398. {
  4399. dics.Add("Other", "√");
  4400. dics.Add("OtherDetails", custInfo.HighestEducation.Trim());
  4401. }
  4402. //dics.Add("Job", custInfo.Job.ToString()); ;//职业
  4403. dics.Add("Company", companyInfos.FirstOrDefault()?.Company ?? "");//单位名称
  4404. dics.Add("jobs", companyInfos.FirstOrDefault()?.Job ?? ""); //职务
  4405. dics.Add("CompanyAddress", companyInfos.FirstOrDefault()?.CompanyAddress ?? "");//单位地址
  4406. dics.Add("CompanyTel", companyInfos.FirstOrDefault()?.Phone ?? "");//单位电话
  4407. string day1 = ""; //得到抵达日期
  4408. string day2 = ""; //得到离开日期
  4409. string country = groupInfo.VisitCountry; //国家名
  4410. string HG_City = ""; //城市
  4411. string HG_Country = "";//国家
  4412. string[] HG_countryName = new string[] { };
  4413. if (!string.IsNullOrEmpty(country))
  4414. {
  4415. //处理国家名
  4416. if (country.Contains(" "))
  4417. HG_countryName = country.Split(' ');
  4418. else if (country.Contains(","))
  4419. HG_countryName = country.Split(',');
  4420. else if (country.Contains(","))
  4421. HG_countryName = country.Split(',');
  4422. else if (country.Contains("、"))
  4423. HG_countryName = country.Split('、');
  4424. }
  4425. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  4426. int k = 0;
  4427. for (int i = 0; i < HG_countryName.Length; i++)
  4428. {
  4429. for (int j = 0; j < atbc.Rows.Count; j++)
  4430. {
  4431. string HL_Three = atbc.Rows[j]["Three"].ToString();
  4432. if (!string.IsNullOrEmpty(HL_Three))
  4433. {
  4434. var hl_three = HL_Three.Substring(3);
  4435. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == hl_three).First();
  4436. if (tc != null)
  4437. {
  4438. HG_Country = HG_countryName[i];
  4439. HG_City = tc.City; //得到当前国家 城市名
  4440. day1 = atbc.Rows[j]["Day"].ToString(); //得到抵达日期
  4441. k = j + 1;
  4442. }
  4443. }
  4444. if (k == j)
  4445. day2 = atbc.Rows[j]["Day"].ToString(); //离开航班起飞时间
  4446. }
  4447. }
  4448. if (atbc != null)
  4449. {
  4450. if (day2 != null && day1 != null)
  4451. {
  4452. try
  4453. {
  4454. int Han_day = (Convert.ToDateTime(day2) - Convert.ToDateTime(day1)).Days; //得到天数
  4455. dics.Add("Days", Han_day.ToString() + "天");//滞留天数
  4456. dics.Add("EntryTime", day1.ToString());//入境日期 TemporaryAddress
  4457. }
  4458. catch (Exception) { }
  4459. }
  4460. }
  4461. //得到当前国家下的城市酒店信息
  4462. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  4463. .Where(x => x.DiId == groupId)
  4464. .Where(x => x.City.contains(HG_City))
  4465. .First();
  4466. //访问信息
  4467. if (hotelInfo != null)
  4468. {
  4469. dics.Add("TemporaryAddress", hotelInfo?.HotelAddress ?? "");//停留酒店地址 TATel
  4470. dics.Add("TATel", hotelInfo?.HotelTel ?? ""); //停留酒店联系电话
  4471. }
  4472. if (!string.IsNullOrEmpty(HG_Country) && !string.IsNullOrEmpty(HG_City))
  4473. {
  4474. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  4475. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  4476. .Where(x => x.Country.Contains(HG_Country))
  4477. .Where(x => x.Area.Contains(HG_City))
  4478. .First();
  4479. //在韩邀请方信息
  4480. if (oa != null)
  4481. {
  4482. dics.Add("IsYes", "√");
  4483. dics.Add("TT", oa?.Contact ?? ""); //联系人
  4484. dics.Add("TTAddress", oa?.Address ?? ""); //联系地址
  4485. dics.Add("TTtel", oa?.Tel ?? ""); //联系电话
  4486. dics.Add("TTGuanxi", "BY INVITED"); //和在邀联系人关系
  4487. }
  4488. else
  4489. dics.Add("IsNo", "√");
  4490. }
  4491. //费用信息
  4492. if (groupInfo != null)
  4493. {
  4494. //dics.Add("Payer", "Unit"); //在外期间费用承担
  4495. dics.Add("Team1", groupInfo.ClientUnit); //客户单位名称
  4496. dics.Add("Team12", "雇佣"); //与申请人关系 BY INVITED
  4497. dics.Add("PriceType", "Payment By Unit"); //资金类型
  4498. dics.Add("TeamNameTel", custInfo.ClientPhone); //联系方式
  4499. }
  4500. //是否有协助填表人
  4501. if (!string.IsNullOrEmpty(custInfo.TableOpName))
  4502. dics.Add("WirteTableNo", "√");
  4503. else
  4504. {
  4505. dics.Add("WirteTableYes", "√");
  4506. dics.Add("OpTableName", custInfo.TableOpName.ToString()); //协助填表人姓名
  4507. //dics.Add("OpTableDateTime",custInfo.OpDate.ToString()); //填表时间
  4508. dics.Add("OpTableTel", custInfo.TableOpTel.ToString()); //协助人联系电话
  4509. dics.Add("OpTableGuanXi", "雇佣"); //和协助人关系
  4510. }
  4511. dics.Add("NowDateTime", DateTime.Now.ToString("yyyy/MM/dd")); //获取当前系统时间
  4512. dics.Add("ApplicantName", custInfo.LastName + " " + custInfo.FirstName); //申请人
  4513. #endregion
  4514. #region 生成文件
  4515. try
  4516. {
  4517. Document doc = new(currTempPath);
  4518. Aspose.Words.DocumentBuilder builder = new(doc);
  4519. string strTemp = "";
  4520. //循环键值对
  4521. foreach (var key in dics.Keys)
  4522. {
  4523. //将光标移入书签的位置
  4524. builder.MoveToBookmark(key);
  4525. //判断书签值是否为空
  4526. if (!string.IsNullOrEmpty(dics[key]))
  4527. {
  4528. strTemp = dics[key];
  4529. }
  4530. else strTemp = "";
  4531. //填充书签
  4532. builder.Write(strTemp.Replace("\\N", "\n"));
  4533. }
  4534. var custName = custInfo.LastName + custInfo.FirstName;
  4535. string fileName = $"{custName}_{visaTypeName}.doc";
  4536. var currFilePath = $"{korSavePath}{fileName}";
  4537. doc.Save(currFilePath);
  4538. filePaths.Add(currFilePath);
  4539. }
  4540. catch (Exception ex)
  4541. {
  4542. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4543. }
  4544. #endregion
  4545. }
  4546. break;
  4547. case 4: // 瑞典
  4548. visaTypeName = $"瑞典签证申请表";
  4549. currTempPath = $"{tempPath}{visaTypeName}.pdf";
  4550. var swedenSavePath = $"{fileServerPath}{visaTypeName}/";
  4551. if (!Directory.Exists(swedenSavePath)) Directory.CreateDirectory(swedenSavePath);
  4552. if (!System.IO.File.Exists(currTempPath))
  4553. {
  4554. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4555. }
  4556. foreach (var custInfo in groupCustInfos)
  4557. {
  4558. EncryptionProcessor.DecryptProperties(custInfo);
  4559. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  4560. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  4561. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  4562. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4563. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4564. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4565. #region 生成文件
  4566. PdfReader reader = null;
  4567. FileStream templateStream = null;
  4568. FileStream outputStream = null;
  4569. PdfStamper stamper = null;
  4570. try
  4571. {
  4572. string outputPath = $"{swedenSavePath}{custInfo.LastName}{custInfo.FirstName}.pdf";
  4573. //读取模板文件
  4574. templateStream = new FileStream(currTempPath, FileMode.Open, FileAccess.Read, FileShare.Read);
  4575. reader = new PdfReader(templateStream);
  4576. //创建输出文件
  4577. outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write);
  4578. stamper = new PdfStamper(reader, outputStream);
  4579. AcroFields formFields = stamper.AcroFields;
  4580. #region 设置文本值
  4581. SetFieldValue(formFields, "LastName", custInfo.LastName); //姓
  4582. SetFieldValue(formFields, "BirthLastName", custInfo.LastName); // 出生时姓氏
  4583. SetFieldValue(formFields, "FirstName", custInfo.FirstName); // 名
  4584. // 出生日期(日-月-年)
  4585. string idCard = idInfo.CertNo;
  4586. string birthday = string.Empty;
  4587. if (!string.IsNullOrEmpty(idCard))
  4588. {
  4589. string year = idCard.Substring(6, 4);
  4590. string month = idCard.Substring(10, 2);
  4591. string day = idCard.Substring(12, 2);
  4592. birthday = day + "-" + month + "-" + year;
  4593. }
  4594. SetFieldValue(formFields, "Birthday", birthday);
  4595. string currentNationality = custInfo.BirthProvince + custInfo.BirthCity;
  4596. SetFieldValue(formFields, "CurrentNationality", currentNationality); // 出生地
  4597. SetFieldValue(formFields, "CountryBirth","中国"); // 出生国
  4598. SetFieldValue(formFields, "CurrentNationalityCountry", "中国"); // 现国籍
  4599. SetFieldValue(formFields, "NationalityBirth", ""); // 出生时国籍,如与现国籍不同
  4600. SetFieldValue(formFields, "OtherNationalities", ""); // 其他国籍
  4601. #region 性别处理
  4602. //清除性别
  4603. SetFieldValue(formFields, "Male", "Off"); // 性别 - 男
  4604. SetFieldValue(formFields, "Female", "Off"); // 性别 - 女
  4605. //设置性别
  4606. if (custInfo.Sex == 0) //男
  4607. {
  4608. SetFieldValue(formFields, "Male", "Yes"); // 性别 - 男
  4609. }
  4610. else if (custInfo.Sex == 1) //女
  4611. {
  4612. SetFieldValue(formFields, "Female", "Yes"); // 性别 - 女
  4613. }
  4614. #endregion
  4615. #region 婚姻状况处理
  4616. //清除婚姻状况
  4617. SetFieldValue(formFields, "Single", "Off"); // 婚姻状况 - 未婚
  4618. SetFieldValue(formFields, "Married", "Off"); // 婚姻状况 - 已婚
  4619. SetFieldValue(formFields, "RegisteredPartnership", "Off"); // 婚姻状况 - 注册伴侣关系
  4620. SetFieldValue(formFields, "Separated", "Off"); // 婚姻状况 - 分居
  4621. SetFieldValue(formFields, "Divorced", "Off"); // 婚姻状况 - 离婚
  4622. SetFieldValue(formFields, "Widow(er)", "Off"); // 婚姻状况 - 丧偶
  4623. SetFieldValue(formFields, "OtherCivilStatus", "Off"); // 婚姻状况 - 其它
  4624. SetFieldValue(formFields, "CivilStatusOther", ""); // 婚姻状况 - 其它(请注明)
  4625. //设置婚姻状况
  4626. switch (custInfo.Marriage)
  4627. {
  4628. case 1: // 未婚
  4629. SetFieldValue(formFields, "Single", "Yes");
  4630. break;
  4631. case 2: // 已婚
  4632. SetFieldValue(formFields, "Married", "Yes");
  4633. break;
  4634. case 3: // 离异
  4635. SetFieldValue(formFields, "Divorced", "Yes");
  4636. break;
  4637. case 4: // 离异
  4638. SetFieldValue(formFields, "Widow(er)", "Yes");
  4639. break;
  4640. }
  4641. #endregion
  4642. //亲权人(如是未成年申请人 )/合法监护人(姓名、住址,如与申请人不同) 电话号码、电子邮件及国籍
  4643. SetFieldValue(formFields, "ParentalAuthority", "");
  4644. SetFieldValue(formFields, "NationalIdentityNumber", idCard); //公民身份证号码
  4645. #region 护照(旅行证件类型)处理
  4646. //清除值
  4647. SetFieldValue(formFields, "OrdinaryPassport", "Off"); //旅行证件类型 - 普通护照
  4648. SetFieldValue(formFields, "DiplomaticPassport", "Off"); //旅行证件类型 - 外交护照
  4649. SetFieldValue(formFields, "ServicePassport", "Off"); //旅行证件类型 - 公务护照
  4650. SetFieldValue(formFields, "OfficialPassport", "Off"); //旅行证件类型 - 因公护照
  4651. SetFieldValue(formFields, "SpecialPassport", "Off"); //旅行证件类型 - 特殊护照
  4652. SetFieldValue(formFields, "OtherTravel", "Off"); //旅行证件类型 - 其它旅行证件
  4653. SetFieldValue(formFields, "OtherTravelDesc", ""); //旅行证件类型 - 其它旅行证件(请注明)
  4654. //设置值
  4655. SetFieldValue(formFields, "OrdinaryPassport", "Yes"); //旅行证件类型 - 普通护照
  4656. if (passportInfo != null)
  4657. {
  4658. SetFieldValue(formFields, "TravelNumber", passportInfo.CertNo); //旅行证件编号
  4659. SetFieldValue(formFields, "IssueDate", passportInfo.IssueDt?.ToString("yyyy-MM-dd") ?? ""); //签发日期
  4660. SetFieldValue(formFields, "ValidUntil", passportInfo.ExpiryDt?.ToString("yyyy-MM-dd") ?? ""); //有效期至
  4661. SetFieldValue(formFields, "IssuedCountry", passportInfo.Country); //签发(国)
  4662. }
  4663. #endregion
  4664. //如有家庭成员为欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的,请填写该家庭成员的个人信息
  4665. SetFieldValue(formFields, "LastName_om", ""); //姓
  4666. SetFieldValue(formFields, "FirstName_om", ""); //名
  4667. SetFieldValue(formFields, "BirthDate_om", ""); //出生日期(日-月-年)
  4668. SetFieldValue(formFields, "Nationality_om", ""); //国籍
  4669. SetFieldValue(formFields, "TravelNuber_om", ""); //旅行证件或身分证编号
  4670. //申请人与欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的关系
  4671. SetFieldValue(formFields, "Spouse_om", ""); //配偶
  4672. SetFieldValue(formFields, "RegisteredPartnership_om", ""); //注册伴侣
  4673. SetFieldValue(formFields, "Child_om", ""); //子女
  4674. SetFieldValue(formFields, "DependentAscendant_om", ""); //受养人
  4675. SetFieldValue(formFields, "Grandchild_om", ""); //孙子女
  4676. SetFieldValue(formFields, "FamilyOther_om", ""); //其他
  4677. SetFieldValue(formFields, "FamilyOtherDesc_om", ""); //其他(说明)
  4678. //申请人住址及电子邮件
  4679. string applicantHomeAddress = $"{custInfo.Address} {custInfo.Email}";
  4680. SetFieldValue(formFields, "ApplicantHomeAddress", applicantHomeAddress); //申请人住址及电子邮件
  4681. SetFieldValue(formFields, "TelephoneNo", custInfo.Tel); //电话号码
  4682. //是否居住在现时国籍以外的国家
  4683. SetFieldValue(formFields, "AnotherCountryNo", "Yes"); //否
  4684. SetFieldValue(formFields, "AnotherCountryYes", ""); //是。
  4685. SetFieldValue(formFields, "ResidencePermit", ""); //居住许可或同等证
  4686. SetFieldValue(formFields, "Number", ""); //编号
  4687. SetFieldValue(formFields, "ValidUntils", ""); //有效期至
  4688. SetFieldValue(formFields, "CurrentOccupation", custInfo.Job); //当前职业
  4689. //工作单位名称,地址和电话,学生填写学校名称及地址
  4690. var currCompanyInfo = currCompanyInfos.FirstOrDefault();
  4691. string employerInfoStr = $"{currCompanyInfo?.Company ?? ""} {currCompanyInfo?.CompanyAddress ?? ""} {currCompanyInfo?.Phone ?? ""}";
  4692. SetFieldValue(formFields, "EmployerInfo", employerInfoStr);
  4693. #region 旅行的目的
  4694. //清空值
  4695. SetFieldValue(formFields, "Tourism", "Off"); //旅游
  4696. SetFieldValue(formFields, "Business", "Off"); //商务
  4697. SetFieldValue(formFields, "VisitingFamily", "Off"); //探亲访友
  4698. SetFieldValue(formFields, "Cultural", "Off"); //文化
  4699. SetFieldValue(formFields, "Sports", "Off"); //体育
  4700. SetFieldValue(formFields, "OfficialVisit", "Off"); //官方访问
  4701. SetFieldValue(formFields, "MedicalReasons", "Off"); //医疗
  4702. SetFieldValue(formFields, "Study", "Off"); //学习
  4703. SetFieldValue(formFields, "AirportTransit", "Off"); //机场过境
  4704. SetFieldValue(formFields, "Other", "Off"); //其它
  4705. SetFieldValue(formFields, "OtherDesc", ""); //其它 (请注明)
  4706. //设置值
  4707. if (groupInfo.VisitPurpose.contains("旅游")) SetFieldValue(formFields, "Tourism", "Yes"); //旅游
  4708. if (groupInfo.VisitPurpose.contains("商务")) SetFieldValue(formFields, "Business", "Yes"); //商务
  4709. if (groupInfo.VisitPurpose.contains("探亲访友")) SetFieldValue(formFields, "VisitingFamily", "Yes"); //探亲访友
  4710. if (groupInfo.VisitPurpose.contains("文化")) SetFieldValue(formFields, "Cultural", "Yes"); //文化
  4711. if (groupInfo.VisitPurpose.contains("体育")) SetFieldValue(formFields, "Sports", "Yes"); //体育
  4712. if (groupInfo.VisitPurpose.contains("官方访问")) SetFieldValue(formFields, "OfficialVisit", "Yes"); //官方访问
  4713. if (groupInfo.VisitPurpose.contains("医疗")) SetFieldValue(formFields, "MedicalReasons", "Yes"); //医疗
  4714. if (groupInfo.VisitPurpose.contains("学习")) SetFieldValue(formFields, "Study", "Yes"); //学习
  4715. if (groupInfo.VisitPurpose.contains("机场过境")) SetFieldValue(formFields, "AirportTransit", "Yes"); //机场过境
  4716. #endregion
  4717. SetFieldValue(formFields, "AdditionalInfo", ""); //有关停留原因的补充信息
  4718. string[] RD_country = new string[] { }; //接收处理的国家
  4719. string firstEntryLabel = string.Empty; //首入申根国标签
  4720. string membeDescLabel = string.Empty; //申根国目的地
  4721. string stopDays = string.Empty; //停留天数
  4722. if (!string.IsNullOrEmpty(groupInfo.VisitCountry))
  4723. {
  4724. List<string> SGGNames = new List<string>();//接收处理后的国家 是申根国
  4725. if (groupInfo.VisitCountry.Contains(","))
  4726. RD_country = groupInfo.VisitCountry.Split(',');
  4727. else if (groupInfo.VisitCountry.Contains(' '))
  4728. RD_country = groupInfo.VisitCountry.Split(' ');
  4729. else if (groupInfo.VisitCountry.Contains(","))
  4730. RD_country = groupInfo.VisitCountry.Split(',');
  4731. else if (groupInfo.VisitCountry.Contains("、"))
  4732. RD_country = groupInfo.VisitCountry.Split('、');
  4733. else if (groupInfo.VisitCountry.Contains("|"))
  4734. RD_country = groupInfo.VisitCountry.Split('|');
  4735. //判断是否是申根国家
  4736. for (int i = 0; i < RD_country.Length; i++)
  4737. {
  4738. if (RD_country[i].ToString() != null)
  4739. {
  4740. //在申根国家中筛选 该国家是否是申根国家
  4741. for (int j = 0; j < _shenGenGuos.Length; j++)
  4742. {
  4743. if (RD_country[i] == _shenGenGuos[j])
  4744. SGGNames.Add(_shenGenGuos[j]); //添加申根国
  4745. }
  4746. }
  4747. }
  4748. //目的地国是否有申根国
  4749. if (SGGNames.Count > 0)
  4750. {
  4751. firstEntryLabel = SGGNames.First();
  4752. membeDescLabel = string.Join(",", SGGNames.ToArray());
  4753. //接收生根国详细信息 存储顺序 起飞日期:Day 起飞时刻:StartTime 抵达日期:ArrivedDate 到达时刻:EndTime
  4754. List<SSGDetails> ListSSGDetails = new List<SSGDetails>();
  4755. //处理申根国家 预定到达时间 预定离开时间 预定停留天数
  4756. for (int i = 0; i < SGGNames.Count; i++)
  4757. {
  4758. //在相同的国家下 得到该航班的信息 //抵达时间 起飞日期:Day 起飞时刻:StartTime 到达时刻:EndTime 抵达日期:ArrivedDate 飞行时间:FlightTime 航司 Fliagtcode 入境口岸
  4759. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  4760. //ResidenceTime1 机票三字码信息
  4761. if (atbc != null)
  4762. {
  4763. string HL_Three = ""; //三字码 Three
  4764. for (int j = 0; j < atbc.Rows.Count; j++)
  4765. {
  4766. HL_Three = atbc.Rows[j]["Three"].ToString();
  4767. if (!string.IsNullOrEmpty(HL_Three))
  4768. {
  4769. string threeCodeTwo = HL_Three.Substring(3);
  4770. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == threeCodeTwo).First();
  4771. if (tc != null)
  4772. {
  4773. //首入申根国时间
  4774. if (SGGNames[i] == tc.Country)
  4775. {
  4776. SSGDetails SSGDetails = new SSGDetails()
  4777. {
  4778. Three = atbc.Rows[j]["Three"].ToString(), //三字码
  4779. Fliagtcode = atbc.Rows[j]["Fliagtcode"].ToString(), //航司
  4780. startDate = atbc.Rows[j]["Day"].ToString(), //整理起飞日期
  4781. startTime = atbc.Rows[j]["StartTime"].ToString(), //整理起飞时刻
  4782. endDate = atbc.Rows[j]["ArrivedDate"].ToString(), //整理抵达日期
  4783. endTime = atbc.Rows[j]["EndTime"].ToString() //整理抵达时刻
  4784. };
  4785. ListSSGDetails.Add(SSGDetails);
  4786. }
  4787. }
  4788. }
  4789. }
  4790. }
  4791. }
  4792. ListSSGDetails.Sort((a, b) => a.startDate.CompareTo(b.startDate));
  4793. //得到并计算出入境时间
  4794. if (ListSSGDetails != null)
  4795. {
  4796. string RuJingTime = ListSSGDetails.First().endDate + " " + ListSSGDetails.First().endTime.Substring(0, 2) + ":" + ListSSGDetails.First().endTime.Substring(2); //入境时间
  4797. string LiJingTime = ListSSGDetails[ListSSGDetails.Count - 1].startDate + " " + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(0, 2) + ":" + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(2); //离境时间
  4798. stopDays = Convert.ToDateTime(LiJingTime).Subtract(Convert.ToDateTime(RuJingTime)).Days.ToString();
  4799. }
  4800. }
  4801. }
  4802. SetFieldValue(formFields, "MembeDesc", membeDescLabel); //主要申根目的地 (以及其他申根目的地,如适用)
  4803. SetFieldValue(formFields, "FirstEntry", firstEntryLabel); //首入申根国
  4804. //申请入境次数
  4805. SetFieldValue(formFields, "27.SingleEntry", ""); //单次
  4806. SetFieldValue(formFields, "27.TwoEntries", ""); //两次
  4807. SetFieldValue(formFields, "27.MultipleEntries", ""); //多次
  4808. SetFieldValue(formFields, "27.IntendedDateIn", ""); //在申根地区预计首次停留的预计抵达日期
  4809. SetFieldValue(formFields, "27.IntendedDateOut", ""); //在申根地区预计首次停留之后的预计离开日期
  4810. //以往申根国签证是否有指纹记录
  4811. SetFieldValue(formFields, "28.No", ""); //否
  4812. SetFieldValue(formFields, "28.Yes", ""); //是
  4813. SetFieldValue(formFields, "28.KnownDate", ""); //如有,请写明日期
  4814. SetFieldValue(formFields, "28.KnownVisanumber", ""); //如有,请写明签证贴纸号码
  4815. //最后目的地之入境许可
  4816. SetFieldValue(formFields, "29.Issued", ""); //签发机关
  4817. SetFieldValue(formFields, "29.ValidFrom", ""); //有效期由
  4818. SetFieldValue(formFields, "29.Until", ""); //至
  4819. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  4820. //得到当前国家下的城市酒店信息
  4821. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  4822. .Where(x => x.DiId == groupId)
  4823. //.Where(x => x.City.contains(city))
  4824. .First();
  4825. //酒店住址
  4826. if (hotelInfo != null)
  4827. {
  4828. SetFieldValue(formFields, "30.SurnameFirstName", hotelInfo?.HotelName ?? ""); //申根国的酒店
  4829. var otherInfo = $"{hotelInfo.HotelAddress}";
  4830. SetFieldValue(formFields, "30.HotelInfo", otherInfo); //邀请人/酒店/暂住居所的地址及电子邮件
  4831. SetFieldValue(formFields, "30.TelephoneNo", hotelInfo?.HotelTel ?? ""); //电话号码
  4832. }
  4833. //邀请公司或机构的名称及地址
  4834. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  4835. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  4836. //.Where(x => x.Country.Contains(county))
  4837. //.Where(x => x.Area.Contains(city))
  4838. .First();
  4839. if (oa != null)
  4840. {
  4841. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  4842. SetFieldValue(formFields, "30.SurnameFirstName", oa?.Contact ?? ""); //申根国的酒店
  4843. SetFieldValue(formFields, "30.HotelInfo", oa?.Address ?? ""); //邀请人/酒店/暂住居所的地址及电子邮件
  4844. SetFieldValue(formFields, "30.TelephoneNo", oa?.Tel ?? ""); //电话号码
  4845. string nameAddressLabel = $"{oa.Client} {oa.Address}";
  4846. SetFieldValue(formFields, "31.NameAddress", nameAddressLabel); //邀请公司或机构的名称及地址
  4847. string surnameLabel = $"{oa.Contact} {oa.Tel}";
  4848. SetFieldValue(formFields, "31.Surname", surnameLabel); //邀请公司或机构的联系人姓名、地址、电话号码及电子邮件
  4849. SetFieldValue(formFields, "31.TelephoneNo", oa?.Tel ?? ""); //邀请公司或机构的电话
  4850. }
  4851. //申请人的旅费以及在国外停留期间的生活费用
  4852. SetFieldValue(formFields, "32.Applicant", ""); //由申请人支付
  4853. SetFieldValue(formFields, "32.Cash", ""); //支付方式 - 现金
  4854. SetFieldValue(formFields, "32.Traveller", ""); //支付方式 - 旅行支票
  4855. SetFieldValue(formFields, "32.CreditCard", ""); //支付方式 - 信用卡
  4856. SetFieldValue(formFields, "32.Prepaid", ""); //支付方式 - 预缴住宿
  4857. SetFieldValue(formFields, "32.Prepaid1", ""); //支付方式 - 预缴交通
  4858. SetFieldValue(formFields, "32.OtherMeans", ""); //支付方式 - 其它
  4859. SetFieldValue(formFields, "32.OtherMeansDesc", ""); //支付方式 - 其它(请注明)
  4860. SetFieldValue(formFields, "32.Sponsor", ""); //由赞助方(邀请人、公司或机构)支付,请注明
  4861. SetFieldValue(formFields, "32.Referred", ""); //参见第 30 及 31 项
  4862. SetFieldValue(formFields, "32.ReferredDesc", ""); //参见第 30 及 31 项(请注明)
  4863. SetFieldValue(formFields, "32.OtherSponsor", ""); //其它
  4864. SetFieldValue(formFields, "32.OtherSponsorDesc", ""); //其它(请注明)
  4865. SetFieldValue(formFields, "32.SponsorCash", ""); //赞助方式 - 现金
  4866. SetFieldValue(formFields, "32.SponsorAccommodation", ""); //赞助方式 - 提供住宿
  4867. SetFieldValue(formFields, "32.SponsorExpenses", ""); //赞助方式 - 支付旅程期间所有开支
  4868. SetFieldValue(formFields, "32.SponsorPrepaid", ""); //赞助方式 - 预缴交通
  4869. SetFieldValue(formFields, "32.ponsorOther", ""); //赞助方式 - 其它
  4870. SetFieldValue(formFields, "32.ponsorOtherDesc", ""); //赞助方式 - 其它(请注明)
  4871. SetFieldValue(formFields, "33.PlaceAndDate", DateTime.Now.ToString("yyyy-MM-dd")); //地点及日期
  4872. #endregion
  4873. filePaths.Add(outputPath);
  4874. //return outputPath;
  4875. }
  4876. catch (Exception ex)
  4877. {
  4878. return Ok(JsonView(false, $"生成PDF文件时出错:{ex.Message}"));
  4879. }
  4880. finally
  4881. {
  4882. // 按正确顺序关闭资源
  4883. stamper?.Close();
  4884. reader?.Close();
  4885. templateStream?.Close();
  4886. outputStream?.Close();
  4887. }
  4888. #endregion
  4889. }
  4890. break;
  4891. case 5: // 波兰
  4892. visaTypeName = $"波兰签证申请表";
  4893. currTempPath = $"{tempPath}{visaTypeName}.pdf";
  4894. var polandSavePath = $"{fileServerPath}{visaTypeName}/";
  4895. if (!Directory.Exists(polandSavePath)) Directory.CreateDirectory(polandSavePath);
  4896. if (!System.IO.File.Exists(currTempPath))
  4897. {
  4898. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4899. }
  4900. foreach (var custInfo in groupCustInfos)
  4901. {
  4902. EncryptionProcessor.DecryptProperties(custInfo);
  4903. var visaData = new VisaDateView() {
  4904. groupInfo = groupInfo,
  4905. idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773),
  4906. passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774),
  4907. custInfo = custInfo,
  4908. schoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList(),
  4909. familyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList(),
  4910. companyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList()
  4911. };
  4912. //生成文件
  4913. string outFilePath = CreatePolandVisaPdf(visaData, polandSavePath, currTempPath);
  4914. filePaths.Add(outFilePath);
  4915. }
  4916. break;
  4917. default:
  4918. return Ok(JsonView(false, "正在开发中,请等待。。。"));
  4919. }
  4920. //压缩文件
  4921. var zipFilePathName = $"{groupInfo.TeamName}({visaTypeName}).zip";
  4922. var zipFilePath = $"{fileServerPath}{zipFilePathName}";
  4923. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4924. {
  4925. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4926. {
  4927. foreach (string filePath in filePaths)
  4928. {
  4929. if (System.IO.File.Exists(filePath))
  4930. {
  4931. // 获取文件名
  4932. string fileName = Path.GetFileName(filePath);
  4933. // 将文件添加到ZIP归档中
  4934. zipArchive.CreateEntryFromFile(filePath, fileName);
  4935. }
  4936. }
  4937. }
  4938. }
  4939. url = $"{serverPath}{zipFilePathName}";
  4940. if (!string.IsNullOrEmpty(url))
  4941. {
  4942. return Ok(JsonView(true, url));
  4943. }
  4944. return Ok(JsonView(false, "操作失败!"));
  4945. }
  4946. #region iTextSharp pdf 设置值辅助方法
  4947. /// <summary>
  4948. /// 设置文本值
  4949. /// 辅助方法
  4950. /// </summary>
  4951. /// <param name="formFields"></param>
  4952. /// <param name="fieldName"></param>
  4953. /// <param name="value"></param>
  4954. private static void SetFieldValue(AcroFields formFields, string fieldName, string value)
  4955. {
  4956. if (formFields.Fields.ContainsKey(fieldName) && !string.IsNullOrEmpty(value))
  4957. {
  4958. formFields.SetField(fieldName, value);
  4959. }
  4960. }
  4961. /// <summary>
  4962. /// 创建PDF
  4963. /// </summary>
  4964. /// <param name="data"></param>
  4965. /// <param name="currSavePath"></param>
  4966. /// <param name="currTempPath"></param>
  4967. /// <returns></returns>
  4968. /// <exception cref="Exception"></exception>
  4969. private string CreatePolandVisaPdf(VisaDateView data, string currSavePath,string currTempPath)
  4970. {
  4971. var groupInfo = data.groupInfo;
  4972. var groupId = groupInfo.Id;
  4973. var idInfo = data.idInfo;
  4974. var passportInfo = data.passportInfo;
  4975. var custInfo = data.custInfo;
  4976. var currSchoolInfos = data.schoolInfos;
  4977. var currFamilyInfos = data.familyInfos;
  4978. var currCompanyInfos = data.companyInfos;
  4979. string outputPath = $"{currSavePath}{custInfo.LastName}{custInfo.FirstName}.pdf";
  4980. PdfReader reader = null;
  4981. FileStream templateStream = null;
  4982. FileStream outputStream = null;
  4983. PdfStamper stamper = null;
  4984. try
  4985. {
  4986. //读取模板文件
  4987. templateStream = new FileStream(currTempPath, FileMode.Open, FileAccess.Read, FileShare.Read);
  4988. reader = new PdfReader(templateStream);
  4989. //创建输出文件
  4990. outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write);
  4991. stamper = new PdfStamper(reader, outputStream);
  4992. AcroFields formFields = stamper.AcroFields;
  4993. #region 设置文本值
  4994. SetFieldValue(formFields, "1.LastName", custInfo.LastName); //姓
  4995. SetFieldValue(formFields, "2.BirthLastName", custInfo.LastName); // 出生时姓氏
  4996. SetFieldValue(formFields, "3.FirstName", custInfo.FirstName); // 名
  4997. // 出生日期(日-月-年)
  4998. string idCard = idInfo.CertNo;
  4999. string birthday = string.Empty;
  5000. if (!string.IsNullOrEmpty(idCard))
  5001. {
  5002. string year = idCard.Substring(6, 4);
  5003. string month = idCard.Substring(10, 2);
  5004. string day = idCard.Substring(12, 2);
  5005. birthday = day + "-" + month + "-" + year;
  5006. }
  5007. SetFieldValue(formFields, "4.Birthday", birthday);
  5008. string currentNationality = custInfo.BirthProvince + custInfo.BirthCity;
  5009. SetFieldValue(formFields, "5.CurrentNationality", currentNationality); // 出生地
  5010. SetFieldValue(formFields, "6.CountryBirth", "中国"); // 出生国
  5011. SetFieldValue(formFields, "7.CurrentNationalityCountry", "中国"); // 现国籍
  5012. SetFieldValue(formFields, "7.NationalityBirth", ""); // 出生时国籍,如与现国籍不同
  5013. SetFieldValue(formFields, "7.OtherNationalities", ""); // 其他国籍
  5014. #region 性别处理
  5015. //清除性别
  5016. SetFieldValue(formFields, "8.Male", "Off"); // 性别 - 男
  5017. SetFieldValue(formFields, "8.Female", "Off"); // 性别 - 女
  5018. SetFieldValue(formFields, "8.Other", "Off"); // 性别 - 其他
  5019. //设置性别
  5020. if (custInfo.Sex == 0) //男
  5021. {
  5022. SetFieldValue(formFields, "8.Male", "Yes"); // 性别 - 男
  5023. }
  5024. else if (custInfo.Sex == 1) //女
  5025. {
  5026. SetFieldValue(formFields, "8.Female", "Yes"); // 性别 - 女
  5027. }
  5028. else //其他
  5029. {
  5030. SetFieldValue(formFields, "8.Other", "Yes"); // 性别 - 其他
  5031. }
  5032. #endregion
  5033. #region 婚姻状况处理
  5034. //清除婚姻状况
  5035. SetFieldValue(formFields, "9.Single", "Off"); // 婚姻状况 - 未婚
  5036. SetFieldValue(formFields, "9.Married", "Off"); // 婚姻状况 - 已婚
  5037. SetFieldValue(formFields, "9.RegisteredPartnership", "Off"); // 婚姻状况 - 注册伴侣关系
  5038. SetFieldValue(formFields, "9.Separated", "Off"); // 婚姻状况 - 分居
  5039. SetFieldValue(formFields, "9.Divorced", "Off"); // 婚姻状况 - 离婚
  5040. SetFieldValue(formFields, "9.Widow(er)", "Off"); // 婚姻状况 - 丧偶
  5041. SetFieldValue(formFields, "9.OtherCivilStatus", "Off"); // 婚姻状况 - 其它
  5042. SetFieldValue(formFields, "9.CivilStatusOther", ""); // 婚姻状况 - 其它(请注明)
  5043. //设置婚姻状况
  5044. switch (custInfo.Marriage)
  5045. {
  5046. case 1: // 未婚
  5047. SetFieldValue(formFields, "9.Single", "Yes");
  5048. break;
  5049. case 2: // 已婚
  5050. SetFieldValue(formFields, "9.Married", "Yes");
  5051. break;
  5052. case 3: // 离异
  5053. SetFieldValue(formFields, "9.Divorced", "Yes");
  5054. break;
  5055. case 4: // 离异
  5056. SetFieldValue(formFields, "9.Widow(er)", "Yes");
  5057. break;
  5058. }
  5059. #endregion
  5060. //亲权人(如是未成年申请人 )/合法监护人(姓名、住址,如与申请人不同) 电话号码、电子邮件及国籍
  5061. SetFieldValue(formFields, "10.ParentalAuthority", "");
  5062. SetFieldValue(formFields, "11.NationalIdentityNumber", idCard); //公民身份证号码
  5063. #region 护照(旅行证件类型)处理
  5064. //清除值
  5065. SetFieldValue(formFields, "12.OrdinaryPassport", "Off"); //旅行证件类型 - 普通护照
  5066. SetFieldValue(formFields, "12.DiplomaticPassport", "Off"); //旅行证件类型 - 外交护照
  5067. SetFieldValue(formFields, "12.ServicePassport", "Off"); //旅行证件类型 - 公务护照
  5068. SetFieldValue(formFields, "12.OfficialPassport", "Off"); //旅行证件类型 - 因公护照
  5069. SetFieldValue(formFields, "12.SpecialPassport", "Off"); //旅行证件类型 - 特殊护照
  5070. SetFieldValue(formFields, "12.OtherTravel", "Off"); //旅行证件类型 - 其它旅行证件
  5071. SetFieldValue(formFields, "12.OtherTravelDesc", ""); //旅行证件类型 - 其它旅行证件(请注明)
  5072. //设置值
  5073. SetFieldValue(formFields, "12.OrdinaryPassport", "Yes"); //旅行证件类型 - 普通护照
  5074. if (passportInfo != null)
  5075. {
  5076. SetFieldValue(formFields, "13.TravelNumber", passportInfo.CertNo); //旅行证件编号
  5077. SetFieldValue(formFields, "14.IssueDate", passportInfo.IssueDt?.ToString("yyyy-MM-dd") ?? ""); //签发日期
  5078. SetFieldValue(formFields, "15.ValidUntil", passportInfo.ExpiryDt?.ToString("yyyy-MM-dd") ?? ""); //有效期至
  5079. SetFieldValue(formFields, "16.IssuedCountry", passportInfo.Country); //签发(国)
  5080. }
  5081. #endregion
  5082. //如有家庭成员为欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的,请填写该家庭成员的个人信息
  5083. SetFieldValue(formFields, "17.LastName_om", ""); //姓
  5084. SetFieldValue(formFields, "17.FirstName_om", ""); //名
  5085. SetFieldValue(formFields, "17.BirthDate_om", ""); //出生日期(日-月-年)
  5086. SetFieldValue(formFields, "17.Nationality_om", ""); //国籍
  5087. SetFieldValue(formFields, "17.TravelNuber_om", ""); //旅行证件或身分证编号
  5088. //申请人与欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的关系
  5089. SetFieldValue(formFields, "18.Spouse_om", ""); //配偶
  5090. SetFieldValue(formFields, "18.RegisteredPartnership_om", ""); //注册伴侣
  5091. SetFieldValue(formFields, "18.Child_om", ""); //子女
  5092. SetFieldValue(formFields, "18.DependentAscendant_om", ""); //受养人
  5093. SetFieldValue(formFields, "18.Grandchild_om", ""); //孙子女
  5094. SetFieldValue(formFields, "18.FamilyOther_om", ""); //其他
  5095. SetFieldValue(formFields, "18.FamilyOtherDesc_om", ""); //其他(说明)
  5096. //申请人住址及电子邮件
  5097. string applicantHomeAddress = $"{custInfo.Address} {custInfo.Email}";
  5098. SetFieldValue(formFields, "19.ApplicantHomeAddress", applicantHomeAddress); //申请人住址及电子邮件
  5099. SetFieldValue(formFields, "19.TelephoneNo", custInfo.Tel); //电话号码
  5100. //是否居住在现时国籍以外的国家
  5101. SetFieldValue(formFields, "20.AnotherCountryNo", "Yes"); //否
  5102. SetFieldValue(formFields, "20.AnotherCountryYes", ""); //是
  5103. SetFieldValue(formFields, "20.ResidencePermit", ""); //居住许可或同等证
  5104. SetFieldValue(formFields, "20.Number", ""); //编号
  5105. SetFieldValue(formFields, "20.ValidUntils", ""); //有效期至
  5106. SetFieldValue(formFields, "21.CurrentOccupation", custInfo.Job); //当前职业
  5107. //工作单位名称,地址和电话,学生填写学校名称及地址
  5108. var currCompanyInfo = currCompanyInfos.FirstOrDefault();
  5109. string employerInfoStr = $"{currCompanyInfo?.Company ?? ""} {currCompanyInfo?.CompanyAddress ?? ""} {currCompanyInfo?.Phone ?? ""}";
  5110. SetFieldValue(formFields, "22.EmployerInfo", employerInfoStr);
  5111. #region 旅行的目的
  5112. //清空值
  5113. SetFieldValue(formFields, "23.Tourism", "Off"); // 旅游
  5114. SetFieldValue(formFields, "23.Business", "Off"); // 商务
  5115. SetFieldValue(formFields, "23.VisitingFamily", "Off"); // 探亲访友
  5116. SetFieldValue(formFields, "23.Cultural", "Off"); // 文化
  5117. SetFieldValue(formFields, "23.Sports", "Off"); // 体育
  5118. SetFieldValue(formFields, "23.OfficialVisit", "Off"); // 官方访问
  5119. SetFieldValue(formFields, "23.MedicalReasons", "Off"); // 医疗
  5120. SetFieldValue(formFields, "23.Study", "Off"); // 学习
  5121. SetFieldValue(formFields, "23.AirportTransit", "Off"); // 机场过境
  5122. SetFieldValue(formFields, "23.Other", "Off"); // 其它
  5123. SetFieldValue(formFields, "23.OtherDesc", ""); // 其它 (请注明)
  5124. //设置值
  5125. if (groupInfo.VisitPurpose.contains("旅游")) SetFieldValue(formFields, "23.Tourism", "Yes"); //旅游
  5126. if (groupInfo.VisitPurpose.contains("商务")) SetFieldValue(formFields, "23.Business", "Yes"); //商务
  5127. if (groupInfo.VisitPurpose.contains("探亲访友")) SetFieldValue(formFields, "23.VisitingFamily", "Yes"); //探亲访友
  5128. if (groupInfo.VisitPurpose.contains("文化")) SetFieldValue(formFields, "23.Cultural", "Yes"); //文化
  5129. if (groupInfo.VisitPurpose.contains("体育")) SetFieldValue(formFields, "23.Sports", "Yes"); //体育
  5130. if (groupInfo.VisitPurpose.contains("官方访问")) SetFieldValue(formFields, "23.OfficialVisit", "Yes"); //官方访问
  5131. if (groupInfo.VisitPurpose.contains("医疗")) SetFieldValue(formFields, "23.MedicalReasons", "Yes"); //医疗
  5132. if (groupInfo.VisitPurpose.contains("学习")) SetFieldValue(formFields, "23.Study", "Yes"); //学习
  5133. if (groupInfo.VisitPurpose.contains("机场过境")) SetFieldValue(formFields, "23.AirportTransit", "Yes"); //机场过境
  5134. #endregion
  5135. SetFieldValue(formFields, "24.AdditionalInfo", ""); //有关停留原因的补充信息
  5136. string[] RD_country = new string[] { }; //接收处理的国家
  5137. string firstEntryLabel = string.Empty; //首入申根国标签
  5138. string membeDescLabel = string.Empty; //申根国目的地
  5139. string stopDays = string.Empty; //停留天数
  5140. if (!string.IsNullOrEmpty(groupInfo.VisitCountry))
  5141. {
  5142. List<string> SGGNames = new List<string>();//接收处理后的国家 是申根国
  5143. if (groupInfo.VisitCountry.Contains(","))
  5144. RD_country = groupInfo.VisitCountry.Split(',');
  5145. else if (groupInfo.VisitCountry.Contains(' '))
  5146. RD_country = groupInfo.VisitCountry.Split(' ');
  5147. else if (groupInfo.VisitCountry.Contains(","))
  5148. RD_country = groupInfo.VisitCountry.Split(',');
  5149. else if (groupInfo.VisitCountry.Contains("、"))
  5150. RD_country = groupInfo.VisitCountry.Split('、');
  5151. else if (groupInfo.VisitCountry.Contains("|"))
  5152. RD_country = groupInfo.VisitCountry.Split('|');
  5153. //判断是否是申根国家
  5154. for (int i = 0; i < RD_country.Length; i++)
  5155. {
  5156. if (RD_country[i].ToString() != null)
  5157. {
  5158. //在申根国家中筛选 该国家是否是申根国家
  5159. for (int j = 0; j < _shenGenGuos.Length; j++)
  5160. {
  5161. if (RD_country[i] == _shenGenGuos[j])
  5162. SGGNames.Add(_shenGenGuos[j]); //添加申根国
  5163. }
  5164. }
  5165. }
  5166. //目的地国是否有申根国
  5167. if (SGGNames.Count > 0)
  5168. {
  5169. firstEntryLabel = SGGNames.First();
  5170. membeDescLabel = string.Join(",", SGGNames.ToArray());
  5171. //接收生根国详细信息 存储顺序 起飞日期:Day 起飞时刻:StartTime 抵达日期:ArrivedDate 到达时刻:EndTime
  5172. List<SSGDetails> ListSSGDetails = new List<SSGDetails>();
  5173. //处理申根国家 预定到达时间 预定离开时间 预定停留天数
  5174. for (int i = 0; i < SGGNames.Count; i++)
  5175. {
  5176. //在相同的国家下 得到该航班的信息 //抵达时间 起飞日期:Day 起飞时刻:StartTime 到达时刻:EndTime 抵达日期:ArrivedDate 飞行时间:FlightTime 航司 Fliagtcode 入境口岸
  5177. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  5178. //ResidenceTime1 机票三字码信息
  5179. if (atbc != null)
  5180. {
  5181. string HL_Three = ""; //三字码 Three
  5182. for (int j = 0; j < atbc.Rows.Count; j++)
  5183. {
  5184. HL_Three = atbc.Rows[j]["Three"].ToString();
  5185. if (!string.IsNullOrEmpty(HL_Three))
  5186. {
  5187. string threeCodeTwo = HL_Three.Substring(3);
  5188. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == threeCodeTwo).First();
  5189. if (tc != null)
  5190. {
  5191. //首入申根国时间
  5192. if (SGGNames[i] == tc.Country)
  5193. {
  5194. SSGDetails SSGDetails = new SSGDetails()
  5195. {
  5196. Three = atbc.Rows[j]["Three"].ToString(), //三字码
  5197. Fliagtcode = atbc.Rows[j]["Fliagtcode"].ToString(), //航司
  5198. startDate = atbc.Rows[j]["Day"].ToString(), //整理起飞日期
  5199. startTime = atbc.Rows[j]["StartTime"].ToString(), //整理起飞时刻
  5200. endDate = atbc.Rows[j]["ArrivedDate"].ToString(), //整理抵达日期
  5201. endTime = atbc.Rows[j]["EndTime"].ToString() //整理抵达时刻
  5202. };
  5203. ListSSGDetails.Add(SSGDetails);
  5204. }
  5205. }
  5206. }
  5207. }
  5208. }
  5209. }
  5210. ListSSGDetails.Sort((a, b) => a.startDate.CompareTo(b.startDate));
  5211. //得到并计算出入境时间
  5212. if (ListSSGDetails != null)
  5213. {
  5214. string RuJingTime = ListSSGDetails.First().endDate + " " + ListSSGDetails.First().endTime.Substring(0, 2) + ":" + ListSSGDetails.First().endTime.Substring(2); //入境时间
  5215. string LiJingTime = ListSSGDetails[ListSSGDetails.Count - 1].startDate + " " + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(0, 2) + ":" + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(2); //离境时间
  5216. stopDays = Convert.ToDateTime(LiJingTime).Subtract(Convert.ToDateTime(RuJingTime)).Days.ToString();
  5217. }
  5218. }
  5219. }
  5220. SetFieldValue(formFields, "25.MembeDesc", membeDescLabel); //主要申根目的地 (以及其他申根目的地,如适用)
  5221. SetFieldValue(formFields, "26.FirstEntry", firstEntryLabel); //首入申根国
  5222. //申请入境次数
  5223. SetFieldValue(formFields, "27.SingleEntry", ""); //单次
  5224. SetFieldValue(formFields, "27.TwoEntries", ""); //两次
  5225. SetFieldValue(formFields, "27.MultipleEntries", ""); //多次
  5226. SetFieldValue(formFields, "27.IntendedDateIn", ""); //在申根地区预计首次停留的预计抵达日期
  5227. SetFieldValue(formFields, "27.IntendedDateOut", ""); //在申根地区预计首次停留之后的预计离开日期
  5228. //以往申根国签证是否有指纹记录
  5229. SetFieldValue(formFields, "28.No", ""); //否
  5230. SetFieldValue(formFields, "28.Yes", ""); //是
  5231. SetFieldValue(formFields, "28.KnownDate", ""); //如有,请写明日期
  5232. SetFieldValue(formFields, "28.KnownVisanumber", ""); //如有,请写明签证贴纸号码
  5233. //最后目的地之入境许可
  5234. SetFieldValue(formFields, "29.Issued", ""); //签发机关 Entry permit for the final country of destination, where applicable
  5235. SetFieldValue(formFields, "29.ValidFrom", ""); //有效期由
  5236. SetFieldValue(formFields, "29.Until", ""); //至
  5237. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  5238. //得到当前国家下的城市酒店信息
  5239. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  5240. .Where(x => x.DiId == groupId)
  5241. //.Where(x => x.City.contains(city))
  5242. .First();
  5243. //酒店住址
  5244. if (hotelInfo != null)
  5245. {
  5246. SetFieldValue(formFields, "30.SurnameFirstName", hotelInfo?.HotelName ?? ""); //申根国的酒店
  5247. var otherInfo = $"{hotelInfo.HotelAddress}";
  5248. SetFieldValue(formFields, "30.HotelInfo", otherInfo); //邀请人/酒店/暂住居所的地址及电子邮件
  5249. SetFieldValue(formFields, "30.TelephoneNo", hotelInfo?.HotelTel ?? ""); //电话号码
  5250. }
  5251. //邀请公司或机构的名称及地址
  5252. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  5253. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  5254. //.Where(x => x.Country.Contains(county))
  5255. //.Where(x => x.Area.Contains(city))
  5256. .First();
  5257. if (oa != null)
  5258. {
  5259. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  5260. SetFieldValue(formFields, "30.SurnameFirstName", oa?.Contact ?? ""); //申根国的酒店
  5261. SetFieldValue(formFields, "30.HotelInfo", oa?.Address ?? ""); //邀请人/酒店/暂住居所的地址及电子邮件
  5262. SetFieldValue(formFields, "30.TelephoneNo", oa?.Tel ?? ""); //电话号码
  5263. string nameAddressLabel = $"{oa.Client} {oa.Address}";
  5264. SetFieldValue(formFields, "31.NameAddress", nameAddressLabel); //邀请公司或机构的名称及地址
  5265. string surnameLabel = $"{oa.Contact} {oa.Tel}";
  5266. SetFieldValue(formFields, "31.Surname", surnameLabel); //邀请公司或机构的联系人姓名、地址、电话号码及电子邮件
  5267. SetFieldValue(formFields, "31.TelephoneNo", oa?.Tel ?? ""); //邀请公司或机构的电话
  5268. }
  5269. //申请人的旅费以及在国外停留期间的生活费用
  5270. SetFieldValue(formFields, "32.Applicant", ""); //由申请人支付
  5271. SetFieldValue(formFields, "32.Cash", ""); //支付方式 - 现金
  5272. SetFieldValue(formFields, "32.Traveller", ""); //支付方式 - 旅行支票
  5273. SetFieldValue(formFields, "32.CreditCard", ""); //支付方式 - 信用卡
  5274. SetFieldValue(formFields, "32.Prepaid", ""); //支付方式 - 预缴住宿
  5275. SetFieldValue(formFields, "32.Prepaid1", ""); //支付方式 - 预缴交通
  5276. SetFieldValue(formFields, "32.OtherMeans", ""); //支付方式 - 其它
  5277. SetFieldValue(formFields, "32.OtherMeansDesc", ""); //支付方式 - 其它(请注明)
  5278. SetFieldValue(formFields, "32.Sponsor", ""); //由赞助方(邀请人、公司或机构)支付,请注明
  5279. SetFieldValue(formFields, "32.Referred", ""); //参见第 30 及 31 项
  5280. SetFieldValue(formFields, "32.ReferredDesc", ""); //参见第 30 及 31 项(请注明)
  5281. SetFieldValue(formFields, "32.OtherSponsor", ""); //其它
  5282. SetFieldValue(formFields, "32.OtherSponsorDesc", ""); //其它(请注明)
  5283. SetFieldValue(formFields, "32.SponsorCash", ""); //赞助方式 - 现金
  5284. SetFieldValue(formFields, "32.SponsorAccommodation", ""); //赞助方式 - 提供住宿
  5285. SetFieldValue(formFields, "32.SponsorExpenses", ""); //赞助方式 - 支付旅程期间所有开支
  5286. SetFieldValue(formFields, "32.SponsorPrepaid", ""); //赞助方式 - 预缴交通
  5287. SetFieldValue(formFields, "32.ponsorOther", ""); //赞助方式 - 其它
  5288. SetFieldValue(formFields, "32.ponsorOtherDesc", ""); //赞助方式 - 其它(请注明)
  5289. //填表人与申请人不同
  5290. SetFieldValue(formFields, "33.WriteTableName", ""); //姓名
  5291. SetFieldValue(formFields, "33.WriteTableAddress", ""); //住址
  5292. SetFieldValue(formFields, "33.WriteTableTel", ""); //电话
  5293. SetFieldValue(formFields, "EndPlaceAndDate", DateTime.Now.ToString("yyyy-MM-dd")); //地点及日期
  5294. #endregion
  5295. }
  5296. catch (Exception ex)
  5297. {
  5298. throw new Exception($"生成PDF文件时出错: {ex.Message}", ex);
  5299. }
  5300. finally
  5301. {
  5302. // 按正确顺序关闭资源
  5303. stamper?.Close();
  5304. reader?.Close();
  5305. templateStream?.Close();
  5306. outputStream?.Close();
  5307. }
  5308. return outputPath;
  5309. }
  5310. #endregion
  5311. #region 文档下载辅助实体类
  5312. private class VisaDateView
  5313. {
  5314. /// <summary>
  5315. /// 团组信息
  5316. /// </summary>
  5317. public Grp_DelegationInfo groupInfo { get; set; }
  5318. /// <summary>
  5319. /// 身份证信息
  5320. /// </summary>
  5321. public Crm_CustomerCert idInfo { get; set; }
  5322. /// <summary>
  5323. /// 护照信息
  5324. /// </summary>
  5325. public Crm_CustomerCert passportInfo { get; set; }
  5326. /// <summary>
  5327. /// 客户信息
  5328. /// </summary>
  5329. public Crm_DeleClient custInfo { get; set; }
  5330. /// <summary>
  5331. /// 学校资料
  5332. /// </summary>
  5333. public List<Crm_VisaCustomerSchool> schoolInfos { get; set; }
  5334. /// <summary>
  5335. /// 家庭成员资料
  5336. /// </summary>
  5337. public List<Crm_VisaCustomerFamily> familyInfos { get; set; }
  5338. /// <summary>
  5339. /// 公司资料
  5340. /// </summary>
  5341. public List<Crm_VisaCustomerCompany> companyInfos { get; set; }
  5342. }
  5343. private class SSGDetails
  5344. {
  5345. public string Three { get; set; } //三字码
  5346. public string Fliagtcode { get; set; } //航司
  5347. public string startDate { get; set; } //首入申根国日期
  5348. public string startTime { get; set; } //首入申根国时间
  5349. public string endDate { get; set; } //离开申根国日期
  5350. public string endTime { get; set; } //离开申根国时间
  5351. }
  5352. #endregion
  5353. #endregion
  5354. /// <summary>
  5355. /// 根据团组Id获取签证客户信息List
  5356. /// </summary>
  5357. /// <param name="dto">请求dto</param>
  5358. /// <returns></returns>
  5359. [HttpPost]
  5360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5361. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  5362. {
  5363. var groupData = await _groupRepository.GetCrmByGroupId(dto);
  5364. if (groupData.Code != 0)
  5365. {
  5366. return Ok(JsonView(false, groupData.Msg));
  5367. }
  5368. return Ok(JsonView(groupData.Data));
  5369. }
  5370. /// <summary>
  5371. /// IOS获取团组签证拍照上传进度01(团组列表)
  5372. /// </summary>
  5373. /// <param name="dto">请求dto</param>
  5374. /// <returns></returns>
  5375. [HttpPost]
  5376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5377. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  5378. {
  5379. if (dto == null)
  5380. {
  5381. return Ok(JsonView(false, "参数为空"));
  5382. }
  5383. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  5384. return Ok(JsonView(visaList));
  5385. }
  5386. /// <summary>
  5387. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  5388. /// </summary>
  5389. /// <returns></returns>
  5390. [HttpPost]
  5391. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5392. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  5393. {
  5394. if (dto == null)
  5395. {
  5396. return Ok(JsonView(false, "请求错误:"));
  5397. }
  5398. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  5399. return Ok(JsonView(list));
  5400. }
  5401. /// <summary>
  5402. /// IOS获取团组签证拍照上传进度03(相册)
  5403. /// </summary>
  5404. /// <returns></returns>
  5405. [HttpPost]
  5406. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5407. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  5408. {
  5409. if (dto == null)
  5410. {
  5411. return Ok(JsonView(false, "请求错误:"));
  5412. }
  5413. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  5414. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  5415. list.ForEach(s => s.url = url);
  5416. return Ok(JsonView(list));
  5417. }
  5418. /// <summary>
  5419. /// IOS获取团组签证拍照上传进度04(图片上传)
  5420. /// </summary>
  5421. /// <param name="dto"></param>
  5422. /// <returns></returns>
  5423. [HttpPost]
  5424. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5425. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  5426. {
  5427. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  5428. //if (!string.IsNullOrEmpty(result))
  5429. //{
  5430. //}
  5431. //else {
  5432. // return Ok(JsonView(false, "上传失败"));
  5433. //}
  5434. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  5435. int sucNum = 0;
  5436. try
  5437. {
  5438. foreach (var item in dto.base64DataList)
  5439. {
  5440. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  5441. string result = DecodeBase64ToImage(item, imageName);
  5442. if (!string.IsNullOrEmpty(result))
  5443. {
  5444. var pic = new Grp_VisaProgressCustomerPicture
  5445. {
  5446. CreateUserId = dto.CreateUserId,
  5447. PicName = imageName,
  5448. PicPath = result,
  5449. VisaProgressCustomerId = dto.visaProgressCustomerId
  5450. };
  5451. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  5452. if (insertResult > 0)
  5453. {
  5454. sucNum++;
  5455. }
  5456. }
  5457. }
  5458. }
  5459. catch (Exception ex)
  5460. {
  5461. return Ok(JsonView(false, ex.Message));
  5462. }
  5463. string msg = string.Format(@"成功上传{0}张", sucNum);
  5464. return Ok(JsonView(true, msg));
  5465. }
  5466. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  5467. {
  5468. string filename = "";//声明一个string类型的相对路径
  5469. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  5470. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  5471. try//会有异常抛出,try,catch一下
  5472. {
  5473. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  5474. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  5475. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  5476. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  5477. //文件名称
  5478. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  5479. //上传的文件的路径
  5480. string filePath = "";
  5481. if (!Directory.Exists(fileDir))
  5482. {
  5483. Directory.CreateDirectory(fileDir);
  5484. }
  5485. //上传的文件的路径
  5486. filePath = fileDir + filename;
  5487. //string url = HttpRuntime.AppDomainAppPath.ToString();
  5488. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  5489. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  5490. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  5491. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  5492. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  5493. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  5494. ms.Close();//关闭当前流,并释放所有与之关联的资源
  5495. bitmap.Dispose();
  5496. }
  5497. catch (Exception e)
  5498. {
  5499. string massage = e.Message;
  5500. Logs("IOS图片上传Error:" + massage);
  5501. //filename = e.Message;
  5502. }
  5503. return filename;//返回相对路径
  5504. }
  5505. /// <summary>
  5506. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  5507. /// </summary>
  5508. /// <param name="dto"></param>
  5509. /// <returns></returns>
  5510. [HttpPost]
  5511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5512. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  5513. {
  5514. if (dto == null)
  5515. {
  5516. return Ok(JsonView(false, "请求错误:"));
  5517. }
  5518. string msg = "参数错误";
  5519. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  5520. {
  5521. try
  5522. {
  5523. //_delegationVisaRep.BeginTran();
  5524. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  5525. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  5526. .Where(s => s.Id == dto.visaProgressCustomerId)
  5527. .ExecuteCommandAsync();
  5528. if (updCount > 0 && dto.publishCode == 1)
  5529. {
  5530. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  5531. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  5532. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  5533. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  5534. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  5535. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  5536. if (groupData == null)
  5537. {
  5538. _delegationVisaRep.RollbackTran();
  5539. }
  5540. string title = string.Format(@"[签证进度更新]");
  5541. string content = string.Format(@"测试文本");
  5542. bool rst = await _message.AddMsg(new MessageDto()
  5543. {
  5544. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  5545. IssuerId = dto.publisher,
  5546. Title = title,
  5547. Content = content,
  5548. ReleaseTime = DateTime.Now,
  5549. UIdList = new List<int> {
  5550. 234
  5551. }
  5552. });
  5553. if (rst)
  5554. {
  5555. return Ok(JsonView(true, "发送通知成功"));
  5556. }
  5557. }
  5558. //_delegationVisaRep.CommitTran();
  5559. }
  5560. catch (Exception)
  5561. {
  5562. //_delegationVisaRep.RollbackTran();
  5563. }
  5564. }
  5565. return Ok(JsonView(true, msg));
  5566. }
  5567. #endregion
  5568. #endregion
  5569. #region 团组任务分配
  5570. /// <summary>
  5571. /// 团组任务分配初始化
  5572. /// </summary>
  5573. /// <returns></returns>
  5574. [HttpPost]
  5575. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5576. public async Task<IActionResult> GetTaskAssignmen()
  5577. {
  5578. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  5579. if (groupData.Code != 0)
  5580. {
  5581. return Ok(JsonView(false, groupData.Msg));
  5582. }
  5583. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5584. }
  5585. /// <summary>
  5586. /// 团组任务分配查询
  5587. /// </summary>
  5588. /// <param name="dto"></param>
  5589. /// <returns></returns>
  5590. [HttpPost]
  5591. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5592. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  5593. {
  5594. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  5595. if (groupData.Code != 0)
  5596. {
  5597. return Ok(JsonView(false, groupData.Msg));
  5598. }
  5599. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5600. }
  5601. /// <summary>
  5602. /// 团组任务分配操作
  5603. /// </summary>
  5604. /// <param name="dto"></param>
  5605. /// <returns></returns>
  5606. [HttpPost]
  5607. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5608. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  5609. {
  5610. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  5611. if (groupData.Code != 0)
  5612. {
  5613. return Ok(JsonView(false, groupData.Msg));
  5614. }
  5615. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5616. }
  5617. /// <summary>
  5618. /// 团组任务分配
  5619. /// 批量分配
  5620. /// 查询团组
  5621. /// </summary>
  5622. /// <param name="dto"></param>
  5623. /// <returns></returns>
  5624. [HttpPost]
  5625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5626. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  5627. {
  5628. //参数验证
  5629. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  5630. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  5631. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  5632. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  5633. }
  5634. /// <summary>
  5635. /// 团组任务分配
  5636. /// 批量分配
  5637. /// </summary>
  5638. /// <param name="dto"></param>
  5639. /// <returns></returns>
  5640. [HttpPost]
  5641. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5642. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  5643. {
  5644. //参数验证
  5645. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  5646. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  5647. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  5648. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  5649. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  5650. }
  5651. #endregion
  5652. #region 团组费用审核
  5653. /// <summary>
  5654. /// 费用审核
  5655. /// 团组列表 Page
  5656. /// </summary>
  5657. /// <param name="_dto">团组列表请求dto</param>
  5658. /// <returns></returns>
  5659. [HttpPost]
  5660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5661. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto _dto)
  5662. {
  5663. #region 参数验证
  5664. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  5665. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  5666. #region 页面操作权限验证
  5667. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  5668. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  5669. #endregion
  5670. #endregion
  5671. if (_dto.PortType == 1 || _dto.PortType == 2 || _dto.PortType == 3) // web/Android/IOS
  5672. {
  5673. string sqlWhere = string.Empty;
  5674. if (_dto.IsSure == 0) //未完成
  5675. {
  5676. sqlWhere += string.Format(@" And IsSure = 0");
  5677. }
  5678. else if (_dto.IsSure == 1) //已完成
  5679. {
  5680. sqlWhere += string.Format(@" And IsSure = 1");
  5681. }
  5682. if (!string.IsNullOrEmpty(_dto.SearchCriteria))
  5683. {
  5684. string tj = _dto.SearchCriteria;
  5685. sqlWhere += string.Format(@"And (ssd.Name Like '%{0}%' Or TeamName Like '%{1}%' Or ClientName Like '%{2}%' Or su.CnName Like '%{3}%')",
  5686. tj, tj, tj, tj);
  5687. }
  5688. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  5689. TeamName,ClientName,ClientUnit, TeamLevId,TeamLev,VisitDate,
  5690. VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  5691. From (
  5692. Select row_number() over(order by gdi.VisitDate Desc) as Row_Number,
  5693. gdi.Id,SalesQuoteNo,TourCode,ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,
  5694. ClientName,ClientUnit,ssd.Id TeamTypeId, ssd.Name TeamType,VisitDate,
  5695. VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  5696. From Grp_DelegationInfo gdi
  5697. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  5698. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  5699. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  5700. Where gdi.IsDel = 0 {0}
  5701. ) temp ", sqlWhere);
  5702. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  5703. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(_dto.PageIndex, _dto.PageSize, total);//ToPageAsync
  5704. var _view = new
  5705. {
  5706. PageFuncAuth = pageFunAuthView,
  5707. Data = _DelegationList
  5708. };
  5709. return Ok(JsonView(true, "查询成功!", _view, total));
  5710. }
  5711. else
  5712. {
  5713. return Ok(JsonView(false, "查询失败"));
  5714. }
  5715. }
  5716. /// <summary>
  5717. /// 获取团组费用审核
  5718. /// </summary>
  5719. /// <param name="_dto"></param>
  5720. /// <returns></returns>
  5721. [HttpPost]
  5722. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5723. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  5724. {
  5725. try
  5726. {
  5727. #region 参数验证
  5728. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  5729. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  5730. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  5731. #region 页面操作权限验证
  5732. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  5733. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  5734. #endregion
  5735. #endregion
  5736. var _view = new Grp_CreditCardPaymentView();
  5737. var clientNameList = GetSimplClientList(_dto.DiId);
  5738. #region 费用清单
  5739. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  5740. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  5741. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  5742. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  5743. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  5744. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  5745. /*
  5746. * 76://酒店预订
  5747. */
  5748. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5749. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5750. /*
  5751. * 79://车/导游地接
  5752. */
  5753. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5754. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5755. /*
  5756. * 80: //签证
  5757. */
  5758. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5759. /*
  5760. *81: //邀请/公务活动
  5761. */
  5762. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5763. /*
  5764. * 82: //团组客户保险
  5765. */
  5766. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5767. /*
  5768. * Lable = 85 机票预订
  5769. */
  5770. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5771. /*
  5772. * 85 机票预定
  5773. */
  5774. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5775. /*
  5776. * 98 其他款项
  5777. */
  5778. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5779. /*
  5780. * 285:收款退还
  5781. */
  5782. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5783. /*
  5784. * 1015: //超支费用
  5785. */
  5786. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5787. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  5788. /*
  5789. * 币种信息
  5790. */
  5791. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  5792. /*
  5793. * 车/导游地接 费用类型
  5794. */
  5795. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  5796. /*
  5797. * 车/导游地接 费用类型
  5798. */
  5799. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  5800. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  5801. /*
  5802. * 用户信息
  5803. */
  5804. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  5805. /*
  5806. * 费用模块
  5807. */
  5808. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  5809. string priceModule = string.Empty;
  5810. if (sdPriceName != null)
  5811. {
  5812. priceModule = sdPriceName.Name;
  5813. }
  5814. /*
  5815. * 成本信息
  5816. */
  5817. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  5818. decimal _groupRate = 0.0000M;
  5819. string _groupCurrencyCode = "-";
  5820. if (groupCost != null)
  5821. {
  5822. _groupRate = groupCost.Rate;
  5823. if (int.TryParse(groupCost.Currency, out int _currency))
  5824. {
  5825. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  5826. }
  5827. else _groupCurrencyCode = groupCost.Currency;
  5828. }
  5829. string costContentSql = $"Select * From Grp_GroupCost";
  5830. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  5831. //处理日期为空的天数
  5832. for (int i = 0; i < groupCostDetails.Count; i++)
  5833. if (i != 0)
  5834. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  5835. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  5836. /*
  5837. * 处理详情数据
  5838. */
  5839. foreach (var entity in entityList)
  5840. {
  5841. var _detail = new Grp_CreditCardPaymentDetailView
  5842. {
  5843. Id = entity.Id,
  5844. PriceName = priceModule,
  5845. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  5846. };
  5847. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  5848. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  5849. //处理金额
  5850. if (entity.CTable == 1015)
  5851. {
  5852. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  5853. if (czInfo != null)
  5854. {
  5855. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  5856. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  5857. }
  5858. }
  5859. /*
  5860. * 应付款金额
  5861. */
  5862. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  5863. string PaymentCurrency_WaitPay = "Unknown";
  5864. string hotelCurrncyCode = "Unknown";
  5865. string hotelCurrncyName = "Unknown";
  5866. if (sdPaymentCurrency_WaitPay != null)
  5867. {
  5868. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  5869. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  5870. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  5871. if (hotelCurrncyCode.Equals("CNY"))
  5872. {
  5873. entity.DayRate = 1.0000M;
  5874. }
  5875. }
  5876. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  5877. /*
  5878. * 此次付款金额
  5879. */
  5880. decimal CurrPayStr = 0.00M,
  5881. OriginalCurrPay = 0.00M;
  5882. if (entity.PayPercentage == 0)
  5883. {
  5884. if (entity.PayThenMoney != 0)
  5885. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  5886. }
  5887. else
  5888. {
  5889. if (entity.PayMoney != 0)
  5890. {
  5891. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  5892. }
  5893. }
  5894. //if (_dto.Label == 79)
  5895. //{
  5896. // string original = string.Empty;
  5897. // if (hotelCurrncyCode.Equals("CNY"))
  5898. // {
  5899. // OriginalCurrPay = CurrPayStr;
  5900. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  5901. // }
  5902. // else
  5903. // {
  5904. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  5905. // //760 EUR(7600.00 CNY)
  5906. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  5907. // }
  5908. //}
  5909. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  5910. string original = string.Empty;
  5911. if (hotelCurrncyCode.Equals("CNY"))
  5912. {
  5913. OriginalCurrPay = CurrPayStr;
  5914. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  5915. }
  5916. else
  5917. {
  5918. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  5919. //760 EUR(7600.00 CNY)
  5920. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  5921. }
  5922. /*
  5923. * 剩余尾款
  5924. */
  5925. decimal BalanceStr = 0;
  5926. if (CurrPayStr != 0)
  5927. {
  5928. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  5929. BalanceStr = 0;
  5930. else
  5931. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  5932. }
  5933. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  5934. /*
  5935. * Bus名称
  5936. */
  5937. _detail.BusName = "待增加";
  5938. /*
  5939. *费用所属
  5940. */
  5941. switch (entity.CTable)
  5942. {
  5943. case 76://酒店预订
  5944. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  5945. if (hotelReservations != null)
  5946. {
  5947. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  5948. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  5949. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  5950. string roomFeeStr = "", roomFeestr1 = "";
  5951. //是否比较房型价格
  5952. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  5953. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  5954. roomFeeStr += $"<br/>";
  5955. var roomTotal = 0.00M;
  5956. if (hotelReservations.SingleRoomPrice > 0)
  5957. {
  5958. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  5959. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5960. //__isSingle = true;
  5961. roomTotal += fee;
  5962. }
  5963. if (hotelReservations.DoubleRoomPrice > 0)
  5964. {
  5965. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  5966. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5967. // __isDouble = true;
  5968. roomTotal += fee;
  5969. }
  5970. if (hotelReservations.SuiteRoomPrice > 0)
  5971. {
  5972. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  5973. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5974. //__isSuite = true;
  5975. roomTotal += fee;
  5976. }
  5977. if (hotelReservations.OtherRoomPrice > 0)
  5978. {
  5979. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  5980. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5981. //__isOther = true;
  5982. roomTotal += fee;
  5983. }
  5984. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  5985. else roomFeeStr += " 0.00 * 0";
  5986. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  5987. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  5988. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  5989. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  5990. /*
  5991. * 费用类型
  5992. * 1:房费
  5993. * 2:早餐
  5994. * 3:地税
  5995. * 4:城市税
  5996. * </summary>
  5997. */
  5998. //地税
  5999. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  6000. if (governmentRentData != null)
  6001. {
  6002. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  6003. governmentRentFee = governmentRentData.Price;
  6004. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  6005. if (governmentRentCurrData != null)
  6006. {
  6007. governmentRentCode = governmentRentCurrData.Name;
  6008. governmentRentName = $"({governmentRentCurrData.Remark})";
  6009. }
  6010. }
  6011. //城市税
  6012. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  6013. if (cityTaxData != null)
  6014. {
  6015. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  6016. cityTaxFee = cityTaxData.Price;
  6017. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  6018. if (cityTaxCurrData != null)
  6019. {
  6020. cityTaxCode = cityTaxCurrData.Name;
  6021. cityTaxName = $"({cityTaxCurrData.Remark})";
  6022. }
  6023. }
  6024. //酒店早餐
  6025. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  6026. if (breakfastData != null)
  6027. {
  6028. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  6029. breakfastFee = breakfastData.Price;
  6030. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  6031. if (breakfastCurrData != null)
  6032. {
  6033. breakfastCode = breakfastCurrData.Name;
  6034. breakfastName = $"({breakfastCurrData.Remark})";
  6035. }
  6036. }
  6037. //房间费用
  6038. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  6039. if (roomData != null)
  6040. {
  6041. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  6042. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  6043. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  6044. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  6045. roomFee = roomData.Price;
  6046. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  6047. if (roomCurrData != null)
  6048. {
  6049. roomCode = roomCurrData.Name;
  6050. roomName = $"({roomCurrData.Remark})";
  6051. }
  6052. }
  6053. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  6054. string hotelCostStr = "";
  6055. decimal hotelCsotTotal = 0.00M;
  6056. if (groupCost != null)
  6057. {
  6058. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  6059. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  6060. }
  6061. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  6062. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  6063. string hotelCost_day = "";
  6064. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  6065. foreach (var item in hotelCostDetails1)
  6066. {
  6067. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  6068. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  6069. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  6070. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  6071. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  6072. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  6073. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  6074. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  6075. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  6076. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  6077. hotelCost_day += @$"<br/>";
  6078. }
  6079. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  6080. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  6081. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  6082. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  6083. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  6084. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  6085. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  6086. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  6087. $"房间说明: {hotelReservations.Remark} <br/>" +
  6088. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  6089. $"{hotelBreakfastStr}" +
  6090. $"{hotelGovernmentRentStr}" +
  6091. $"{hotelCityTaxStr}";
  6092. _detail.PriceNameContent = hotelReservations.HotelName;
  6093. }
  6094. break;
  6095. case 79://车/导游地接
  6096. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  6097. if (touristGuideGroundReservations != null)
  6098. {
  6099. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  6100. {
  6101. _detail.BusName = touristGuideGroundReservations.BusName;
  6102. }
  6103. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  6104. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  6105. //if (isInt)
  6106. //{
  6107. // var cityInfo = cityData.Find(it => it.Id == cityId);
  6108. // if (cityInfo != null)
  6109. // {
  6110. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  6111. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  6112. // if (carFeeItem != null)
  6113. // {
  6114. // nameContent += $@"({carFeeItem.Name})";
  6115. // }
  6116. // _detail.PriceNameContent = nameContent;
  6117. // }
  6118. //}
  6119. //else
  6120. //{
  6121. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  6122. //}
  6123. var touristGuideGroundReservationsContents =
  6124. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  6125. var opContent_sb = new StringBuilder();
  6126. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  6127. opContent_sb.AppendLine(contetTitle);
  6128. foreach (var item in touristGuideGroundReservationsContents)
  6129. {
  6130. string typeName = "Unknown";
  6131. string carCurrencyCode = "Unknown";
  6132. string carCurrencyName = "Unknown";
  6133. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  6134. if (carTypeData != null) typeName = carTypeData.Name;
  6135. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  6136. if (currencyData != null)
  6137. {
  6138. carCurrencyCode = currencyData.Name;
  6139. carCurrencyName = currencyData.Remark;
  6140. }
  6141. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  6142. bool IsCurrencyAgreement = false;
  6143. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  6144. string opCostStr = string.Empty;
  6145. decimal opCostTypePrice = 0.00M;
  6146. #region 处理成本各项费用
  6147. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  6148. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  6149. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  6150. costOPFeeCNY = 0.00M, //团组成本 op费用
  6151. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  6152. if (opCost.Count > 0)
  6153. {
  6154. switch (item.SId)
  6155. {
  6156. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  6157. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  6158. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  6159. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  6160. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  6161. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  6162. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  6163. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  6164. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  6165. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  6166. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  6167. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  6168. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  6169. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  6170. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  6171. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  6172. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  6173. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  6174. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  6175. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  6176. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  6177. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  6178. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  6179. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  6180. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  6181. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  6182. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  6183. }
  6184. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  6185. costOPFeeCNY = opCostTypePrice * _groupRate;
  6186. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  6187. }
  6188. #endregion
  6189. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  6190. aduitOPFeeCNY = item.Price * entity.DayRate;
  6191. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  6192. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  6193. $"{opTypeStr} {opCostStr}<br/>" +
  6194. $"明细:{item.PriceContent ?? "-"}<br/>" +
  6195. $"备注:{item.Remark ?? "-"}<br/><br/>";
  6196. if (entity.IsAuditGM != 3) //状态 != 自动审核
  6197. {
  6198. if (IsCurrencyAgreement)
  6199. {
  6200. if (item.Price > opCostTypePrice)
  6201. {
  6202. opContent_sb.Append("<span style='color:red;'>");
  6203. opContent_sb.Append(opContent);
  6204. opContent_sb.Append("</span>");
  6205. opContent_sb.AppendLine();
  6206. }
  6207. else
  6208. {
  6209. opContent_sb.Append(opContent);
  6210. opContent_sb.AppendLine();
  6211. }
  6212. }
  6213. else
  6214. {
  6215. //验证是否超成本 按付款比例计算
  6216. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  6217. {
  6218. opContent_sb.Append("<span style='color:red;'>");
  6219. opContent_sb.Append(opContent);
  6220. opContent_sb.Append("</span>");
  6221. opContent_sb.AppendLine();
  6222. }
  6223. else
  6224. {
  6225. opContent_sb.Append(opContent);
  6226. opContent_sb.AppendLine();
  6227. }
  6228. }
  6229. }
  6230. else
  6231. {
  6232. opContent_sb.Append(opContent);
  6233. opContent_sb.AppendLine();
  6234. }
  6235. }
  6236. _detail.PriceMsgContent = opContent_sb.ToString();
  6237. }
  6238. break;
  6239. case 80: //签证
  6240. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  6241. if (visaInfo != null)
  6242. {
  6243. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  6244. _detail.PriceNameContent = visaInfo.VisaDescription;
  6245. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  6246. }
  6247. break;
  6248. case 81: //邀请/公务活动
  6249. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  6250. if (_ioa != null)
  6251. {
  6252. string inviteCurrName = "Unknown", //邀请费用币种 Name
  6253. inviteCurrCode = "Unknown", //邀请费用币种 Code
  6254. sendCurrName = "Unknown", //快递费用币种 Name
  6255. sendCurrCode = "Unknown", //快递费用币种 Code
  6256. eventsCurrName = "Unknown", //公务活动费币种 Name
  6257. eventsCurrCode = "Unknown", //公务活动费币种 Code
  6258. translateCurrName = "Unknown", //公务翻译费 Name
  6259. translateCurrCode = "Unknown"; //公务翻译费 Code
  6260. #region 处理费用币种
  6261. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  6262. if (inviteCurrData != null)
  6263. {
  6264. inviteCurrName = inviteCurrData.Remark;
  6265. inviteCurrCode = inviteCurrData.Name;
  6266. }
  6267. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  6268. if (sendCurrData != null)
  6269. {
  6270. sendCurrName = sendCurrData.Remark;
  6271. sendCurrCode = sendCurrData.Name;
  6272. }
  6273. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  6274. if (eventsCurrData != null)
  6275. {
  6276. eventsCurrName = eventsCurrData.Remark;
  6277. eventsCurrCode = eventsCurrData.Name;
  6278. }
  6279. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  6280. if (translateCurrData != null)
  6281. {
  6282. translateCurrName = translateCurrData.Remark;
  6283. translateCurrCode = translateCurrData.Name;
  6284. }
  6285. #endregion
  6286. _detail.PriceNameContent = _ioa.InviterArea;
  6287. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  6288. List<string> priceExpNames = new List<string>();
  6289. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  6290. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  6291. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  6292. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  6293. if (priceExpNames != null && priceExpNames.Count > 0)
  6294. {
  6295. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  6296. }
  6297. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  6298. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  6299. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  6300. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  6301. $@"备注:" + _ioa.Remark + "<br/>";
  6302. }
  6303. break;
  6304. case 82: //团组客户保险
  6305. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  6306. if (customers != null)
  6307. {
  6308. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  6309. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  6310. }
  6311. break;
  6312. case 85: //机票预订
  6313. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  6314. if (jpRes != null)
  6315. {
  6316. string FlightsDescription = jpRes.FlightsDescription;
  6317. string PriceDescription = jpRes.PriceDescription;
  6318. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  6319. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  6320. }
  6321. break;
  6322. case 98://其他款项
  6323. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  6324. if (gdpRes != null)
  6325. {
  6326. //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/";
  6327. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  6328. //{
  6329. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  6330. //}
  6331. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  6332. _detail.PriceNameContent = gdpRes.PriceName;
  6333. }
  6334. break;
  6335. case 285://收款退还
  6336. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  6337. if (refundAndOtherMoney != null)
  6338. {
  6339. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  6340. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  6341. }
  6342. break;
  6343. case 751://酒店早餐
  6344. break;
  6345. case 1015://超支费用
  6346. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  6347. if (groupExtraCost != null)
  6348. {
  6349. _detail.PriceNameContent = groupExtraCost.PriceName;
  6350. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  6351. }
  6352. break;
  6353. default:
  6354. break;
  6355. }
  6356. /*
  6357. * 申请人
  6358. */
  6359. string operatorName = " - ";
  6360. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  6361. if (_opUser != null)
  6362. {
  6363. operatorName = _opUser.CnName;
  6364. }
  6365. _detail.OperatorName = operatorName;
  6366. /*
  6367. * 审核人
  6368. */
  6369. string auditOperatorName = " - ";
  6370. if (entity.IsAuditGM != 0)
  6371. {
  6372. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  6373. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  6374. else
  6375. {
  6376. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  6377. if (_adUser != null)
  6378. {
  6379. auditOperatorName = _adUser.CnName;
  6380. }
  6381. }
  6382. }
  6383. _detail.AuditOperatorName = auditOperatorName;
  6384. /*
  6385. * 超预算比例
  6386. */
  6387. string overBudgetStr = "";
  6388. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  6389. else if (entity.ExceedBudget == 0)
  6390. {
  6391. if (entity.CTable == 76 || entity.CTable == 79)
  6392. {
  6393. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  6394. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  6395. }
  6396. else
  6397. {
  6398. overBudgetStr = "未超预算";
  6399. }
  6400. }
  6401. else overBudgetStr = entity.ExceedBudget.ToString("P");
  6402. _detail.OverBudget = overBudgetStr;
  6403. decimal auditFee = 0.00M; //已审核金额 人名币
  6404. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  6405. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  6406. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  6407. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  6408. {
  6409. auditedFeeOriginal = entity.PayMoney;
  6410. auditFee = CurrPayStr;
  6411. }
  6412. else if (entity.IsAuditGM == 0)
  6413. {
  6414. unAuditFeeCNY = CurrPayStr;
  6415. unAuditFeeOriginal = OriginalCurrPay;
  6416. OriginalCurrPay = 0.00M;
  6417. }
  6418. /*
  6419. * 费用总计
  6420. */
  6421. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  6422. {
  6423. CurrencyId = entity.PaymentCurrency,
  6424. CurrencyName = PaymentCurrency_WaitPay,
  6425. AmountPayable = entity.PayMoney,
  6426. ThisPayment = OriginalCurrPay,
  6427. BalancePayment = BalanceStr,
  6428. AuditedFunds = auditFee,
  6429. AuditedFundsOriginal = auditedFeeOriginal,
  6430. UnAuditFundsCNY = unAuditFeeCNY,
  6431. UnAuditFundsOriginal = unAuditFeeOriginal
  6432. });
  6433. _detail.IsAuditGM = entity.IsAuditGM;
  6434. detailList.Add(_detail);
  6435. }
  6436. #endregion
  6437. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  6438. /*
  6439. * 下方描述处理
  6440. */
  6441. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  6442. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  6443. if (ccpCurrencyPrice != null)
  6444. {
  6445. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  6446. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  6447. }
  6448. else
  6449. {
  6450. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  6451. }
  6452. string amountPayableStr = string.Format(@"应付款总金额: ");
  6453. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  6454. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  6455. string auditedFundsStr = string.Format(@"已审费用总额: ");
  6456. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  6457. foreach (var item in nonDuplicat)
  6458. {
  6459. var currencyName = item.CurrencyName;
  6460. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  6461. if (strs.Count > 0)
  6462. {
  6463. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  6464. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  6465. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  6466. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  6467. //单独处理此次付款金额
  6468. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  6469. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  6470. //单独处理已审核费用
  6471. //if (item.CurrencyId == 836) //人民币
  6472. //{
  6473. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  6474. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  6475. //}
  6476. //else
  6477. //{
  6478. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  6479. //}
  6480. if (currencyName.Equals("CNY"))
  6481. {
  6482. //已审核费用
  6483. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  6484. //未审核费用
  6485. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  6486. }
  6487. else
  6488. {
  6489. //已审核费用
  6490. 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"));
  6491. //未审核费用
  6492. 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"));
  6493. }
  6494. }
  6495. }
  6496. _view.TotalStr1 = amountPayableStr[..^1];
  6497. _view.TotalStr2 = thisPaymentStr[..^1];
  6498. _view.TotalStr3 = balancePaymentStr[..^1];
  6499. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  6500. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  6501. var _view1 = new
  6502. {
  6503. PageFuncAuth = pageFunAuthView,
  6504. Data = _view
  6505. };
  6506. return Ok(JsonView(_view1));
  6507. }
  6508. catch (Exception ex)
  6509. {
  6510. return Ok(JsonView(false, ex.Message));
  6511. }
  6512. }
  6513. /// <summary>
  6514. /// 费用审核
  6515. /// 修改团组费用审核状态
  6516. /// </summary>
  6517. /// <param name="_dto">参数Json字符串</param>
  6518. /// <returns></returns>
  6519. [HttpPost]
  6520. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6521. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  6522. {
  6523. #region 参数验证
  6524. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6525. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  6526. #endregion
  6527. #region 页面操作权限验证
  6528. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6529. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  6530. #endregion
  6531. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  6532. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  6533. DateTime dtNow = DateTime.Now;
  6534. _groupRepository.BeginTran();
  6535. int rst = 0;
  6536. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  6537. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  6538. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6539. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  6540. var msgDatas = new List<dynamic>();
  6541. var dic_ccp_user = new Dictionary<int, int>() { };
  6542. foreach (var item in idList)
  6543. {
  6544. int CreditId = int.Parse(item);
  6545. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  6546. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  6547. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  6548. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  6549. .Where(s => s.Id == CreditId)
  6550. .ExecuteCommandAsync();
  6551. if (result < 1)
  6552. {
  6553. rst = -1;
  6554. _groupRepository.RollbackTran();
  6555. return Ok(JsonView(false, "操作失败并回滚!"));
  6556. }
  6557. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  6558. if (creditData != null)
  6559. {
  6560. #region 应用通知配置
  6561. try
  6562. {
  6563. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  6564. }
  6565. catch (Exception ex)
  6566. {
  6567. }
  6568. #endregion
  6569. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  6570. string groupNameStr = string.Empty;
  6571. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  6572. if (groupData != null) groupNameStr = groupData.TeamName;
  6573. string creditTypeStr = string.Empty;
  6574. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  6575. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  6576. string creditCurrency = string.Empty;
  6577. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  6578. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  6579. if (creditCurrency.Equals("CNY"))
  6580. {
  6581. creditData.DayRate = 1.0000M;
  6582. }
  6583. if (creditData.PayPercentage == 0.00M)
  6584. {
  6585. creditData.PayPercentage = 100M;
  6586. }
  6587. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  6588. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  6589. string msgContent = "";
  6590. if (creditCurrency.Equals("CNY"))
  6591. {
  6592. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  6593. }
  6594. else
  6595. {
  6596. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  6597. }
  6598. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  6599. }
  6600. }
  6601. if (rst == 0)
  6602. {
  6603. _groupRepository.CommitTran();
  6604. foreach (var item in msgDatas)
  6605. {
  6606. //发送消息
  6607. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  6608. }
  6609. #region 应用推送
  6610. try
  6611. {
  6612. foreach (var ccpId in dic_ccp_user.Keys)
  6613. {
  6614. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  6615. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  6616. }
  6617. }
  6618. catch (Exception)
  6619. {
  6620. }
  6621. #endregion
  6622. return Ok(JsonView(true, "操作成功!"));
  6623. }
  6624. return Ok(JsonView(false, "操作失败!"));
  6625. }
  6626. /// <summary>
  6627. /// 费用审核
  6628. /// 其他款项 文件下载
  6629. /// </summary>
  6630. /// <param name="id">其他款项 主键编号</param>
  6631. /// <returns></returns>
  6632. [HttpGet("{id}")]
  6633. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6634. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  6635. {
  6636. //网站域名
  6637. 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/";
  6638. var otherInfo = await _decreasePaymentsRep._sqlSugar
  6639. .Queryable<Grp_DecreasePayments>()
  6640. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  6641. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  6642. .Select((x, y) => new
  6643. {
  6644. x.Id,
  6645. x.FilePath
  6646. })
  6647. .FirstAsync();
  6648. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  6649. {
  6650. var url = $"{baseUrl}{otherInfo.FilePath}";
  6651. return Ok(JsonView(true, "操作成功!", url));
  6652. }
  6653. return Ok(JsonView(false, "暂无附件"));
  6654. }
  6655. #endregion
  6656. #region 机票费用录入
  6657. /// <summary>
  6658. /// 机票录入当前登录人可操作团组
  6659. /// </summary>
  6660. /// <param name="dto"></param>
  6661. /// <returns></returns>
  6662. [HttpPost]
  6663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6664. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  6665. {
  6666. try
  6667. {
  6668. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  6669. if (groupData.Code != 0)
  6670. {
  6671. return Ok(JsonView(false, groupData.Msg));
  6672. }
  6673. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6674. }
  6675. catch (Exception ex)
  6676. {
  6677. return Ok(JsonView(false, ex.Message));
  6678. }
  6679. }
  6680. /// <summary>
  6681. /// 机票费用录入列表
  6682. /// </summary>
  6683. /// <param name="dto"></param>
  6684. /// <returns></returns>
  6685. [HttpPost]
  6686. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6687. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  6688. {
  6689. try
  6690. {
  6691. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  6692. if (groupData.Code != 0)
  6693. {
  6694. return Ok(JsonView(false, groupData.Msg));
  6695. }
  6696. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6697. }
  6698. catch (Exception ex)
  6699. {
  6700. return Ok(JsonView(false, ex.Message));
  6701. throw;
  6702. }
  6703. }
  6704. /// <summary>
  6705. /// 根据id查询费用录入信息
  6706. /// </summary>
  6707. /// <param name="dto"></param>
  6708. /// <returns></returns>
  6709. [HttpPost]
  6710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6711. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  6712. {
  6713. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  6714. if (groupData.Code != 0)
  6715. {
  6716. return Ok(JsonView(false, groupData.Msg));
  6717. }
  6718. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6719. }
  6720. /// <summary>
  6721. /// 机票费用录入操作(Status:1.新增,2.修改)
  6722. /// </summary>
  6723. /// <param name="dto"></param>
  6724. /// <returns></returns>
  6725. [HttpPost]
  6726. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6727. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  6728. {
  6729. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  6730. if (groupData.Code != 0)
  6731. {
  6732. return Ok(JsonView(false, groupData.Msg));
  6733. }
  6734. #region 应用推送
  6735. try
  6736. {
  6737. var diId = dto.AirTicketResOpData.DiId;
  6738. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6739. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6740. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  6741. //自动审核
  6742. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  6743. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  6744. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  6745. $"GroupId:{diId};airId:{dataId};",
  6746. status,
  6747. auditMsg);
  6748. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6749. //2024-10-21 新增LZ UID
  6750. var userIds = new List<int>() { 21 };
  6751. string title = $"系统通知";
  6752. string content = "";
  6753. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6754. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6755. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6756. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6757. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6758. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  6759. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6760. }
  6761. catch (Exception ex)
  6762. {
  6763. }
  6764. #endregion
  6765. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6766. }
  6767. /// <summary>
  6768. /// 机票费用自动审核 AI识别方式
  6769. /// </summary>
  6770. /// <returns></returns>
  6771. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  6772. {
  6773. var ecoTypeIds = new List<int>() {
  6774. 459, //超经舱
  6775. 460, //经济舱
  6776. 1430, //公务舱(实际经济舱)
  6777. 1432, //头等舱(实际经济舱)
  6778. };
  6779. var bizTypeIds = new List<int>() {
  6780. 457, //头等舱
  6781. 458, //公务舱
  6782. 1431, //头等舱(实际公务舱)
  6783. };
  6784. var auditFeeTypeIds = new List<int>() { };
  6785. auditFeeTypeIds.AddRange(ecoTypeIds);
  6786. auditFeeTypeIds.AddRange(bizTypeIds);
  6787. int currModule = 85;
  6788. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  6789. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  6790. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  6791. .Select((x, y) => new
  6792. {
  6793. x.Id,
  6794. CcpId = y.Id,
  6795. x.FlightsDate,
  6796. x.PrePrice,
  6797. x.CType,
  6798. x.ClientNum,
  6799. x.DIId
  6800. })
  6801. .FirstAsync();
  6802. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  6803. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  6804. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  6805. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  6806. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  6807. var groupCostContents = await _sqlSugar
  6808. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  6809. .Where(x => x.IsDel == 0 && x.Diid == diId)
  6810. .ToListAsync();
  6811. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  6812. //处理 成本详细信息日期为空 填装费用信息
  6813. var airFeeLabel = new StringBuilder();
  6814. airFeeLabel.AppendLine("费用成本:");
  6815. for (int i = 0; i < groupCostContents.Count; i++)
  6816. {
  6817. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  6818. {
  6819. int index = i - 1;
  6820. if (index >= 0)
  6821. {
  6822. groupCostContents[i].Date = groupCostContents[index].Date;
  6823. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  6824. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  6825. }
  6826. }
  6827. else
  6828. {
  6829. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  6830. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  6831. }
  6832. var item = groupCostContents[i];
  6833. airFeeLabel.AppendLine($"{item.Date}");
  6834. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  6835. }
  6836. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  6837. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  6838. //访问Kimi AI 返回价格结果
  6839. var msgs = new List<SeedMessages>()
  6840. {
  6841. new ()
  6842. {
  6843. Role = KimiRole.user,
  6844. Content = airFeeLabel.ToString()
  6845. }
  6846. };
  6847. var client = new KiMiApiClient();
  6848. var kimiApiResult = await client.SeedMessage(msgs);
  6849. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  6850. string clients = kimiApiResult_JObject["content"].ToString();
  6851. decimal ecoPri_kimiAI = 0.00M,
  6852. bizPri_kimiAI = 0.00M;
  6853. //单个价格: 经济舱价格
  6854. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  6855. //价格文本包含/:/前经济舱价格 /后公务舱价格
  6856. if (clients.Contains('/'))
  6857. {
  6858. var priArray = clients.Split('/');
  6859. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  6860. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  6861. }
  6862. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  6863. var isAutoAudit = false;
  6864. //价格验证处理
  6865. //经济舱
  6866. if (ecoTypeIds.Contains(airInfo.CType))
  6867. {
  6868. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  6869. }
  6870. //公务舱
  6871. else if (bizTypeIds.Contains(airInfo.CType))
  6872. {
  6873. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  6874. }
  6875. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  6876. //是否执行自动审核
  6877. if (isAutoAudit)
  6878. {
  6879. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6880. .SetColumns(x => x.IsAuditGM == 3)
  6881. .SetColumns(x => x.AuditGMOperate == 4)
  6882. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  6883. .Where(x => x.Id == airInfo.CcpId)
  6884. .ExecuteCommandAsync();
  6885. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  6886. }
  6887. return (false, "当前费用超过成本费用,不可自动审核!");
  6888. }
  6889. /// <summary>
  6890. /// 机票费用录入
  6891. /// 自动审核测试 - AI 识别
  6892. /// </summary>
  6893. /// <param name="groupId"></param>
  6894. /// <param name="Id"></param>
  6895. /// <returns></returns>
  6896. [HttpPost]
  6897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6898. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  6899. {
  6900. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  6901. return Ok(JsonView(status, msg));
  6902. }
  6903. /// <summary>
  6904. /// 根据舱位类型查询接团客户名单信息
  6905. /// </summary>
  6906. /// <param name="dto"></param>
  6907. /// <returns></returns>
  6908. [HttpPost]
  6909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6910. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  6911. {
  6912. try
  6913. {
  6914. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  6915. if (crm_Groups.Count != 0)
  6916. {
  6917. var Customer = new List<dynamic>();
  6918. foreach (var item in crm_Groups)
  6919. {
  6920. var data = new
  6921. {
  6922. item.Id,
  6923. item.Pinyin,
  6924. Name = item.LastName + item.FirstName
  6925. };
  6926. Customer.Add(data);
  6927. }
  6928. return Ok(JsonView(true, "查询成功!", Customer));
  6929. }
  6930. return Ok(JsonView(true, "暂无数据", crm_Groups));
  6931. }
  6932. catch (Exception ex)
  6933. {
  6934. return Ok(JsonView(false, "程序错误!"));
  6935. throw;
  6936. }
  6937. }
  6938. /// <summary>
  6939. /// 根据团号获取客户信息
  6940. /// </summary>
  6941. /// <param name="dto"></param>
  6942. /// <returns></returns>
  6943. [HttpPost]
  6944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6945. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  6946. {
  6947. var jw = JsonView(false);
  6948. if (dto.DIID < 1)
  6949. {
  6950. jw.Msg += "请输入正确的diid";
  6951. return Ok(jw);
  6952. }
  6953. var arr = GetSimplClientList(dto.DIID);
  6954. jw = JsonView(true, "获取成功!", arr);
  6955. return Ok(jw);
  6956. }
  6957. private List<SimplClientInfo> GetSimplClientList(int diId)
  6958. {
  6959. 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);
  6960. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  6961. foreach (var item in arr)
  6962. {
  6963. EncryptionProcessor.DecryptProperties(item);
  6964. }
  6965. return arr;
  6966. }
  6967. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  6968. {
  6969. string result = origin;
  6970. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  6971. {
  6972. string[] temparr = origin.Split(',');
  6973. string fistrStr = temparr[0];
  6974. int count = temparr.Length;
  6975. bool success = int.TryParse(fistrStr, out int tempId);
  6976. if (success)
  6977. {
  6978. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  6979. if (tempInfo != null)
  6980. {
  6981. if (count > 1)
  6982. {
  6983. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  6984. }
  6985. else
  6986. {
  6987. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  6988. }
  6989. }
  6990. }
  6991. }
  6992. return result;
  6993. }
  6994. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  6995. {
  6996. string result = origin;
  6997. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  6998. {
  6999. string[] temparr = origin.Split(',');
  7000. result = "";
  7001. foreach (var item in temparr)
  7002. {
  7003. bool success = int.TryParse(item, out int tempId);
  7004. if (success)
  7005. {
  7006. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  7007. if (tempInfo != null)
  7008. {
  7009. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  7010. }
  7011. }
  7012. }
  7013. }
  7014. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  7015. return result;
  7016. }
  7017. /// <summary>
  7018. /// 机票费用录入,删除
  7019. /// </summary>
  7020. /// <param name="dto"></param>
  7021. /// <returns></returns>
  7022. [HttpPost]
  7023. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7024. public async Task<IActionResult> DelAirTicketRes(DelBaseDto dto)
  7025. {
  7026. try
  7027. {
  7028. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7029. if (res)
  7030. {
  7031. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  7032. {
  7033. IsDel = 1,
  7034. DeleteUserId = dto.DeleteUserId,
  7035. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7036. }).ExecuteCommandAsync();
  7037. return Ok(JsonView(true, "删除成功!"));
  7038. }
  7039. return Ok(JsonView(false, "删除失败!"));
  7040. }
  7041. catch (Exception ex)
  7042. {
  7043. return Ok(JsonView(false, "程序错误!"));
  7044. throw;
  7045. }
  7046. }
  7047. /// <summary>
  7048. /// 导出机票录入报表
  7049. /// </summary>
  7050. /// <param name="dto"></param>
  7051. /// <returns></returns>
  7052. [HttpPost]
  7053. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7054. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  7055. {
  7056. try
  7057. {
  7058. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  7059. if (groupData.Code != 0)
  7060. {
  7061. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  7062. }
  7063. else
  7064. {
  7065. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  7066. if (AirTicketReservations.Count != 0)
  7067. {
  7068. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  7069. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  7070. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  7071. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  7072. var designer = new WorkbookDesigner
  7073. {
  7074. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  7075. };
  7076. decimal countCost = 0;
  7077. foreach (var item in AirTicketReservations)
  7078. {
  7079. #region 处理客人姓名
  7080. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  7081. item.ClientName = clientNames;
  7082. #endregion
  7083. if (item.BankType == "其他")
  7084. {
  7085. item.BankNo = "--";
  7086. }
  7087. else
  7088. {
  7089. if (!string.IsNullOrEmpty(item.BankType))
  7090. {
  7091. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  7092. }
  7093. }
  7094. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  7095. item.Price = System.Decimal.Round(item.Price, 2);
  7096. countCost += Convert.ToDecimal(item.Price);
  7097. }
  7098. designer.SetDataSource("Export", AirTicketReservations);
  7099. designer.SetDataSource("ExportDiCode", diCode);
  7100. designer.SetDataSource("ExportDiName", diName);
  7101. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  7102. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  7103. designer.Process();
  7104. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  7105. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  7106. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  7107. return Ok(JsonView(true, "成功", url = rst));
  7108. }
  7109. else
  7110. {
  7111. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  7112. }
  7113. }
  7114. }
  7115. catch (Exception ex)
  7116. {
  7117. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  7118. throw;
  7119. }
  7120. }
  7121. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  7122. /// <summary>
  7123. /// 行程单导出
  7124. /// </summary>
  7125. /// <param name="dto"></param>
  7126. /// <returns></returns>
  7127. [HttpPost]
  7128. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7129. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  7130. {
  7131. try
  7132. {
  7133. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  7134. if (groupData.Code != 0)
  7135. {
  7136. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  7137. }
  7138. else
  7139. {
  7140. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  7141. if (dto.Language == "CN")
  7142. {
  7143. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  7144. var builder = new DocumentBuilder(doc);
  7145. int tableIndex = 0;//表格索引
  7146. //得到文档中的第一个表格
  7147. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  7148. foreach (var item in _AirTicketReservations)
  7149. {
  7150. #region 处理固定数据
  7151. string[] FlightsCode = item.FlightsCode.Split('/');
  7152. if (FlightsCode.Length != 0)
  7153. {
  7154. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7155. if (_AirCompany != null)
  7156. {
  7157. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  7158. }
  7159. else
  7160. {
  7161. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7162. }
  7163. }
  7164. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7165. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7166. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7167. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7168. string name = "";
  7169. foreach (string clientName in nameArray)
  7170. {
  7171. if (!name.Contains(clientName))
  7172. {
  7173. name += clientName + ",";
  7174. }
  7175. }
  7176. if (!string.IsNullOrWhiteSpace(name))
  7177. {
  7178. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  7179. }
  7180. else
  7181. {
  7182. table.Range.Bookmarks["ClientName"].Text = "--";
  7183. }
  7184. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7185. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7186. table.Range.Bookmarks["JointTicket"].Text = "--";
  7187. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7188. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7189. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7190. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7191. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7192. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7193. #endregion
  7194. #region 循环数据处理
  7195. var airs = new List<AirInfo>();
  7196. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  7197. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  7198. for (int i = 0; i < FlightsCode.Length; i++)
  7199. {
  7200. var air = new AirInfo();
  7201. string[] tempstr = DayArray[i]
  7202. .Replace("\r\n", string.Empty)
  7203. .Replace("\\r\\n", string.Empty)
  7204. .TrimStart().TrimEnd()
  7205. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  7206. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  7207. string starCity = "";
  7208. if (star_Three != null)
  7209. {
  7210. starCity = star_Three.AirPort;
  7211. }
  7212. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  7213. string EndCity = "";
  7214. if (End_Three != null)
  7215. {
  7216. EndCity = End_Three.AirPort;
  7217. }
  7218. air.Destination = starCity + "/" + EndCity;
  7219. air.Flight = FlightsCode[i];
  7220. air.SeatingClass = item.CTypeName;
  7221. string dateTime = tempstr[2];
  7222. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  7223. air.FlightDate = DateTemp;
  7224. air.DepartureTime = tempstr[5];
  7225. air.LandingTime = tempstr[6];
  7226. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  7227. air.TicketStatus = "--";
  7228. air.Luggage = "--";
  7229. air.DepartureTerminal = "--";
  7230. air.LandingTerminal = "--";
  7231. airs.Add(air);
  7232. }
  7233. int row = 13;
  7234. for (int i = 0; i < airs.Count; i++)
  7235. {
  7236. if (airs.Count > 2)
  7237. {
  7238. for (int j = 0; j < airs.Count - 2; j++)
  7239. {
  7240. var CopyRow = table.Rows[12].Clone(true);
  7241. table.Rows.Add(CopyRow);
  7242. }
  7243. }
  7244. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  7245. int index = 0;
  7246. foreach (PropertyInfo property in properties)
  7247. {
  7248. string value = property.GetValue(airs[i]).ToString();
  7249. Cell ishcel0 = table.Rows[row].Cells[index];
  7250. var p = new Paragraph(doc);
  7251. string s = value;
  7252. p.AppendChild(new Run(doc, s));
  7253. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  7254. ishcel0.AppendChild(p);
  7255. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  7256. index++;
  7257. }
  7258. row++;
  7259. }
  7260. #endregion
  7261. var lastParagraph = new Paragraph(doc);
  7262. //第一个表格末尾加段落
  7263. table.ParentNode.InsertAfter(lastParagraph, table);
  7264. //复制第一个表格
  7265. Table cloneTable = (Table)table.Clone(true);
  7266. //在文档末尾段落后面加入复制的表格
  7267. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  7268. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  7269. {
  7270. int rownewsIndex = 13;
  7271. for (int i = 0; i < 2; i++)
  7272. {
  7273. var CopyRow = table.Rows[12].Clone(true);
  7274. table.Rows.RemoveAt(13);
  7275. table.Rows.Add(CopyRow);
  7276. rownewsIndex++;
  7277. }
  7278. }
  7279. else
  7280. {
  7281. table.Rows.RemoveAt(12);
  7282. }
  7283. cloneTable.Rows.RemoveAt(12);
  7284. }
  7285. if (_AirTicketReservations.Count != 0)
  7286. {
  7287. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  7288. if (FlightsCode.Length != 0)
  7289. {
  7290. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7291. if (_AirCompany != null)
  7292. {
  7293. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  7294. }
  7295. else
  7296. {
  7297. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7298. }
  7299. }
  7300. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7301. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7302. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7303. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7304. string name = "";
  7305. foreach (string clientName in nameArray)
  7306. {
  7307. if (!name.Contains(clientName))
  7308. {
  7309. name += clientName + ",";
  7310. }
  7311. }
  7312. if (!string.IsNullOrWhiteSpace(name))
  7313. {
  7314. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  7315. }
  7316. else
  7317. {
  7318. table.Range.Bookmarks["ClientName"].Text = "--";
  7319. }
  7320. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7321. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7322. table.Range.Bookmarks["JointTicket"].Text = "--";
  7323. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7324. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7325. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7326. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7327. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7328. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7329. }
  7330. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  7331. //保存合并后的文档
  7332. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  7333. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  7334. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  7335. return Ok(JsonView(true, "成功!", rst));
  7336. }
  7337. else
  7338. {
  7339. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  7340. var builder = new DocumentBuilder(doc);
  7341. int tableIndex = 0;//表格索引
  7342. //得到文档中的第一个表格
  7343. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  7344. var texts = new List<string>();
  7345. foreach (var item in _AirTicketReservations)
  7346. {
  7347. string[] FlightsCode = item.FlightsCode.Split('/');
  7348. if (FlightsCode.Length != 0)
  7349. {
  7350. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7351. if (_AirCompany != null)
  7352. {
  7353. if (!transDic.ContainsKey(_AirCompany.CnName))
  7354. {
  7355. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  7356. }
  7357. }
  7358. else
  7359. {
  7360. if (!transDic.ContainsKey("--"))
  7361. {
  7362. transDic.Add("--", "--");
  7363. }
  7364. }
  7365. }
  7366. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7367. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7368. string name = "";
  7369. foreach (string clientName in nameArray)
  7370. {
  7371. name += clientName + ",";
  7372. }
  7373. if (!texts.Contains(name))
  7374. {
  7375. texts.Add(name);
  7376. }
  7377. var airs = new List<AirInfo>();
  7378. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  7379. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  7380. for (int i = 0; i < FlightsCode.Length; i++)
  7381. {
  7382. var air = new AirInfo();
  7383. string[] tempstr = DayArray[i]
  7384. .Replace("\r\n", string.Empty)
  7385. .Replace("\\r\\n", string.Empty)
  7386. .TrimStart().TrimEnd()
  7387. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  7388. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  7389. if (star_Three != null)
  7390. {
  7391. if (!transDic.ContainsKey(star_Three.AirPort))
  7392. {
  7393. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  7394. }
  7395. }
  7396. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  7397. if (End_Three != null)
  7398. {
  7399. if (!transDic.ContainsKey(End_Three.AirPort))
  7400. {
  7401. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  7402. }
  7403. }
  7404. if (!texts.Contains(item.CTypeName))
  7405. {
  7406. texts.Add(item.CTypeName);
  7407. }
  7408. }
  7409. }
  7410. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  7411. if (transData.Count > 0)
  7412. {
  7413. foreach (TranslateResult item in transData)
  7414. {
  7415. if (!transDic.ContainsKey(item.Query))
  7416. {
  7417. transDic.Add(item.Query, item.Translation);
  7418. }
  7419. }
  7420. }
  7421. foreach (var item in _AirTicketReservations)
  7422. {
  7423. #region 处理固定数据
  7424. string[] FlightsCode = item.FlightsCode.Split('/');
  7425. if (FlightsCode.Length != 0)
  7426. {
  7427. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7428. if (_AirCompany != null)
  7429. {
  7430. string str = "--";
  7431. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  7432. if (!string.IsNullOrEmpty(translateResult))
  7433. {
  7434. str = translateResult;
  7435. str = _airTicketResRep.Processing(str);
  7436. }
  7437. table.Range.Bookmarks["AirlineCompany"].Text = str;
  7438. }
  7439. else
  7440. {
  7441. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7442. }
  7443. }
  7444. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7445. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7446. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7447. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7448. string names = "";
  7449. foreach (string clientName in nameArray)
  7450. {
  7451. names += clientName + ",";
  7452. }
  7453. if (!string.IsNullOrWhiteSpace(names))
  7454. {
  7455. string str = "--";
  7456. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  7457. if (!string.IsNullOrEmpty(translateResult))
  7458. {
  7459. str = translateResult;
  7460. str = _airTicketResRep.Processing(str);
  7461. }
  7462. table.Range.Bookmarks["ClientName"].Text = str;
  7463. }
  7464. else
  7465. {
  7466. table.Range.Bookmarks["ClientName"].Text = "--";
  7467. }
  7468. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7469. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7470. table.Range.Bookmarks["JointTicket"].Text = "--";
  7471. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7472. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7473. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7474. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7475. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7476. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7477. #endregion
  7478. #region 循环数据处理
  7479. var airs = new List<AirInfo>();
  7480. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  7481. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  7482. for (int i = 0; i < FlightsCode.Length; i++)
  7483. {
  7484. var air = new AirInfo();
  7485. string[] tempstr = DayArray[i]
  7486. .Replace("\r\n", string.Empty)
  7487. .Replace("\\r\\n", string.Empty)
  7488. .TrimStart().TrimEnd()
  7489. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  7490. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  7491. string starCity = "";
  7492. if (star_Three != null)
  7493. {
  7494. string str2 = "--";
  7495. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  7496. if (!string.IsNullOrEmpty(translateResult2))
  7497. {
  7498. str2 = translateResult2;
  7499. str2 = _airTicketResRep.Processing(str2);
  7500. }
  7501. starCity = str2;
  7502. }
  7503. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  7504. string EndCity = "";
  7505. if (End_Three != null)
  7506. {
  7507. string str1 = "--";
  7508. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  7509. if (!string.IsNullOrEmpty(translateResult1))
  7510. {
  7511. str1 = translateResult1;
  7512. str1 = _airTicketResRep.Processing(str1);
  7513. }
  7514. EndCity = str1;
  7515. }
  7516. air.Destination = starCity + "/" + EndCity;
  7517. air.Flight = FlightsCode[i];
  7518. string str = "--";
  7519. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  7520. if (!string.IsNullOrEmpty(translateResult))
  7521. {
  7522. str = translateResult;
  7523. str = _airTicketResRep.Processing(str);
  7524. }
  7525. air.SeatingClass = str;
  7526. string dateTime = tempstr[2];
  7527. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  7528. air.FlightDate = DateTemp;
  7529. air.DepartureTime = tempstr[5];
  7530. air.LandingTime = tempstr[6];
  7531. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  7532. air.TicketStatus = "--";
  7533. air.Luggage = "--";
  7534. air.DepartureTerminal = "--";
  7535. air.LandingTerminal = "--";
  7536. airs.Add(air);
  7537. }
  7538. int row = 13;
  7539. for (int i = 0; i < airs.Count; i++)
  7540. {
  7541. if (airs.Count > 2)
  7542. {
  7543. for (int j = 0; j < airs.Count - 2; j++)
  7544. {
  7545. var CopyRow = table.Rows[12].Clone(true);
  7546. table.Rows.Add(CopyRow);
  7547. }
  7548. }
  7549. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  7550. int index = 0;
  7551. foreach (PropertyInfo property in properties)
  7552. {
  7553. string value = property.GetValue(airs[i]).ToString();
  7554. Cell ishcel0 = table.Rows[row].Cells[index];
  7555. var p = new Paragraph(doc);
  7556. string s = value;
  7557. p.AppendChild(new Run(doc, s));
  7558. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  7559. ishcel0.AppendChild(p);
  7560. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  7561. //ishcel0.CellFormat.VerticalAlignment=
  7562. index++;
  7563. }
  7564. row++;
  7565. }
  7566. #endregion
  7567. var lastParagraph = new Paragraph(doc);
  7568. //第一个表格末尾加段落
  7569. table.ParentNode.InsertAfter(lastParagraph, table);
  7570. //复制第一个表格
  7571. Table cloneTable = (Table)table.Clone(true);
  7572. //在文档末尾段落后面加入复制的表格
  7573. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  7574. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  7575. {
  7576. int rownewsIndex = 13;
  7577. for (int i = 0; i < 2; i++)
  7578. {
  7579. var CopyRow = table.Rows[12].Clone(true);
  7580. table.Rows.RemoveAt(13);
  7581. table.Rows.Add(CopyRow);
  7582. rownewsIndex++;
  7583. }
  7584. }
  7585. else
  7586. {
  7587. table.Rows.RemoveAt(12);
  7588. }
  7589. cloneTable.Rows.RemoveAt(12);
  7590. }
  7591. if (_AirTicketReservations.Count != 0)
  7592. {
  7593. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  7594. if (FlightsCode.Length != 0)
  7595. {
  7596. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7597. if (_AirCompany != null)
  7598. {
  7599. string str = "--";
  7600. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  7601. if (!string.IsNullOrEmpty(translateResult))
  7602. {
  7603. str = translateResult;
  7604. str = _airTicketResRep.Processing(str);
  7605. }
  7606. table.Range.Bookmarks["AirlineCompany"].Text = str;
  7607. }
  7608. else
  7609. {
  7610. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7611. }
  7612. }
  7613. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7614. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7615. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7616. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7617. string names = "";
  7618. foreach (string clientName in nameArray)
  7619. {
  7620. names += clientName + ",";
  7621. }
  7622. if (!string.IsNullOrWhiteSpace(names))
  7623. {
  7624. string str = "--";
  7625. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  7626. if (!string.IsNullOrEmpty(translateResult))
  7627. {
  7628. str = translateResult;
  7629. str = _airTicketResRep.Processing(str);
  7630. }
  7631. table.Range.Bookmarks["ClientName"].Text = str;
  7632. }
  7633. else
  7634. {
  7635. table.Range.Bookmarks["ClientName"].Text = "--";
  7636. }
  7637. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7638. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7639. table.Range.Bookmarks["JointTicket"].Text = "--";
  7640. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7641. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7642. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7643. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7644. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7645. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7646. }
  7647. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  7648. //保存合并后的文档
  7649. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  7650. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  7651. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  7652. return Ok(JsonView(true, "成功!", rst));
  7653. }
  7654. }
  7655. }
  7656. catch (Exception ex)
  7657. {
  7658. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  7659. throw;
  7660. }
  7661. }
  7662. #endregion
  7663. #region 团组增减款项 --> 其他款项
  7664. /// <summary>
  7665. /// 团组增减款项下拉框绑定
  7666. /// </summary>
  7667. /// <param name="dto"></param>
  7668. /// <returns></returns>
  7669. [HttpPost]
  7670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7671. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  7672. {
  7673. #region 参数验证
  7674. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7675. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  7676. #endregion
  7677. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  7678. }
  7679. /// <summary>
  7680. /// 根据团组Id查询团组增减款项
  7681. /// </summary>
  7682. /// <param name="dto"></param>
  7683. /// <returns></returns>
  7684. [HttpPost]
  7685. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7686. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  7687. {
  7688. #region 参数验证
  7689. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7690. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7691. #endregion
  7692. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  7693. }
  7694. /// <summary>
  7695. /// 团组增减款项操作(Status:1.新增,2.修改)
  7696. /// </summary>
  7697. /// <param name="dto"></param>
  7698. /// <returns></returns>
  7699. [HttpPost]
  7700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7701. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  7702. {
  7703. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  7704. if (groupData.Code != 200)
  7705. {
  7706. return Ok(JsonView(false, groupData.Msg));
  7707. }
  7708. #region 应用推送
  7709. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  7710. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7711. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7712. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  7713. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  7714. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  7715. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  7716. if (recheck)
  7717. {
  7718. //自动审核
  7719. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  7720. }
  7721. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7722. //2024-10-21 新增LZ UID
  7723. var userIds = new List<int>() { 21 };
  7724. string title = $"系统通知";
  7725. string content = "";
  7726. var diId = dto.DiId;
  7727. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7728. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7729. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7730. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7731. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7732. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  7733. #endregion
  7734. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7735. }
  7736. /// <summary>
  7737. /// 团组增减款项操作 删除
  7738. /// </summary>
  7739. /// <param name="dto"></param>
  7740. /// <returns></returns>
  7741. [HttpPost]
  7742. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7743. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  7744. {
  7745. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  7746. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  7747. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  7748. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  7749. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  7750. }
  7751. /// <summary>
  7752. /// 根据团组增减款项Id查询
  7753. /// </summary>
  7754. /// <param name="dto"></param>
  7755. /// <returns></returns>
  7756. [HttpPost]
  7757. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7758. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  7759. {
  7760. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  7761. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  7762. }
  7763. /// <summary>
  7764. /// 查询供应商名称
  7765. /// </summary>
  7766. /// <param name="dto"></param>
  7767. /// <returns></returns>
  7768. [HttpPost]
  7769. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  7770. {
  7771. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  7772. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  7773. ?? new List<Grp_DecreasePayments>();
  7774. dbResult = dbResult.Distinct(new
  7775. ProductComparer()).ToList();
  7776. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  7777. {
  7778. x.Id,
  7779. x.SupplierAddress,
  7780. x.SupplierArea,
  7781. x.SupplierContact,
  7782. x.SupplierContactNumber,
  7783. x.SupplierEmail,
  7784. x.SupplierName,
  7785. x.SupplierSocialAccount,
  7786. x.SupplierTypeId,
  7787. }).ToList());
  7788. return Ok(jw);
  7789. }
  7790. /// <summary>
  7791. /// 团组增减款项 OTA匹配
  7792. /// </summary>
  7793. /// <param name="file"></param>
  7794. /// <returns></returns>
  7795. [HttpPost]
  7796. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  7797. {
  7798. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  7799. string fileName = file.FileName;
  7800. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  7801. {
  7802. return Ok(JsonView(false, "请上传Excel文件!"));
  7803. }
  7804. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  7805. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  7806. if (!Directory.Exists(path))
  7807. {
  7808. Directory.CreateDirectory(path);
  7809. }
  7810. var filePath = @$"{path}/{fileName}";
  7811. //保存文件
  7812. using (FileStream fs = System.IO.File.Create(filePath))
  7813. {
  7814. file.CopyTo(fs);
  7815. fs.Flush();
  7816. }
  7817. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  7818. //读取ExcelFile
  7819. DataTable dt = ConvertExcelToDataTable(filePath);
  7820. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  7821. dt.TableName = "TB";
  7822. //修改table列名
  7823. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  7824. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  7825. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  7826. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  7827. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  7828. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  7829. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  7830. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  7831. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  7832. dt.Columns[9].ColumnName = "Quantity"; // 台数
  7833. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  7834. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  7835. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  7836. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  7837. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  7838. var otaOrderNos = new List<string>();
  7839. foreach (DataRow item in dt.Rows)
  7840. {
  7841. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  7842. }
  7843. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  7844. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  7845. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  7846. .Select((dp, di) => new
  7847. {
  7848. dp.PriceName,
  7849. dp.OTAOrderNo,
  7850. dp.FeeTotal,
  7851. di.TeamName,
  7852. })
  7853. .ToListAsync();
  7854. foreach (DataRow item in dt.Rows)
  7855. {
  7856. var otaOrderNo = item["OTAOrderNo"].ToString();
  7857. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  7858. if (oaData == null) continue;
  7859. item["GroupName"] = oaData.TeamName;
  7860. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  7861. }
  7862. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  7863. var pairs = new Dictionary<string, object>();
  7864. var datas = new List<DataTable>
  7865. {
  7866. dt
  7867. };
  7868. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  7869. return Ok(JsonView(true, "操作成功", new { url }));
  7870. }
  7871. #region
  7872. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  7873. {
  7874. // 创建Workbook对象
  7875. var workbook = new Workbook(excelFilePath);
  7876. // 获取第一个工作表
  7877. var worksheet = workbook.Worksheets[0];
  7878. // 将工作表转换为DataTable
  7879. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  7880. return dataTable;
  7881. }
  7882. #endregion
  7883. /// <summary>
  7884. /// 世运会数据
  7885. /// </summary>
  7886. /// <returns></returns>
  7887. [HttpGet]
  7888. public IActionResult WorldGamesData()
  7889. {
  7890. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  7891. var groupMenu = setData.GroupBy(x => x.T0);
  7892. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  7893. foreach (var item in groupMenu)
  7894. {
  7895. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  7896. {
  7897. Data = new SetDataView
  7898. {
  7899. Name = item.Key
  7900. },
  7901. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  7902. });
  7903. }
  7904. return Ok(JsonView(true, "success", resultArr));
  7905. }
  7906. #endregion
  7907. #region 文件上传、删除
  7908. /// <summary>
  7909. /// region 文件上传 可以带参数
  7910. /// </summary>
  7911. /// <param name="file"></param>
  7912. /// <returns></returns>
  7913. [HttpPost]
  7914. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7915. public async Task<IActionResult> UploadProject(IFormFile file)
  7916. {
  7917. //var TypeName = Request.Headers["TypeName"].ToString();
  7918. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  7919. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7920. ////文件名称
  7921. //string projectFileName = file.FileName;
  7922. ////上传的文件的路径
  7923. //string filePath = $"{fileDir}/{projectFileName}";
  7924. //if (TypeName == "A")//A代表团组增减款项
  7925. //{
  7926. // filePath = fileDir + $@"\团组增减款项相关文件";
  7927. // if (!Directory.Exists(filePath))
  7928. // {
  7929. // Directory.CreateDirectory(filePath);
  7930. // }
  7931. // //上传的文件的路径
  7932. // filePath += $@"\{projectFileName}";
  7933. //}
  7934. //else if (TypeName == "B")//B代表商邀相关文件
  7935. //{
  7936. // //上传的文件的路径
  7937. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  7938. // if (!Directory.Exists(filePath))
  7939. // {
  7940. // Directory.CreateDirectory(filePath);
  7941. // }
  7942. // //上传的文件的路径
  7943. // filePath = $@"\{projectFileName}";
  7944. //}
  7945. //try
  7946. //{
  7947. // using (FileStream fs = System.IO.File.Create(filePath))
  7948. // {
  7949. // file.CopyTo(fs);
  7950. // fs.Flush();
  7951. // }
  7952. //}
  7953. //catch (Exception ex)
  7954. //{
  7955. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  7956. //}
  7957. //return Ok(JsonView(true, "上传成功!", projectFileName));
  7958. try
  7959. {
  7960. var TypeName = Request.Headers["TypeName"].ToString();
  7961. if (file != null)
  7962. {
  7963. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7964. //文件名称
  7965. string projectFileName = file.FileName;
  7966. //上传的文件的路径
  7967. string filePath = $"{fileDir}/{projectFileName}";
  7968. if (TypeName == "A")//A代表团组增减款项
  7969. {
  7970. if (!Directory.Exists(fileDir))
  7971. {
  7972. Directory.CreateDirectory(fileDir);
  7973. }
  7974. //上传的文件的路径
  7975. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  7976. }
  7977. else if (TypeName == "B")//B代表商邀相关文件
  7978. {
  7979. if (!Directory.Exists(fileDir))
  7980. {
  7981. Directory.CreateDirectory(fileDir);
  7982. }
  7983. //上传的文件的路径
  7984. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  7985. }
  7986. using (FileStream fs = System.IO.File.Create(filePath))
  7987. {
  7988. file.CopyTo(fs);
  7989. fs.Flush();
  7990. }
  7991. return Ok(JsonView(true, "上传成功!", projectFileName));
  7992. }
  7993. else
  7994. {
  7995. return Ok(JsonView(false, "上传失败!"));
  7996. }
  7997. }
  7998. catch (Exception ex)
  7999. {
  8000. return Ok(JsonView(false, ex.Message));
  8001. }
  8002. }
  8003. /// <summary>
  8004. /// 删除指定文件
  8005. /// </summary>
  8006. /// <param name="dto"></param>
  8007. /// <returns></returns>
  8008. [HttpPost]
  8009. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8010. public async Task<IActionResult> DelFile(DelFileDto dto)
  8011. {
  8012. try
  8013. {
  8014. var TypeName = Request.Headers["TypeName"].ToString();
  8015. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  8016. string filePath = "";
  8017. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  8018. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  8019. int id = 0;
  8020. if (TypeName == "A")
  8021. {
  8022. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  8023. // 删除该文件
  8024. System.IO.File.Delete(filePath);
  8025. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  8026. .Where(a => a.Id == dto.Id)
  8027. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  8028. .ExecuteCommandAsync();
  8029. }
  8030. else if (TypeName == "B")
  8031. {
  8032. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  8033. // 删除该文件
  8034. System.IO.File.Delete(filePath);
  8035. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  8036. if (info != null)
  8037. {
  8038. string[] files = Array.Empty<string>();
  8039. if (!string.IsNullOrEmpty(info.Attachment))
  8040. {
  8041. try
  8042. {
  8043. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  8044. }
  8045. catch (Exception)
  8046. {
  8047. files = new List<string>() { info.Attachment }.ToArray();
  8048. }
  8049. }
  8050. if (files.Length > 0)
  8051. {
  8052. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  8053. string filePath2 = string.Empty;
  8054. if (files1.Length > 0)
  8055. {
  8056. filePath2 = JsonConvert.SerializeObject(files1);
  8057. }
  8058. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  8059. .Where(a => a.Id == dto.Id)
  8060. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  8061. .ExecuteCommandAsync();
  8062. }
  8063. }
  8064. }
  8065. if (id != 0)
  8066. {
  8067. return Ok(JsonView(true, "成功!"));
  8068. }
  8069. else
  8070. {
  8071. return Ok(JsonView(false, "失败!"));
  8072. }
  8073. }
  8074. catch (Exception ex)
  8075. {
  8076. return Ok(JsonView(false, "程序错误!"));
  8077. throw;
  8078. }
  8079. }
  8080. /// <summary>
  8081. /// 文件上传多个文件 可以带参数
  8082. /// </summary>
  8083. /// <param name="files"></param>
  8084. /// <returns></returns>
  8085. [HttpPost]
  8086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8087. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  8088. {
  8089. try
  8090. {
  8091. var TypeName = Request.Headers["TypeName"].ToString();
  8092. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  8093. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  8094. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  8095. var filePahts = new List<string>();
  8096. foreach (var file in files)
  8097. {
  8098. //文件名称
  8099. string projectFileName = file.FileName;
  8100. //上传的文件的路径
  8101. string filePath = $"{fileDir}/{projectFileName}";
  8102. if (TypeName == "A")//A代表团组增减款项
  8103. {
  8104. if (!Directory.Exists(fileDir))
  8105. {
  8106. Directory.CreateDirectory(fileDir);
  8107. }
  8108. //上传的文件的路径
  8109. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  8110. }
  8111. else if (TypeName == "B")//B代表商邀相关文件
  8112. {
  8113. if (!Directory.Exists(fileDir))
  8114. {
  8115. Directory.CreateDirectory(fileDir);
  8116. }
  8117. //上传的文件的路径
  8118. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  8119. }
  8120. using (FileStream fs = System.IO.File.Create(filePath))
  8121. {
  8122. file.CopyTo(fs);
  8123. fs.Flush();
  8124. }
  8125. filePahts.Add(projectFileName);
  8126. }
  8127. return Ok(JsonView(true, "上传成功!", filePahts));
  8128. }
  8129. catch (Exception ex)
  8130. {
  8131. return Ok(JsonView(false, ex.Message));
  8132. }
  8133. }
  8134. #endregion
  8135. #region 商邀费用录入
  8136. /// <summary>
  8137. /// 根据团组Id查询商邀费用列表
  8138. /// </summary>
  8139. /// <param name="dto"></param>
  8140. /// <returns></returns>
  8141. [HttpPost]
  8142. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8143. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  8144. {
  8145. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  8146. if (groupData.Code != 0)
  8147. {
  8148. return Ok(JsonView(false, groupData.Msg));
  8149. }
  8150. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8151. }
  8152. /// <summary>
  8153. /// 商邀费用列表
  8154. /// 下载文件
  8155. /// </summary>
  8156. /// <param name="id"></param>
  8157. /// <returns></returns>
  8158. [HttpGet("{id}")]
  8159. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8160. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  8161. {
  8162. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  8163. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  8164. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  8165. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  8166. var filePaths = new List<string>();
  8167. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  8168. try
  8169. {
  8170. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  8171. }
  8172. catch (Exception ex)
  8173. {
  8174. filePaths.Add(info.Attachment);
  8175. }
  8176. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  8177. for (int i = 0; i < filePaths.Count; i++)
  8178. {
  8179. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  8180. }
  8181. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  8182. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  8183. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  8184. {
  8185. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  8186. {
  8187. foreach (string filePath in filePaths)
  8188. {
  8189. if (System.IO.File.Exists(filePath))
  8190. {
  8191. // 获取文件名
  8192. string fileName = Path.GetFileName(filePath);
  8193. // 将文件添加到ZIP归档中
  8194. zipArchive.CreateEntryFromFile(filePath, fileName);
  8195. }
  8196. }
  8197. }
  8198. }
  8199. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  8200. }
  8201. /// <summary>
  8202. /// 商邀费用 Info Page 基础数据源
  8203. /// </summary>
  8204. /// <returns></returns>
  8205. [HttpPost]
  8206. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8207. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  8208. {
  8209. try
  8210. {
  8211. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  8212. if (groupData.Code != 0)
  8213. {
  8214. return Ok(JsonView(false, groupData.Msg));
  8215. }
  8216. return Ok(JsonView(true, "操作成功", groupData.Data));
  8217. }
  8218. catch (Exception ex)
  8219. {
  8220. return Ok(JsonView(false, ex.Message));
  8221. throw;
  8222. }
  8223. }
  8224. /// <summary>
  8225. /// 根据商邀费用ID查询C表和商邀费用数据
  8226. /// </summary>
  8227. /// <param name="dto"></param>
  8228. /// <returns></returns>
  8229. [HttpPost]
  8230. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8231. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  8232. {
  8233. try
  8234. {
  8235. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  8236. if (groupData.Code != 0)
  8237. {
  8238. return Ok(JsonView(false, groupData.Msg));
  8239. }
  8240. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8241. }
  8242. catch (Exception ex)
  8243. {
  8244. return Ok(JsonView(false, ex.Message));
  8245. throw;
  8246. }
  8247. }
  8248. /// <summary>
  8249. /// 商邀费用录入操作(Status:1.新增,2.修改)
  8250. /// </summary>
  8251. /// <param name="dto"></param>
  8252. /// <returns></returns>
  8253. [HttpPost]
  8254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8255. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  8256. {
  8257. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  8258. if (groupData.Code != 0)
  8259. {
  8260. return Ok(JsonView(false, groupData.Msg));
  8261. }
  8262. #region 应用推送
  8263. try
  8264. {
  8265. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  8266. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  8267. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8268. //2024-10-21 新增LZ UID
  8269. var userIds = new List<int>() { 21 };
  8270. string title = $"系统通知";
  8271. string content = "";
  8272. var diId = dto.DiId;
  8273. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  8274. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  8275. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8276. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8277. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  8278. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  8279. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  8280. }
  8281. catch (Exception ex)
  8282. {
  8283. }
  8284. #endregion
  8285. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8286. }
  8287. /// <summary>
  8288. /// 商邀删除
  8289. /// </summary>
  8290. /// <param name="dto"></param>
  8291. /// <returns></returns>
  8292. [HttpPost]
  8293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8294. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  8295. {
  8296. try
  8297. {
  8298. _sqlSugar.BeginTran();
  8299. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  8300. .SetColumns(it => new Grp_InvitationOfficialActivities()
  8301. {
  8302. IsDel = 1,
  8303. DeleteUserId = dto.DeleteUserId,
  8304. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8305. })
  8306. .Where(it => it.Id == dto.Id)
  8307. .ExecuteCommand();
  8308. if (res1 > 0)
  8309. {
  8310. int _diId = 0;
  8311. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  8312. if (_ioaInfo != null)
  8313. {
  8314. _diId = _ioaInfo.DiId;
  8315. }
  8316. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  8317. .SetColumns(a => new Grp_CreditCardPayment()
  8318. {
  8319. IsDel = 1,
  8320. DeleteUserId = dto.DeleteUserId,
  8321. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8322. })
  8323. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  8324. .ExecuteCommand();
  8325. if (res2 > 0)
  8326. {
  8327. _sqlSugar.CommitTran();
  8328. return Ok(JsonView(true, "删除成功!"));
  8329. }
  8330. }
  8331. _sqlSugar.RollbackTran();
  8332. return Ok(JsonView(false, "删除失败"));
  8333. }
  8334. catch (Exception ex)
  8335. {
  8336. _sqlSugar.RollbackTran();
  8337. return Ok(JsonView(false, ex.Message));
  8338. }
  8339. }
  8340. #endregion
  8341. #region 票据上传
  8342. /// <summary>
  8343. /// 团组模块文件上传
  8344. /// </summary>
  8345. /// <param name="dto"></param>
  8346. /// <returns></returns>
  8347. [HttpPost]
  8348. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  8349. {
  8350. var jw = JsonView(false);
  8351. long M = 1024 * 1024;
  8352. if (dto.Files == null || dto.Files.Count == 0)
  8353. {
  8354. jw.Msg = "无文件信息!";
  8355. return Ok(jw);
  8356. }
  8357. if (dto.Files.Sum(x => x.Length) > 20 * M)
  8358. {
  8359. jw.Msg = "文件大小超过20M!";
  8360. return Ok(jw);
  8361. }
  8362. //var nameSp = dto.File.FileName.Split(".");
  8363. //if (nameSp.Length < 2)
  8364. //{
  8365. // jw.Msg = "拓展名称有误!";
  8366. // return Ok(jw);
  8367. //}
  8368. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  8369. //if (!existsName.Contains(nameSp[1].ToUpper()))
  8370. //{
  8371. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  8372. // return Ok(jw);
  8373. //}
  8374. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  8375. if (Ctable == null)
  8376. {
  8377. jw.Msg = "Ctable指向有误!";
  8378. return Ok(jw);
  8379. }
  8380. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  8381. if (groupInfo == null)
  8382. {
  8383. jw.Msg = "团组信息不存在!";
  8384. return Ok(jw);
  8385. }
  8386. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  8387. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8388. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  8389. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8390. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  8391. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  8392. try
  8393. {
  8394. if (!Directory.Exists(fileBase))
  8395. {
  8396. Directory.CreateDirectory(fileBase);
  8397. }
  8398. var saveArr = new List<Grp_GroupModelFile>();
  8399. foreach (var fileStream in dto.Files)
  8400. {
  8401. var fileName = fileStream.FileName;
  8402. string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
  8403. string extension = Path.GetExtension(fileName);
  8404. int counter = 0;
  8405. //文件重命名验证
  8406. string newFilePath;
  8407. string currFileName;
  8408. do
  8409. {
  8410. string newFileName;
  8411. if (counter == 0) newFileName = $"{fileNameWithoutExtension}{extension}";
  8412. else newFileName = $"{fileNameWithoutExtension} ({counter}){extension}";
  8413. currFileName = newFileName;
  8414. newFilePath = Path.Combine(fileBase, newFileName);
  8415. counter++;
  8416. } while (System.IO.File.Exists(newFilePath));
  8417. var saveFilePath = fileBase + "\\" + currFileName;
  8418. var file = new Grp_GroupModelFile()
  8419. {
  8420. Cid = dto.Cid,
  8421. CreateTime = DateTime.Now,
  8422. CreateUserId = dto.Userid,
  8423. Ctable = dto.Ctable,
  8424. Diid = dto.Diid,
  8425. IsDel = 0,
  8426. FilePath = saveFilePath,
  8427. FileName = currFileName
  8428. };
  8429. using (FileStream fs = System.IO.File.Create(saveFilePath))
  8430. {
  8431. fileStream.CopyTo(fs);
  8432. fs.Flush();
  8433. }
  8434. saveArr.Add(file);
  8435. }
  8436. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  8437. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  8438. jw = JsonView(true, "保存成功!", new
  8439. {
  8440. count = addResult,
  8441. filesName = saveArr.Select(x => x.FileName)
  8442. });
  8443. }
  8444. catch (Exception ex)
  8445. {
  8446. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  8447. {
  8448. count = 0,
  8449. filesName = Array.Empty<string>(),
  8450. });
  8451. }
  8452. return Ok(jw);
  8453. }
  8454. /// <summary>
  8455. /// 查询各模块已保存文件
  8456. /// </summary>
  8457. /// <param name="dto"></param>
  8458. /// <returns></returns>
  8459. [HttpPost]
  8460. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  8461. {
  8462. var expression = Expressionable.Create<Grp_GroupModelFile>()
  8463. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  8464. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  8465. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  8466. {
  8467. expression = Expressionable.Create<Grp_GroupModelFile>()
  8468. .And(x => visaIds.Contains(x.CreateUserId));
  8469. }
  8470. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  8471. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  8472. .Where(expression.ToExpression())
  8473. .ToList();
  8474. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  8475. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  8476. {
  8477. x.FileName,
  8478. x.Id,
  8479. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  8480. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  8481. })));
  8482. }
  8483. /// <summary>
  8484. /// 下载该团组下的所有文件
  8485. /// </summary>
  8486. /// <param name="dto"></param>
  8487. /// <returns></returns>
  8488. [HttpPost]
  8489. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  8490. {
  8491. var jw = JsonView(false);
  8492. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  8493. if (groupInfo == null)
  8494. {
  8495. jw.Msg = "团组信息不存在!";
  8496. return Ok(jw);
  8497. }
  8498. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  8499. var isModule = Convert.ToBoolean(dto.isModule);
  8500. var Zips = new Dictionary<string, Stream>();
  8501. var io = new IOOperatorHelper();
  8502. if (isModule)
  8503. {
  8504. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  8505. foreach (var moduleArr in moduleGroup)
  8506. {
  8507. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  8508. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  8509. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8510. var chiZips = new Dictionary<string, Stream>();
  8511. foreach (var item in moduleArr)
  8512. {
  8513. if (System.IO.File.Exists(item.FilePath))
  8514. {
  8515. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  8516. {
  8517. byte[] bytes = new byte[fileStream.Length];
  8518. fileStream.Read(bytes, 0, bytes.Length);
  8519. fileStream.Close();
  8520. Stream stream = new MemoryStream(bytes);
  8521. chiZips.Add(item.FileName, stream);
  8522. }
  8523. }
  8524. }
  8525. if (chiZips.Count > 0)
  8526. {
  8527. var byts = io.ConvertZipStream(chiZips);
  8528. Stream stream = new MemoryStream(byts);
  8529. Zips.Add(key.Name + "_.zip", stream);
  8530. }
  8531. }
  8532. }
  8533. else
  8534. {
  8535. foreach (var item in dbQuery)
  8536. {
  8537. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  8538. {
  8539. byte[] bytes = new byte[fileStream.Length];
  8540. fileStream.Read(bytes, 0, bytes.Length);
  8541. fileStream.Close();
  8542. var stream = new MemoryStream(bytes);
  8543. while (Zips.ContainsKey(item.FileName))
  8544. {
  8545. item.FileName = new Random().Next(100) + "_" + item.FileName;
  8546. }
  8547. Zips.Add(item.FileName, stream);
  8548. }
  8549. }
  8550. }
  8551. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  8552. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8553. if (Zips.Count > 0)
  8554. {
  8555. var byts = io.ConvertZipStream(Zips);
  8556. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  8557. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  8558. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  8559. }
  8560. else
  8561. {
  8562. jw.Msg = "暂无生成文件!";
  8563. }
  8564. return Ok(jw);
  8565. }
  8566. /// <summary>
  8567. /// 下载该团组下此模块的所有文件
  8568. /// </summary>
  8569. /// <param name="dto"></param>
  8570. /// <returns></returns>
  8571. [HttpPost]
  8572. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  8573. {
  8574. var jw = JsonView(false);
  8575. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  8576. if (groupInfo == null)
  8577. {
  8578. jw.Msg = "团组信息不存在!";
  8579. return Ok(jw);
  8580. }
  8581. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  8582. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  8583. && x.IsDel == 0);
  8584. if (key == null)
  8585. {
  8586. jw.Msg = "Ctable指向错误!";
  8587. return Ok(jw);
  8588. }
  8589. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  8590. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8591. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  8592. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8593. var io = new IOOperatorHelper();
  8594. var Zips = new Dictionary<string, Stream>();
  8595. foreach (var item in dbQuery)
  8596. {
  8597. if (System.IO.File.Exists(item.FilePath))
  8598. {
  8599. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  8600. {
  8601. byte[] bytes = new byte[fileStream.Length];
  8602. fileStream.Read(bytes, 0, bytes.Length);
  8603. fileStream.Close();
  8604. var stream = new MemoryStream(bytes);
  8605. while (Zips.ContainsKey(item.FileName))
  8606. {
  8607. item.FileName = new Random().Next(100) + "_" + item.FileName;
  8608. }
  8609. Zips.Add(item.FileName, stream);
  8610. }
  8611. }
  8612. }
  8613. if (Zips.Count > 0)
  8614. {
  8615. var byts = io.ConvertZipStream(Zips);
  8616. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  8617. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  8618. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  8619. }
  8620. else
  8621. {
  8622. jw.Msg = "暂无生成文件!";
  8623. }
  8624. return Ok(jw);
  8625. }
  8626. /// <summary>
  8627. /// 删除该团组下的指定文件
  8628. /// </summary>
  8629. /// <param name="dto"></param>
  8630. /// <returns></returns>
  8631. [HttpPost]
  8632. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  8633. {
  8634. var jw = JsonView(false);
  8635. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  8636. if (sing == null)
  8637. {
  8638. jw.Msg = "暂无";
  8639. return Ok(jw);
  8640. }
  8641. if (System.IO.File.Exists(sing.FilePath))
  8642. {
  8643. try
  8644. {
  8645. System.IO.File.Delete(sing.FilePath);
  8646. }
  8647. catch (Exception ex)
  8648. {
  8649. jw.Msg = "删除失败!" + ex.Message;
  8650. return Ok(jw);
  8651. }
  8652. }
  8653. sing.IsDel = 1;
  8654. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  8655. sing.DeleteUserId = dto.UserId;
  8656. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  8657. jw = JsonView(true, "删除成功!");
  8658. return Ok(jw);
  8659. }
  8660. #endregion
  8661. #region 共享文件上传
  8662. /// <summary>
  8663. /// 超支通知推送
  8664. /// </summary>
  8665. /// <param name="dto"></param>
  8666. /// <returns></returns>
  8667. [HttpPost]
  8668. public async Task<IActionResult> qyWeChatNotification(qyWeChatNotificationDto dto)
  8669. {
  8670. //81 邀请/公务活动
  8671. var syCTable = new List<int> { 81 };
  8672. //76 酒店预订
  8673. //79 车/导游地接
  8674. //85 机票预订
  8675. var gjCTable = new List<int> { 76, 79, 85 };
  8676. var jw = JsonView(false);
  8677. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  8678. if (di == null)
  8679. {
  8680. jw.Msg = "团组信息不存在!";
  8681. return Ok(jw);
  8682. }
  8683. var user = _sqlSugar.Queryable<Sys_Users>().First(x => x.IsDel == 0 && x.Id == dto.UserId);
  8684. if (user == null)
  8685. {
  8686. jw.Msg = "用户信息不存在!";
  8687. return Ok(jw);
  8688. }
  8689. if (syCTable.Contains(dto.CTable))
  8690. {
  8691. await AppNoticeLibrary.SendChatMsg_ExpenseOverrunsChat(dto.Diid, dto.UserId, dto.CTable, QiyeWeChatEnum.ExpenseOverrunsChat02);
  8692. }
  8693. else if (gjCTable.Contains(dto.CTable))
  8694. {
  8695. await AppNoticeLibrary.SendChatMsg_ExpenseOverrunsChat(dto.Diid, dto.UserId, dto.CTable, QiyeWeChatEnum.ExpenseOverrunsChat01);
  8696. }
  8697. else
  8698. {
  8699. jw.Msg = "CTABLE类型有误!";
  8700. }
  8701. jw = JsonView(true, "推送成功!", "");
  8702. return Ok(jw);
  8703. }
  8704. /// <summary>
  8705. /// 共享文件数据初始化
  8706. /// </summary>
  8707. /// <returns></returns>
  8708. [HttpGet]
  8709. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  8710. {
  8711. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  8712. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  8713. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  8714. .Select(x => x.Id)
  8715. .ToList()
  8716. .Contains(userid);
  8717. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  8718. .Where(x => x.STid == 111 && x.IsDel == 0)
  8719. .Select(x => new
  8720. {
  8721. x.Name,
  8722. x.Id,
  8723. }).ToList();
  8724. if (isMarketingDepartment)
  8725. {
  8726. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  8727. }
  8728. if (portType == 1)
  8729. {
  8730. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  8731. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  8732. .Where(x => x.IsDel == 0)
  8733. .OrderByDescending(x => x.VisitDate)
  8734. .Select(x => new
  8735. {
  8736. x.TeamName,
  8737. x.Id,
  8738. x.CityId,
  8739. })
  8740. .ToList()
  8741. .Select(x =>
  8742. {
  8743. var provinceId = x.CityId;
  8744. var isDefualtVal = true;
  8745. if (provinceId > 0)
  8746. {
  8747. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  8748. if (parentId != null)
  8749. {
  8750. isDefualtVal = false;
  8751. provinceId = (int)parentId;
  8752. }
  8753. }
  8754. if (isDefualtVal)
  8755. {
  8756. provinceId = 122; //默认四川
  8757. }
  8758. return new
  8759. {
  8760. x.TeamName,
  8761. x.Id,
  8762. provinceId,
  8763. };
  8764. })
  8765. .ToList();
  8766. return Ok(JsonView(true, "SUCCESS!", new
  8767. {
  8768. dropDownType,
  8769. dropDownGroupList,
  8770. isMarketingDepartment
  8771. }));
  8772. }
  8773. else if (portType == 2 || portType == 3)
  8774. {
  8775. return Ok(JsonView(true, "SUCCESS!", new
  8776. {
  8777. dropDownType,
  8778. isMarketingDepartment
  8779. }));
  8780. }
  8781. else
  8782. {
  8783. return Ok(JsonView(false, "portType有误!"));
  8784. }
  8785. }
  8786. /// <summary>
  8787. /// 共享文件上传
  8788. /// </summary>
  8789. /// <param name="dto"></param>
  8790. /// <returns></returns>
  8791. [HttpPost]
  8792. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  8793. {
  8794. var isGroup = new List<int> { 1412 };
  8795. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  8796. {
  8797. return Ok(JsonView(false, "该文件需要关联团组!"));
  8798. }
  8799. if (dto.Files == null || dto.Files.Count == 0)
  8800. {
  8801. return Ok(JsonView(false, "无文件信息!"));
  8802. }
  8803. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  8804. {
  8805. return Ok(JsonView(false, "文件大小超过20M!"));
  8806. }
  8807. if (dto.Userid < 1)
  8808. {
  8809. return Ok(JsonView(false, "请传入有效的Userid!"));
  8810. }
  8811. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  8812. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  8813. .Select((u, j) => new
  8814. {
  8815. u.CnName,
  8816. UserId = u.Id,
  8817. j.JobName,
  8818. })
  8819. .First();
  8820. if (jobInfo == null)
  8821. {
  8822. return Ok(JsonView(false, "请传入有效的Userid!"));
  8823. }
  8824. var commonFileExtensions = new List<string>
  8825. {
  8826. // 文本文件
  8827. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  8828. // 图片文件
  8829. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  8830. // 视频文件
  8831. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  8832. // 音频文件
  8833. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  8834. // 压缩文件
  8835. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  8836. // 数据文件
  8837. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  8838. };
  8839. try
  8840. {
  8841. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  8842. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  8843. commonFileExtensions.AddRange(settingExtend);
  8844. }
  8845. catch (Exception)
  8846. { }
  8847. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  8848. if (setdata == null)
  8849. {
  8850. return Ok(JsonView(false, "请传入有效的FileType!"));
  8851. }
  8852. var insertList = new List<Grp_GroupShareFile>();
  8853. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  8854. if (!Directory.Exists(winPath))
  8855. {
  8856. Directory.CreateDirectory(winPath);
  8857. }
  8858. foreach (var item in dto.Files)
  8859. {
  8860. var houzui = Path.GetExtension(item.FileName);
  8861. if (!commonFileExtensions.Contains(houzui))
  8862. {
  8863. return Ok(JsonView(false, "未知后缀名称!"));
  8864. }
  8865. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  8866. var saveFilePath = winPath + fileName;
  8867. using (FileStream fs = System.IO.File.Create(saveFilePath))
  8868. {
  8869. item.CopyTo(fs);
  8870. fs.Flush();
  8871. }
  8872. var fileDetail = new Grp_GroupShareFile()
  8873. {
  8874. CreateUserId = dto.Userid,
  8875. CreateTime = DateTime.Now,
  8876. UploadJob = jobInfo.JobName,
  8877. FileName = fileName,
  8878. FileType = dto.FileType,
  8879. Diid = dto.Diid,
  8880. FilePath = winPath + fileName,
  8881. };
  8882. insertList.Add(fileDetail);
  8883. }
  8884. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  8885. return Ok(JsonView(true, "保存成功!"));
  8886. }
  8887. /// <summary>
  8888. /// 查询共享文件列表
  8889. /// </summary>
  8890. /// <param name="dto"></param>
  8891. /// <returns></returns>
  8892. [HttpPost]
  8893. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  8894. {
  8895. var isGroup = new List<int> { 1412 };
  8896. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  8897. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  8898. .And(x => x.Diid == dto.Diid)
  8899. .And(x => x.FileType == dto.FileType)
  8900. .And(x => x.IsDel == 0)
  8901. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  8902. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  8903. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  8904. int totalCount = 0;
  8905. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  8906. .Where(queryExpression.ToExpression())
  8907. .OrderBy(x => x.UploadJob)
  8908. .Select(x => new
  8909. {
  8910. x.Id,
  8911. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  8912. x.FileName,
  8913. x.FileType,
  8914. x.CreateTime,
  8915. })
  8916. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  8917. return Ok(JsonView(true, "SUCCESS!", new
  8918. {
  8919. FileList = dbQuery,
  8920. dto.PageSize,
  8921. dto.PageIndex,
  8922. totalCount
  8923. }));
  8924. }
  8925. /// <summary>
  8926. /// 删除共享文件模块下的指定文件
  8927. /// </summary>
  8928. /// <param name="dto"></param>
  8929. /// <returns></returns>
  8930. [HttpPost]
  8931. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  8932. {
  8933. var jw = JsonView(false);
  8934. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  8935. if (sing == null)
  8936. {
  8937. jw.Msg = "暂无文件信息!";
  8938. return Ok(jw);
  8939. }
  8940. if (sing.CreateUserId != dto.UserId)
  8941. {
  8942. jw.Msg = "只能删除自己上传的文件!";
  8943. return Ok(jw);
  8944. }
  8945. if (System.IO.File.Exists(sing.FilePath))
  8946. {
  8947. try
  8948. {
  8949. System.IO.File.Delete(sing.FilePath);
  8950. }
  8951. catch (Exception ex)
  8952. {
  8953. jw.Msg = "删除失败!" + ex.Message;
  8954. return Ok(jw);
  8955. }
  8956. }
  8957. sing.IsDel = 1;
  8958. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  8959. sing.DeleteUserId = dto.UserId;
  8960. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  8961. jw = JsonView(true, "删除成功!");
  8962. return Ok(jw);
  8963. }
  8964. #endregion
  8965. #region 团组英文资料
  8966. /// <summary>
  8967. /// 查询团组英文所有资料
  8968. /// </summary>
  8969. /// <param name="dto"></param>
  8970. /// <returns></returns>
  8971. [HttpPost]
  8972. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8973. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  8974. {
  8975. try
  8976. {
  8977. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  8978. if (groupData.Code != 0)
  8979. {
  8980. return Ok(JsonView(false, groupData.Msg));
  8981. }
  8982. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8983. }
  8984. catch (Exception ex)
  8985. {
  8986. return Ok(JsonView(false, ex.Message));
  8987. throw;
  8988. }
  8989. }
  8990. /// <summary>
  8991. /// 团组英文资料操作(Status:1.新增,2.修改)
  8992. /// </summary>
  8993. /// <param name="dto"></param>
  8994. /// <returns></returns>
  8995. [HttpPost]
  8996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8997. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  8998. {
  8999. try
  9000. {
  9001. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  9002. if (groupData.Code != 0)
  9003. {
  9004. return Ok(JsonView(false, groupData.Msg));
  9005. }
  9006. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9007. }
  9008. catch (Exception ex)
  9009. {
  9010. return Ok(JsonView(false, ex.Message));
  9011. throw;
  9012. }
  9013. }
  9014. /// <summary>
  9015. /// 团组英文资料Id查询数据
  9016. /// </summary>
  9017. /// <param name="dto"></param>
  9018. /// <returns></returns>
  9019. [HttpPost]
  9020. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9021. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  9022. {
  9023. try
  9024. {
  9025. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  9026. if (_DelegationEnData != null)
  9027. {
  9028. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  9029. }
  9030. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  9031. }
  9032. catch (Exception ex)
  9033. {
  9034. return Ok(JsonView(false, "程序错误!"));
  9035. throw;
  9036. }
  9037. }
  9038. /// <summary>
  9039. /// 团组英文资料删除
  9040. /// </summary>
  9041. /// <param name="dto"></param>
  9042. /// <returns></returns>
  9043. [HttpPost]
  9044. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9045. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  9046. {
  9047. try
  9048. {
  9049. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  9050. if (!res)
  9051. {
  9052. return Ok(JsonView(false, "删除失败"));
  9053. }
  9054. return Ok(JsonView(true, "删除成功!"));
  9055. }
  9056. catch (Exception ex)
  9057. {
  9058. return Ok(JsonView(false, ex.Message));
  9059. throw;
  9060. }
  9061. }
  9062. #endregion
  9063. #region 导出邀请函
  9064. /// <summary>
  9065. /// 导出邀请函页面初始化
  9066. /// </summary>
  9067. /// <param name="dto"></param>
  9068. /// <returns></returns>
  9069. [HttpPost]
  9070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9071. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  9072. {
  9073. try
  9074. {
  9075. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  9076. var crm_Deles = new List<Crm_DeleClient>();
  9077. if (dto.DiId == 0)
  9078. {
  9079. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  9080. }
  9081. else
  9082. {
  9083. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  9084. }
  9085. return Ok(JsonView(true, "查询成功!", new
  9086. {
  9087. deleClient = crm_Deles,
  9088. delegations = grp_Delegations
  9089. }));
  9090. }
  9091. catch (Exception ex)
  9092. {
  9093. return Ok(JsonView(false, "程序错误!"));
  9094. throw;
  9095. }
  9096. }
  9097. /// <summary>
  9098. /// 导出邀请函
  9099. /// </summary>
  9100. /// <param name="dto"></param>
  9101. /// <returns></returns>
  9102. [HttpPost]
  9103. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9104. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  9105. {
  9106. #region 参数验证
  9107. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  9108. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9109. #endregion
  9110. try
  9111. {
  9112. var transDic = new Dictionary<string, string>();
  9113. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9114. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9115. From Grp_TourClientList tcl
  9116. Left Join
  9117. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9118. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9119. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9120. From Crm_DeleClient dc
  9121. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9122. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9123. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9124. Where dc.IsDel = 0) temp
  9125. On temp.DcId =tcl.ClientId
  9126. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  9127. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  9128. var texts = new List<string>();
  9129. if (datas.Count != 0)
  9130. {
  9131. foreach (TourClientListDetailsView item in datas)
  9132. {
  9133. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  9134. {
  9135. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  9136. }
  9137. else
  9138. {
  9139. string name = item.LastName + item.FirstName;
  9140. texts.Add(name);
  9141. }
  9142. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  9143. {
  9144. if (!transDic.ContainsKey(item.Job))
  9145. {
  9146. texts.Add(item.Job);
  9147. }
  9148. }
  9149. if (!string.IsNullOrEmpty(item.CompanyFullName))
  9150. {
  9151. texts.Add(item.CompanyFullName);
  9152. }
  9153. }
  9154. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  9155. if (transData.Count > 0)
  9156. {
  9157. foreach (TranslateResult item in transData)
  9158. {
  9159. if (!transDic.ContainsKey(item.Query))
  9160. {
  9161. transDic.Add(item.Query, item.Translation);
  9162. }
  9163. }
  9164. }
  9165. var list = new List<GuestList>();
  9166. foreach (var dele in datas)
  9167. {
  9168. var guestList = new GuestList();
  9169. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  9170. {
  9171. guestList.Name = dele.Pinyin;
  9172. }
  9173. else
  9174. {
  9175. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  9176. guestList.Name = Name;
  9177. }
  9178. if (dele.Sex == 0)
  9179. {
  9180. guestList.Sex = "Male";
  9181. }
  9182. else if (dele.Sex == 1)
  9183. {
  9184. guestList.Sex = "Female";
  9185. }
  9186. guestList.DOB = dele.BirthDay.Replace('-', '.');
  9187. if (!string.IsNullOrEmpty(dele.Job))
  9188. {
  9189. guestList.Job = dele.Job;
  9190. }
  9191. list.Add(guestList);
  9192. }
  9193. //载入模板
  9194. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  9195. var builder = new DocumentBuilder(doc);
  9196. //获取word里所有表格
  9197. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9198. //获取所填表格的序数
  9199. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9200. var rowStart = tableOne.Rows[0]; //获取第1行
  9201. //循环赋值
  9202. for (int i = 0; i < list.Count; i++)
  9203. {
  9204. builder.MoveToCell(0, i + 1, 0, 0);
  9205. builder.Write(list[i].Name.ToString());
  9206. builder.MoveToCell(0, i + 1, 1, 0);
  9207. builder.Write(list[i].Sex.ToString());
  9208. builder.MoveToCell(0, i + 1, 2, 0);
  9209. builder.Write(list[i].DOB.ToString());
  9210. builder.MoveToCell(0, i + 1, 3, 0);
  9211. builder.Write(list[i].Job.ToString());
  9212. }
  9213. //删除多余行
  9214. while (tableOne.Rows.Count > list.Count + 1)
  9215. {
  9216. tableOne.Rows.RemoveAt(list.Count + 1);
  9217. }
  9218. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9219. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  9220. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  9221. doc.Save(filePath);
  9222. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  9223. return Ok(JsonView(true, "操作成功!", Url));
  9224. }
  9225. else
  9226. {
  9227. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  9228. }
  9229. }
  9230. catch (Exception ex)
  9231. {
  9232. return Ok(JsonView(false, ex.Message));
  9233. throw;
  9234. }
  9235. }
  9236. #endregion
  9237. #region 团组经理模块 出入境费用
  9238. /// <summary>
  9239. /// 团组模块 - 出入境费用 - 省份基础数据源
  9240. /// </summary>
  9241. /// <returns></returns>
  9242. [HttpGet]
  9243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9244. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  9245. {
  9246. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  9247. }
  9248. /// <summary>
  9249. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  9250. /// </summary>
  9251. /// <param name="dto"></param>
  9252. /// <returns></returns>
  9253. [HttpPost]
  9254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9255. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  9256. {
  9257. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  9258. var groupNamFirst = groupNameData.FirstOrDefault();
  9259. //SetDataInfoView
  9260. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  9261. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  9262. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  9263. //验证城市归属并给默认值
  9264. int provinceId = 122;
  9265. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  9266. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  9267. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  9268. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9269. return Ok(JsonView(true, "查询成功!", new
  9270. {
  9271. GroupNameData = groupNameData,
  9272. CurrencyData = _CurrencyData,
  9273. WordTypeData = wordTypeData,
  9274. ExcelTypeData = excelTypeData,
  9275. CurrencyInit = _currencyInfos,
  9276. ViewPermissionData = viewPermissionData
  9277. }));
  9278. }
  9279. /// <summary>
  9280. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  9281. /// </summary>
  9282. /// <returns></returns>
  9283. [HttpGet("{provinceId}")]
  9284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9285. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  9286. {
  9287. //验证城市归属并给默认值
  9288. if (provinceId < 1) provinceId = 122;
  9289. /*
  9290. * 122 四川
  9291. * 108 贵州
  9292. * 103 重庆
  9293. * 132 云南
  9294. */
  9295. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  9296. return Ok(JsonView(true, "查询成功!", new
  9297. {
  9298. WordTypeData = wordTypeData,
  9299. ExcelTypeData = excelTypeData,
  9300. }));
  9301. }
  9302. /// <summary>
  9303. /// 团组模块 - 出入境费用
  9304. /// 实时汇率 tips
  9305. /// 签证费用 tips
  9306. /// 机票费用 tips
  9307. /// </summary>
  9308. /// <returns></returns>
  9309. [HttpPost]
  9310. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9311. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  9312. {
  9313. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  9314. //默认币种显示
  9315. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  9316. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  9317. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  9318. return Ok(JsonView(true, "查询成功!", new
  9319. {
  9320. //GroupNameData = groupNameData.Data,
  9321. visaData = visaData.Data,
  9322. airData,
  9323. reteInfos
  9324. }));
  9325. }
  9326. #region 城市区间交通费
  9327. #endregion
  9328. /// <summary>
  9329. /// 团组模块 - 出入境费用 - Info
  9330. /// </summary>
  9331. /// <param name="dto"></param>
  9332. /// <returns></returns>
  9333. [HttpPost]
  9334. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  9335. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9336. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  9337. {
  9338. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9339. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9340. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  9341. }
  9342. /// <summary>
  9343. /// 团组模块 - 出入境费用 - 设置view权限
  9344. /// </summary>
  9345. /// <returns></returns>
  9346. [HttpPost]
  9347. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9348. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  9349. {
  9350. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9351. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9352. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9353. var permissions = new List<Grp_EnterExitCostPermission>();
  9354. foreach (var userId in dto.UserIds)
  9355. {
  9356. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  9357. }
  9358. if (permissions.Any())
  9359. {
  9360. _sqlSugar.BeginTran();
  9361. try
  9362. {
  9363. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  9364. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9365. if (result < 1)
  9366. {
  9367. _sqlSugar.RollbackTran();
  9368. return Ok(JsonView(false));
  9369. }
  9370. }
  9371. catch (Exception ex)
  9372. {
  9373. _sqlSugar.RollbackTran();
  9374. return Ok(JsonView(false, ex.Message));
  9375. }
  9376. _sqlSugar.CommitTran();
  9377. return Ok(JsonView(true));
  9378. }
  9379. return Ok(JsonView(false));
  9380. }
  9381. /// <summary>
  9382. /// 团组模块 - 出入境费用 - Add And Update
  9383. /// </summary>
  9384. /// <returns></returns>
  9385. [HttpPost]
  9386. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  9387. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9388. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  9389. {
  9390. try
  9391. {
  9392. var rateRecords = new List<RateRecordInfo>();
  9393. #region 汇率保存前存储
  9394. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  9395. if (info != null)
  9396. {
  9397. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  9398. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  9399. {
  9400. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  9401. {
  9402. CurrencyCode = x.CurrencyCode,
  9403. CurrencyName = x.CurrencyName,
  9404. UpdatePreRate = x.Rate,
  9405. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  9406. }).ToList();
  9407. }
  9408. else
  9409. {
  9410. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  9411. {
  9412. CurrencyCode = x.CurrencyCode,
  9413. CurrencyName = x.CurrencyName,
  9414. UpdatePreRate = 0.00M,
  9415. UpdateBreRate = x.Rate
  9416. }).ToList();
  9417. }
  9418. }
  9419. else
  9420. {
  9421. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  9422. {
  9423. CurrencyCode = x.CurrencyCode,
  9424. CurrencyName = x.CurrencyName,
  9425. UpdatePreRate = 0.00M,
  9426. UpdateBreRate = x.Rate
  9427. }).ToList();
  9428. }
  9429. #endregion
  9430. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  9431. if (dto.DayOtherPriceData.Any())
  9432. {
  9433. var inserList = dto.DayOtherPriceData
  9434. .Where(x => x.Id == 0)
  9435. .Select(x => new Grp_DayOtherPrice
  9436. {
  9437. Cost = x.Cost,
  9438. Id = x.Id,
  9439. CreateTime = DateTime.Now,
  9440. CreateUserId = dto.UserId,
  9441. Currency = x.Currency,
  9442. Diid = x.DiId,
  9443. Index = x.Index,
  9444. IsDel = 0,
  9445. SetDataId = x.SetDataId,
  9446. SubTotal = x.SubTotal,
  9447. Remark = x.Remark
  9448. })
  9449. .ToList();
  9450. var updateList = dto.DayOtherPriceData
  9451. .Where(x => x.Id != 0)
  9452. .Select(x => new Grp_DayOtherPrice
  9453. {
  9454. Cost = x.Cost,
  9455. Id = x.Id,
  9456. CreateTime = DateTime.Now,
  9457. CreateUserId = dto.UserId,
  9458. Currency = x.Currency,
  9459. Diid = x.DiId,
  9460. Index = x.Index,
  9461. IsDel = 0,
  9462. SetDataId = x.SetDataId,
  9463. SubTotal = x.SubTotal,
  9464. Remark = x.Remark
  9465. })
  9466. .ToList();
  9467. //添加
  9468. _sqlSugar.BeginTran();
  9469. if (inserList.Any())
  9470. {
  9471. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  9472. }
  9473. if (updateList.Any())
  9474. {
  9475. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  9476. }
  9477. _sqlSugar.CommitTran();
  9478. }
  9479. if (data.Code != 0)
  9480. {
  9481. return Ok(JsonView(false, data.Msg));
  9482. }
  9483. //生成默认文件pdf并且通知人员
  9484. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9485. {
  9486. DiId = dto.DiId,
  9487. ExportType = 1,
  9488. SubTypeId = 1005
  9489. }, "pdf");
  9490. //发送通知
  9491. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9492. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9493. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  9494. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  9495. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9496. //汇率信息记录
  9497. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  9498. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  9499. //汇率验证、反推
  9500. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  9501. if (isSendMsg)
  9502. {
  9503. //消息推送
  9504. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  9505. }
  9506. #region 日志汇率记录
  9507. //按照已使用币种记录
  9508. if (checkCurrencys != null && checkCurrencys.Count > 0)
  9509. {
  9510. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  9511. //汇率记录中加入实时汇率
  9512. if (liveRates != null && liveRates.Count > 0)
  9513. {
  9514. foreach (var item in rateRecords)
  9515. {
  9516. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  9517. }
  9518. }
  9519. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  9520. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  9521. var logContent = new StringBuilder();
  9522. foreach (var item in rateRecords)
  9523. {
  9524. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  9525. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  9526. logContent.AppendLine(msg);
  9527. }
  9528. _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());
  9529. }
  9530. #endregion
  9531. return Ok(JsonView(true, data.Msg, data.Data));
  9532. }
  9533. catch (Exception ex)
  9534. {
  9535. return Ok(JsonView(false, ex.Message));
  9536. }
  9537. }
  9538. /// <summary>
  9539. /// 团组模块 - 出入境费用 - Confirm 费用
  9540. /// </summary>
  9541. /// <returns></returns>
  9542. [HttpPost]
  9543. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9544. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  9545. {
  9546. //TODO:测试完毕需把对应的用户ID更改
  9547. //1、数据表添加字段
  9548. //2、更改字段接口()
  9549. var _view = await _enterExitCostRep.ConfirmCost(dto);
  9550. //3、确认成功 给财务发送消息
  9551. if (_view.Code == 200)
  9552. {
  9553. if (dto.Type == 1)
  9554. {
  9555. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  9556. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  9557. }
  9558. }
  9559. return Ok(_view);
  9560. }
  9561. /// <summary>
  9562. /// 团组模块 - 出入境费用 - File download
  9563. /// </summary>
  9564. /// <param name="dto"></param>
  9565. /// <returns></returns>
  9566. [HttpPost]
  9567. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  9568. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9569. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  9570. {
  9571. try
  9572. {
  9573. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  9574. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  9575. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  9576. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  9577. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  9578. 3 团组成员名单 1 团组成员名单", ""));
  9579. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  9580. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9581. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  9582. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  9583. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  9584. //数据源
  9585. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  9586. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  9587. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  9588. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  9589. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9590. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  9591. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  9592. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  9593. .Select((x, a, b) => new
  9594. {
  9595. x.Index,
  9596. itemName = a.Name,
  9597. CurrencyStr = b.Name,
  9598. x.Cost,
  9599. x.SubTotal,
  9600. x.Remark
  9601. })
  9602. .OrderBy((x) => x.Index)
  9603. .ToList(); //其他款项费用
  9604. var peiceItemCurrencys = new List<string>();
  9605. if (_DayAndCosts.Any())
  9606. {
  9607. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  9608. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  9609. }
  9610. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  9611. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  9612. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  9613. {
  9614. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  9615. }
  9616. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9617. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  9618. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  9619. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  9620. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  9621. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  9622. .Select((tcl, dc, cc) => new ClientInfo
  9623. {
  9624. LastName = dc.LastName,
  9625. FirstName = dc.FirstName,
  9626. Sex = dc.Sex,
  9627. Birthday = dc.BirthDay,
  9628. Company = cc.CompanyFullName,
  9629. Job = dc.Job
  9630. })
  9631. .ToList();
  9632. foreach (var item in DeleClientList)
  9633. {
  9634. EncryptionProcessor.DecryptProperties(item);
  9635. }
  9636. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  9637. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  9638. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  9639. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  9640. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  9641. if (dto.ExportType == 1) //明细表
  9642. {
  9643. if (dto.SubTypeId == 1005) //1005(默认明细表)
  9644. {
  9645. //获取模板
  9646. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  9647. //载入模板
  9648. var doc = new Document(tempPath);
  9649. var builder = new DocumentBuilder(doc);
  9650. var dic = new Dictionary<string, string>();
  9651. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  9652. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  9653. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  9654. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  9655. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  9656. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  9657. //境内费用(其他费用)
  9658. if (_EnterExitCosts.ChoiceOne == 1)
  9659. {
  9660. string row1_1 = "";
  9661. if (_EnterExitCosts.Visa > 0)
  9662. {
  9663. //insidePayTotal += _EnterExitCosts.Visa;
  9664. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  9665. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  9666. //{
  9667. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  9668. //}
  9669. }
  9670. string row1_2 = "";
  9671. if (_EnterExitCosts.YiMiao > 0)
  9672. {
  9673. //insidePayTotal += _EnterExitCosts.YiMiao;
  9674. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  9675. }
  9676. if (_EnterExitCosts.HeSuan > 0)
  9677. {
  9678. //insidePayTotal += _EnterExitCosts.HeSuan;
  9679. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  9680. }
  9681. if (_EnterExitCosts.Service > 0)
  9682. {
  9683. //insidePayTotal += _EnterExitCosts.Service;
  9684. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  9685. }
  9686. string row1_3 = "";
  9687. if (_EnterExitCosts.Safe > 0)
  9688. {
  9689. //insidePayTotal += _EnterExitCosts.Safe;
  9690. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  9691. }
  9692. if (_EnterExitCosts.Ticket > 0)
  9693. {
  9694. //insidePayTotal += _EnterExitCosts.Ticket;
  9695. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  9696. }
  9697. string row1 = "";
  9698. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  9699. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  9700. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  9701. row1 += $"备注:{_EnterExitCosts.Remark}";
  9702. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  9703. dic.Add("Row1Str", row1);
  9704. }
  9705. var airTotalStr = new StringBuilder();
  9706. var airPriceStr = new StringBuilder();
  9707. var cityTrafficLabel = new StringBuilder();
  9708. //经济舱
  9709. if (_EnterExitCosts.SumJJC == 1)
  9710. {
  9711. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)");
  9712. airPriceStr.AppendFormat($"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)");
  9713. cityTrafficLabel.AppendFormat("经济舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic);
  9714. }
  9715. //公务舱
  9716. if (_EnterExitCosts.SumGWC == 1)
  9717. {
  9718. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)");
  9719. airPriceStr.AppendFormat($"{_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)");
  9720. cityTrafficLabel.AppendFormat("公务舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic1);
  9721. }
  9722. //头等舱
  9723. if (_EnterExitCosts.SumTDC == 1)
  9724. {
  9725. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)");
  9726. airPriceStr.AppendFormat($"{_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)");
  9727. cityTrafficLabel.AppendFormat("头等舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic2);
  9728. }
  9729. //描述
  9730. var remarkLable = new StringBuilder();
  9731. //第二项描述
  9732. remarkLable.Append("备注:");
  9733. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) remarkLable.AppendFormat(_EnterExitCosts.TwoItemRemark);
  9734. //汇率描述
  9735. if (peiceItemCurrencyInfos.Any())
  9736. {
  9737. remarkLable.AppendLine();
  9738. remarkLable.AppendFormat("汇率描述:");
  9739. foreach (var item in peiceItemCurrencyInfos)
  9740. {
  9741. remarkLable.AppendFormat($"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ");
  9742. }
  9743. }
  9744. dic.Add("AirTotalStr", airTotalStr.ToString());
  9745. dic.Add("AirPriceStr", airPriceStr.ToString());
  9746. dic.Add("CityTranffic", cityTrafficLabel.ToString());
  9747. dic.Add("TwoItemRemark", remarkLable.ToString());
  9748. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9749. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9750. int table1Row = 0,
  9751. table2Row = 0,
  9752. table3Row = 0,
  9753. table4Row = 0,
  9754. table5Row = 0;
  9755. //住宿费
  9756. if (_EnterExitCosts.ChoiceThree == 1)
  9757. {
  9758. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  9759. table1Row = dac1.Count;
  9760. #region 填充word表格内容
  9761. for (int i = 0; i < dac1.Count; i++)
  9762. {
  9763. Grp_DayAndCost dac = dac1[i];
  9764. if (dac == null) continue;
  9765. builder.MoveToCell(0, i, 0, 0);
  9766. builder.Write("第" + dac.Days.ToString() + "晚:");
  9767. builder.MoveToCell(0, i, 1, 0);
  9768. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  9769. //builder.Write(dac.Place == null ? "" : dac.Place);
  9770. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9771. builder.MoveToCell(0, i, 2, 0);
  9772. builder.Write("费用标准:");
  9773. string curr = "";
  9774. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9775. if (currData != null)
  9776. {
  9777. curr = currData.Name;
  9778. }
  9779. builder.MoveToCell(0, i, 3, 0);
  9780. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9781. builder.MoveToCell(0, i, 4, 0);
  9782. builder.Write("费用小计:");
  9783. builder.MoveToCell(0, i, 5, 0);
  9784. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9785. }
  9786. #endregion
  9787. }
  9788. else dic.Add("SubZS", "0.00");
  9789. //删除多余行
  9790. while (table1.Rows.Count > table1Row)
  9791. {
  9792. table1.Rows.RemoveAt(table1Row);
  9793. }
  9794. //伙食费
  9795. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  9796. if (_EnterExitCosts.ChoiceFour == 1)
  9797. {
  9798. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  9799. table2Row = dac2.Count;
  9800. #region 填充word表格内容
  9801. for (int i = 0; i < dac2.Count; i++)
  9802. {
  9803. Grp_DayAndCost dac = dac2[i];
  9804. if (dac == null) continue;
  9805. builder.MoveToCell(1, i, 0, 0);
  9806. builder.Write("第" + dac.Days.ToString() + "天:");
  9807. builder.MoveToCell(1, i, 1, 0);
  9808. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9809. builder.MoveToCell(1, i, 2, 0);
  9810. builder.Write("费用标准:");
  9811. string curr = "";
  9812. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9813. if (currData != null)
  9814. {
  9815. curr = currData.Name;
  9816. }
  9817. builder.MoveToCell(1, i, 3, 0);
  9818. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9819. builder.MoveToCell(1, i, 4, 0);
  9820. builder.Write("费用小计:");
  9821. builder.MoveToCell(1, i, 5, 0);
  9822. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9823. }
  9824. #endregion
  9825. }
  9826. else dic.Add("SubHS", "0.00");
  9827. //删除多余行
  9828. while (table2.Rows.Count > table2Row)
  9829. {
  9830. table2.Rows.RemoveAt(table2Row);
  9831. }
  9832. //公杂费
  9833. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  9834. if (_EnterExitCosts.ChoiceFive == 1)
  9835. {
  9836. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  9837. table3Row = dac3.Count;
  9838. #region 填充word表格内容
  9839. for (int i = 0; i < dac3.Count; i++)
  9840. {
  9841. Grp_DayAndCost dac = dac3[i];
  9842. if (dac == null) continue;
  9843. builder.MoveToCell(2, i, 0, 0);
  9844. builder.Write("第" + dac.Days.ToString() + "天:");
  9845. builder.MoveToCell(2, i, 1, 0);
  9846. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9847. builder.MoveToCell(2, i, 2, 0);
  9848. builder.Write("费用标准:");
  9849. string curr = "";
  9850. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9851. if (currData != null)
  9852. {
  9853. curr = currData.Name;
  9854. }
  9855. builder.MoveToCell(2, i, 3, 0);
  9856. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9857. builder.MoveToCell(2, i, 4, 0);
  9858. builder.Write("费用小计:");
  9859. builder.MoveToCell(2, i, 5, 0);
  9860. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9861. }
  9862. //删除多余行
  9863. while (table3.Rows.Count > table3Row)
  9864. {
  9865. table3.Rows.RemoveAt(table3Row);
  9866. }
  9867. #endregion
  9868. }
  9869. else dic.Add("SubGZF", "0.00");
  9870. //删除多余行
  9871. while (table3.Rows.Count > table3Row)
  9872. {
  9873. table3.Rows.RemoveAt(table3Row);
  9874. }
  9875. //培训费
  9876. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  9877. if (_EnterExitCosts.ChoiceSix == 1)
  9878. {
  9879. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  9880. dic.Add("SubPX", pxStr);
  9881. table4Row = dac4.Count;
  9882. #region 填充word表格内容
  9883. for (int i = 0; i < dac4.Count; i++)
  9884. {
  9885. Grp_DayAndCost dac = dac4[i];
  9886. if (dac == null) continue;
  9887. builder.MoveToCell(3, i, 0, 0);
  9888. builder.Write("第" + dac.Days.ToString() + "天:");
  9889. builder.MoveToCell(3, i, 1, 0);
  9890. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9891. builder.MoveToCell(3, i, 2, 0);
  9892. builder.Write("费用标准:");
  9893. string curr = "";
  9894. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9895. if (currData != null)
  9896. {
  9897. curr = currData.Name;
  9898. }
  9899. builder.MoveToCell(3, i, 3, 0);
  9900. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9901. builder.MoveToCell(3, i, 4, 0);
  9902. builder.Write("费用小计:");
  9903. builder.MoveToCell(3, i, 5, 0);
  9904. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9905. }
  9906. #endregion
  9907. }
  9908. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  9909. //删除多余行
  9910. while (table4.Rows.Count > table4Row)
  9911. {
  9912. table4.Rows.RemoveAt(table4Row);
  9913. }
  9914. //其他费用
  9915. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  9916. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  9917. {
  9918. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  9919. dic.Add("titleQi", qtStr);
  9920. table5Row = dac5.Count;
  9921. #region 填充word表格内容
  9922. for (int i = 0; i < dac5.Count; i++)
  9923. {
  9924. var dac = dac5[i];
  9925. if (dac == null) continue;
  9926. builder.MoveToCell(4, i, 0, 0);
  9927. builder.Write("第" + dac.Index.ToString() + "项:");
  9928. builder.MoveToCell(4, i, 1, 0);
  9929. builder.Write(dac.itemName);
  9930. builder.MoveToCell(4, i, 2, 0);
  9931. builder.Write("费用标准:");
  9932. builder.MoveToCell(4, i, 3, 0);
  9933. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  9934. builder.MoveToCell(4, i, 4, 0);
  9935. builder.Write("费用小计:");
  9936. builder.MoveToCell(4, i, 5, 0);
  9937. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9938. builder.MoveToCell(4, i, 6, 0);
  9939. builder.Write("备注:");
  9940. builder.MoveToCell(4, i, 7, 0);
  9941. builder.Write(dac.Remark);
  9942. }
  9943. #endregion
  9944. }
  9945. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  9946. //删除多余行
  9947. while (table5.Rows.Count > table5Row)
  9948. {
  9949. table5.Rows.RemoveAt(table5Row);
  9950. }
  9951. //加上其他费用
  9952. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  9953. decimal subJJC = 0.00M,
  9954. subGWC = 0.00M,
  9955. subTDC = 0.00M;
  9956. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  9957. string totalLabel = string.Format("全部费用总计:");
  9958. //经济舱
  9959. if (_EnterExitCosts.SumJJC == 1)
  9960. {
  9961. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  9962. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  9963. }
  9964. //公务舱
  9965. if (_EnterExitCosts.SumGWC == 1)
  9966. {
  9967. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  9968. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  9969. }
  9970. //头等舱
  9971. if (_EnterExitCosts.SumTDC == 1)
  9972. {
  9973. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  9974. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  9975. }
  9976. //TotalLabel
  9977. dic.Add("TotalLabel", totalLabel);
  9978. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  9979. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  9980. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  9981. #region 填充word模板书签内容
  9982. foreach (var key in dic.Keys)
  9983. {
  9984. Bookmark bookmark = doc.Range.Bookmarks[key];
  9985. if (bookmark != null)
  9986. {
  9987. builder.MoveToBookmark(key);
  9988. builder.Write(dic[key]);
  9989. }
  9990. }
  9991. #endregion
  9992. #region 设置页眉
  9993. string userLabel = string.Empty;
  9994. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  9995. if (currUserInfo != null)
  9996. {
  9997. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  9998. if (userInfo != null)
  9999. {
  10000. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  10001. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  10002. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  10003. }
  10004. }
  10005. //设置页脚
  10006. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  10007. #endregion
  10008. var guid = CommonFun.GUID.Substring(0, 8);
  10009. //文件名
  10010. string strFileName = CommonFun.ValidFileName($"{_DelegationInfo.TeamName}出入境费用{guid}.docx");
  10011. AsposeHelper.removewatermark_v2180();
  10012. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10013. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10014. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10015. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10016. }
  10017. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  10018. {
  10019. //获取模板
  10020. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  10021. //载入模板
  10022. var doc = new Document(tempPath);
  10023. var builder = new DocumentBuilder(doc);
  10024. var dic = new Dictionary<string, string>();
  10025. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  10026. {
  10027. var list = new List<string>();
  10028. try
  10029. {
  10030. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  10031. foreach (var item in spilitArr)
  10032. {
  10033. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  10034. var depCode = spDotandEmpty[2].Substring(0, 3);
  10035. var arrCode = spDotandEmpty[2].Substring(3, 3);
  10036. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  10037. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  10038. list.Add(depName);
  10039. list.Add(arrName);
  10040. }
  10041. list = list.Distinct().ToList();
  10042. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  10043. }
  10044. catch (Exception)
  10045. {
  10046. dic.Add("ReturnCode", "行程录入不正确!");
  10047. }
  10048. }
  10049. else
  10050. {
  10051. dic.Add("ReturnCode", "未录入行程!");
  10052. }
  10053. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  10054. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10055. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10056. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  10057. {
  10058. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10059. dic.Add("Day", sp.Days.ToString());
  10060. }
  10061. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10062. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  10063. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  10064. //dic.Add("Names", Names);
  10065. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10066. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10067. decimal dac1totalPrice = 0.00M;
  10068. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  10069. foreach (var dac in dac1)
  10070. {
  10071. if (dac.SubTotal == 0.00M)
  10072. {
  10073. continue;
  10074. }
  10075. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  10076. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  10077. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10078. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  10079. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  10080. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  10081. builder.Write(currency);//币种
  10082. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  10083. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10084. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  10085. builder.Write("");//人数
  10086. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  10087. builder.Write("");//天数
  10088. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  10089. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10090. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  10091. decimal rate = 0.00M;
  10092. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  10093. builder.Write(rate.ToString("#0.0000"));//汇率
  10094. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10095. decimal rbmPrice = dac.SubTotal;
  10096. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10097. accommodationStartIndex++;
  10098. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  10099. }
  10100. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10101. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  10102. {
  10103. table1.Rows.RemoveAt(i - 1);
  10104. foodandotherStartIndex--;
  10105. }
  10106. if (dac2.Count == dac3.Count)//国家 币种 金额
  10107. {
  10108. for (int i = 0; i < dac2.Count; i++)
  10109. {
  10110. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10111. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10112. }
  10113. }
  10114. decimal dac2totalPrice = 0.00M;
  10115. foreach (var dac in dac2)
  10116. {
  10117. if (dac.SubTotal == 0)
  10118. {
  10119. continue;
  10120. }
  10121. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  10122. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  10123. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  10124. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  10125. builder.Write(currency);//币种
  10126. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  10127. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10128. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  10129. builder.Write("");//人数
  10130. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  10131. builder.Write("");//天数
  10132. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  10133. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10134. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  10135. decimal rate = 0.00M;
  10136. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  10137. builder.Write(rate.ToString("#0.0000"));//汇率
  10138. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  10139. decimal rbmPrice = dac.SubTotal;
  10140. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10141. foodandotherStartIndex++;
  10142. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  10143. }
  10144. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  10145. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  10146. {
  10147. table1.Rows.RemoveAt(i - 1);
  10148. }
  10149. var cityTrafficLabel = new StringBuilder()
  10150. .AppendFormat(" 经济舱:{0:#0.00} 元", _EnterExitCosts.CityTranffic)
  10151. .AppendFormat(" 公务舱:{0:#0.00} 元", _EnterExitCosts.CityTranffic1)
  10152. .AppendFormat(" 头等舱:{0:#0.00} ", _EnterExitCosts.CityTranffic2)
  10153. .ToString();
  10154. dic.Add("CityTranffic", cityTrafficLabel);
  10155. string otherFeeStr = "";
  10156. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  10157. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  10158. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  10159. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  10160. foreach (var otherInfo in dac5)
  10161. {
  10162. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  10163. }
  10164. #endregion
  10165. if (otherFeeStr.Length > 0)
  10166. {
  10167. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  10168. otherFeeStr = $"({otherFeeStr})";
  10169. dic.Add("OtherFeeStr", otherFeeStr);
  10170. }
  10171. //总计
  10172. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  10173. //国际旅费
  10174. string outsideAir = string.Empty;
  10175. string allPriceAir = string.Empty;
  10176. if (_EnterExitCosts.SumJJC == 1)
  10177. {
  10178. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10179. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  10180. }
  10181. if (_EnterExitCosts.SumGWC == 1)
  10182. {
  10183. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  10184. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10185. }
  10186. if (_EnterExitCosts.SumTDC == 1)
  10187. {
  10188. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  10189. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  10190. }
  10191. dic.Add("InTravelPrice", $"({outsideAir})");
  10192. dic.Add("FinalSumPrice", $"({allPriceAir})");
  10193. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  10194. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  10195. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  10196. foreach (var key in dic.Keys)
  10197. {
  10198. builder.MoveToBookmark(key);
  10199. builder.Write(dic[key]);
  10200. }
  10201. //模板文件名
  10202. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10203. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10204. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10205. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10206. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10207. }
  10208. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  10209. {
  10210. //获取模板
  10211. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  10212. //载入模板
  10213. var designer = new WorkbookDesigner
  10214. {
  10215. Workbook = new Workbook(tempPath)
  10216. };
  10217. var dic = new Dictionary<string, string>();
  10218. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  10219. {
  10220. var list = new List<string>();
  10221. try
  10222. {
  10223. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  10224. foreach (var item in spilitArr)
  10225. {
  10226. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  10227. var depCode = spDotandEmpty[2].Substring(0, 3);
  10228. var arrCode = spDotandEmpty[2].Substring(3, 3);
  10229. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  10230. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  10231. list.Add(depName);
  10232. list.Add(arrName);
  10233. }
  10234. list = list.Distinct().ToList();
  10235. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  10236. }
  10237. catch (Exception)
  10238. {
  10239. dic.Add("ReturnCode", "行程录入不正确!");
  10240. }
  10241. }
  10242. else
  10243. {
  10244. dic.Add("ReturnCode", "未录入行程!");
  10245. }
  10246. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  10247. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10248. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10249. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  10250. {
  10251. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10252. dic.Add("Day", sp.Days.ToString());
  10253. }
  10254. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10255. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  10256. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  10257. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  10258. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  10259. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  10260. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  10261. designer.SetDataSource("Name", Names);
  10262. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  10263. designer.SetDataSource("Day", dic["Day"] + "天");
  10264. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  10265. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  10266. int startIndex = 10;
  10267. const int startIndexcopy = 10;
  10268. if (dac2.Count == dac3.Count)//国家 币种 金额
  10269. {
  10270. for (int i = 0; i < dac2.Count; i++)
  10271. {
  10272. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10273. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10274. }
  10275. }
  10276. var dtdac1 = new DataTable();
  10277. var place = new List<string>();
  10278. dtdac1.Columns.AddRange(new DataColumn[] {
  10279. new(){ ColumnName = "city"},
  10280. new(){ ColumnName = "curr"},
  10281. new(){ ColumnName = "criterion"},
  10282. new(){ ColumnName = "number",DataType = typeof(int)},
  10283. new(){ ColumnName = "day",DataType = typeof(int)},
  10284. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  10285. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  10286. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  10287. });
  10288. var dtdac2 = new DataTable();
  10289. dtdac2.Columns.AddRange(new DataColumn[] {
  10290. new(){ ColumnName = "city"},
  10291. new(){ ColumnName = "curr"},
  10292. new(){ ColumnName = "criterion"},
  10293. new(){ ColumnName = "number",DataType = typeof(int)},
  10294. new(){ ColumnName = "day",DataType = typeof(int)},
  10295. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  10296. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  10297. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  10298. });
  10299. dtdac1.TableName = "tb1";
  10300. dtdac2.TableName = "tb2";
  10301. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  10302. foreach (var item in dac1)
  10303. {
  10304. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  10305. if (place.Contains(item.Place))
  10306. {
  10307. continue;
  10308. }
  10309. DataRow row = dtdac1.NewRow();
  10310. row["city"] = item.Place;
  10311. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10312. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10313. row["curr"] = currency;
  10314. row["rate"] = rate.ToString("#0.0000");
  10315. row["criterion"] = item.Cost.ToString("#0.00");
  10316. row["number"] = 1;
  10317. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10318. //row["costRMB"] = rbmPrice;
  10319. dtdac1.Rows.Add(row);
  10320. place.Add(item.Place);
  10321. }
  10322. place = new List<string>();
  10323. foreach (var item in dac2)
  10324. {
  10325. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  10326. if (place.Contains(item.Place))
  10327. {
  10328. continue;
  10329. }
  10330. DataRow row = dtdac2.NewRow();
  10331. row["city"] = item.Place;
  10332. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10333. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10334. row["curr"] = currency;
  10335. row["rate"] = rate.ToString("#0.0000");
  10336. row["criterion"] = item.Cost.ToString("#0.00");
  10337. row["number"] = 1;
  10338. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10339. //row["cost"] = item.SubTotal;
  10340. //row["costRMB"] = rbmPrice;
  10341. dtdac2.Rows.Add(row);
  10342. place.Add(item.Place);
  10343. //dac2totalPrice += rbmPrice;
  10344. }
  10345. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  10346. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  10347. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10348. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  10349. var cityTrafficLabel = new StringBuilder()
  10350. .AppendFormat(" 其中:国外城市间")
  10351. .AppendFormat(" 经济舱费:{0:#0.00} 元、", _EnterExitCosts.CityTranffic)
  10352. .AppendFormat(" 公务舱费:{0:#0.00} 元、", _EnterExitCosts.CityTranffic1)
  10353. .AppendFormat(" 头等舱费:{0:#0.00} 元", _EnterExitCosts.CityTranffic2)
  10354. .ToString();
  10355. //decimal cityTraffic =_EnterExitCosts.CityTranffic + _EnterExitCosts.CityTranffic1 + _EnterExitCosts.CityTranffic2;
  10356. designer.SetDataSource("cityTranffic", cityTrafficLabel);
  10357. // designer.SetDataSource("sumCityTranffic", @$"{cityTraffic:#0.00} ");
  10358. string cell4Str1 = string.Empty;
  10359. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  10360. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  10361. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  10362. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  10363. string cellStr = $" 5.其他费用(";
  10364. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  10365. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  10366. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  10367. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  10368. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  10369. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  10370. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  10371. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  10372. foreach (var otherInfo in dac5)
  10373. {
  10374. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  10375. }
  10376. #endregion
  10377. if (cellStr.Length > 8)
  10378. {
  10379. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  10380. }
  10381. cellStr += ")";
  10382. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  10383. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  10384. decimal pxFee = dac4.Sum(it => it.Cost);
  10385. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  10386. string celllastStr1 = "";
  10387. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  10388. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  10389. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  10390. celllastStr1 += $",国际旅费 元";
  10391. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  10392. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  10393. designer.SetDataSource("cell4Str", cell4Str);
  10394. designer.SetDataSource("cellStr", cellStr);
  10395. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  10396. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10397. designer.SetDataSource("celllastStr", celllastStr);
  10398. Workbook wb = designer.Workbook;
  10399. var sheet = wb.Worksheets[0];
  10400. //绑定datatable数据集
  10401. designer.SetDataSource(dtdac1);
  10402. designer.SetDataSource(dtdac2);
  10403. designer.Process();
  10404. var rowStart = dtdac1.Rows.Count;
  10405. while (rowStart > 0)
  10406. {
  10407. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  10408. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10409. startIndex++;
  10410. rowStart--;
  10411. }
  10412. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  10413. startIndex += 1; //总计行
  10414. rowStart = dtdac2.Rows.Count;
  10415. while (rowStart > 0)
  10416. {
  10417. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  10418. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10419. startIndex++;
  10420. rowStart--;
  10421. }
  10422. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  10423. wb.CalculateFormula(true);
  10424. //模板文件名
  10425. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10426. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10427. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10428. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10429. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10430. }
  10431. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  10432. {
  10433. //获取模板
  10434. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  10435. //载入模板
  10436. var doc = new Document(tempPath);
  10437. var builder = new DocumentBuilder(doc);
  10438. var dic = new Dictionary<string, string>
  10439. {
  10440. { "GroupName", _DelegationInfo.TeamName },
  10441. { "ClientUnit", _DelegationInfo.ClientUnit }
  10442. };
  10443. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  10444. string missionLeaderJob = "";//负责人job
  10445. //int groupNumber = 0; //团人数
  10446. if (DeleClientList.Count > 0)
  10447. {
  10448. missionLeader = DeleClientList[0]?.Name ?? "";
  10449. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  10450. }
  10451. dic.Add("MissionLeader", missionLeader); //团负责人
  10452. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  10453. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  10454. #region MyRegion
  10455. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  10456. //{
  10457. // List<string> list = new List<string>();
  10458. // try
  10459. // {
  10460. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  10461. // foreach (var item in spilitArr)
  10462. // {
  10463. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  10464. // var depCode = spDotandEmpty[2].Substring(0, 3);
  10465. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  10466. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  10467. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  10468. // list.Add(depName);
  10469. // list.Add(arrName);
  10470. // }
  10471. // list = list.Distinct().ToList();
  10472. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  10473. // }
  10474. // catch (Exception)
  10475. // {
  10476. // dic.Add("ReturnCode", "行程录入不正确!");
  10477. // }
  10478. //}
  10479. //else
  10480. //{
  10481. // dic.Add("ReturnCode", "未录入行程!");
  10482. //}
  10483. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  10484. dic.Add("ReturnCode", string.Join("、", countrys));
  10485. #endregion
  10486. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  10487. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10488. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10489. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  10490. //{
  10491. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10492. // dic.Add("Day", sp.Days.ToString());
  10493. //}
  10494. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  10495. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  10496. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10497. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10498. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10499. //培训人员名单
  10500. int cultivateRowIndex = 7;
  10501. foreach (var item in DeleClientList)
  10502. {
  10503. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  10504. builder.Write(item.Name);
  10505. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  10506. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  10507. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  10508. string birthDay = "";
  10509. if (item.Birthday != null)
  10510. {
  10511. DateTime dt = Convert.ToDateTime(item.Birthday);
  10512. birthDay = $"{dt.Year}.{dt.Month}";
  10513. }
  10514. builder.Write(birthDay);
  10515. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  10516. builder.Write(item.Company);
  10517. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  10518. builder.Write(item.Job);
  10519. cultivateRowIndex++;
  10520. }
  10521. //删除多余行
  10522. //cultivateRowIndex -= 2;
  10523. int delRows = 10 + 7 - cultivateRowIndex;
  10524. if (delRows > 0)
  10525. {
  10526. for (int i = 0; i < delRows; i++)
  10527. {
  10528. table1.Rows.RemoveAt(cultivateRowIndex);
  10529. //cultivateRowIndex++;
  10530. }
  10531. }
  10532. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  10533. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  10534. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  10535. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  10536. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  10537. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  10538. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  10539. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  10540. //decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  10541. decimal cityTranfficFeeToatal = 0.00M;
  10542. //dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));
  10543. //其他费用
  10544. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  10545. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  10546. //其他费用合计
  10547. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  10548. decimal _jjcFeeToatal = _EnterExitCosts.OutsideJJPay + _otherFeeTotal; //经济舱
  10549. decimal _gwcFeeToatal = _EnterExitCosts.OutsideGWPay + _otherFeeTotal; //公务舱
  10550. //公务舱合计
  10551. //国际旅费
  10552. //string outsideJJ = "";
  10553. //string allPriceJJ = "";
  10554. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  10555. {
  10556. dic.Add("AirFeeTotal", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  10557. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  10558. }
  10559. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  10560. {
  10561. dic.Add("AirFeeTotal", _EnterExitCosts.OutsideGWPay.ToString("#0.00"));
  10562. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  10563. }
  10564. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  10565. {
  10566. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.OutsideJJPay:#0.00} 公务舱:{_EnterExitCosts.OutsideGWPay:#0.00}");
  10567. dic.Add("AirFeeTotal", airFeeTotalStr);
  10568. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  10569. dic.Add("FeeTotal", feeTotalStr);
  10570. }
  10571. foreach (var key in dic.Keys)
  10572. {
  10573. builder.MoveToBookmark(key);
  10574. builder.Write(dic[key]);
  10575. }
  10576. //模板文件名
  10577. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  10578. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10579. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10580. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10581. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10582. }
  10583. }
  10584. else if (dto.ExportType == 2) //表格
  10585. {
  10586. //利用键值对存放数据
  10587. Dictionary<string, string> dic = new Dictionary<string, string>();
  10588. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10589. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10590. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10591. dic.Add("Day", sp.Days.ToString());
  10592. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10593. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  10594. {
  10595. //获取模板
  10596. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  10597. //载入模板
  10598. var doc = new Document(tempPath);
  10599. var builder = new DocumentBuilder(doc);
  10600. dic.Add("TeamName", _DelegationInfo.TeamName);
  10601. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  10602. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  10603. string missionLeaderName = "",
  10604. missionLeaderJob = "";
  10605. if (DeleClientList.Count > 0)
  10606. {
  10607. missionLeaderName = DeleClientList[0].Name;
  10608. missionLeaderJob = DeleClientList[0].Job;
  10609. }
  10610. dic.Add("MissionLeaderName", missionLeaderName);
  10611. dic.Add("MissionLeaderJob", missionLeaderJob);
  10612. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  10613. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  10614. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10615. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10616. int rowCount = 10;//总人数行
  10617. int startRowIndex = 7; //起始行
  10618. for (int i = 0; i < DeleClientList.Count; i++)
  10619. {
  10620. builder.MoveToCell(0, startRowIndex, 0, 0);
  10621. builder.Write(DeleClientList[i].Name); //出国人员姓名
  10622. builder.MoveToCell(0, startRowIndex, 1, 0);
  10623. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  10624. builder.Write(sex);//性别
  10625. builder.MoveToCell(0, startRowIndex, 2, 0);
  10626. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  10627. builder.MoveToCell(0, startRowIndex, 3, 0);
  10628. builder.Write(DeleClientList[i].Company);//工作单位
  10629. builder.MoveToCell(0, startRowIndex, 4, 0);
  10630. builder.Write(DeleClientList[i].Job);//职务及级别
  10631. builder.MoveToCell(0, startRowIndex, 5, 0);
  10632. builder.Write("");//人员属性
  10633. builder.MoveToCell(0, startRowIndex, 6, 0);
  10634. builder.Write("");//上次出国时间
  10635. startRowIndex++;
  10636. }
  10637. int nullRow = rowCount - DeleClientList.Count;//空行
  10638. for (int i = 0; i < nullRow; i++)
  10639. {
  10640. table1.Rows.Remove(table1.Rows[startRowIndex]);
  10641. }
  10642. foreach (var key in dic.Keys)
  10643. {
  10644. builder.MoveToBookmark(key);
  10645. builder.Write(dic[key]);
  10646. }
  10647. //模板文件名
  10648. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  10649. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10650. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10651. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  10652. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  10653. }
  10654. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  10655. {
  10656. //获取模板
  10657. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  10658. //载入模板
  10659. var doc = new Document(tempPath);
  10660. var builder = new DocumentBuilder(doc);
  10661. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  10662. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  10663. dic.Add("Names", Names);
  10664. int accommodationRows = 12;
  10665. //int foodandotherRows = 12;
  10666. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  10667. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  10668. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10669. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10670. int accommodationStartIndex = 6;
  10671. decimal dac1totalPrice = 0.00M;
  10672. foreach (var dac in dac1)
  10673. {
  10674. if (dac.SubTotal == 0)
  10675. {
  10676. continue;
  10677. }
  10678. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  10679. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  10680. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10681. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  10682. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  10683. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  10684. builder.Write(currency);//币种
  10685. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  10686. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10687. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  10688. builder.Write("");//人数
  10689. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  10690. builder.Write("");//天数
  10691. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  10692. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10693. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  10694. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10695. builder.Write(rate.ToString("#0.0000"));//汇率
  10696. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10697. decimal rbmPrice = rate * dac.SubTotal;
  10698. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10699. accommodationStartIndex++;
  10700. dac1totalPrice += rbmPrice;
  10701. }
  10702. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10703. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10704. builder.Write("小计");
  10705. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10706. builder.Write(dac1totalPrice.ToString("#0.00"));
  10707. accommodationStartIndex++;
  10708. int nullRow = accommodationRows - dac1.Count;
  10709. //删除空行
  10710. //if (nullRow > 0)
  10711. //{
  10712. // int rowIndex = accommodationStartIndex;
  10713. // for (int i = 0; i < nullRow; i++)
  10714. // {
  10715. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  10716. // row.Remove();
  10717. // rowIndex++;
  10718. // }
  10719. //}
  10720. if (dac2.Count == dac3.Count)//国家 币种 金额
  10721. {
  10722. for (int i = 0; i < dac2.Count; i++)
  10723. {
  10724. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10725. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10726. }
  10727. }
  10728. int foodandotherStartIndex = 19;//
  10729. decimal dac2totalPrice = 0.00M;
  10730. foreach (var dac in dac2)
  10731. {
  10732. if (dac.SubTotal == 0)
  10733. {
  10734. continue;
  10735. }
  10736. //foodandotherStartIndex = 12;
  10737. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  10738. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  10739. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  10740. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  10741. builder.Write(currency);//币种
  10742. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  10743. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10744. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  10745. builder.Write("");//人数
  10746. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  10747. builder.Write("");//天数
  10748. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  10749. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10750. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  10751. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10752. builder.Write(rate.ToString("#0.0000"));//汇率
  10753. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  10754. decimal rbmPrice = rate * dac.SubTotal;
  10755. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10756. foodandotherStartIndex++;
  10757. dac2totalPrice += rbmPrice;
  10758. }
  10759. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  10760. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  10761. //删除空行
  10762. //if (dac2.Count < foodandotherRows)
  10763. //{
  10764. // while (table2.Rows.Count > dac2.Count)
  10765. // {
  10766. // table2.Rows.RemoveAt(dac2.Count);
  10767. // }
  10768. //}
  10769. var citytrafficLable = new StringBuilder()
  10770. .AppendFormat($"经济舱费用:{_EnterExitCosts.CityTranffic:#0.00} 元、")
  10771. .AppendFormat($"公务舱费用:{_EnterExitCosts.CityTranffic1:#0.00}元、")
  10772. .AppendFormat($"头等舱费用:{_EnterExitCosts.CityTranffic2:#0.00}")
  10773. .ToString();
  10774. dic.Add("CityTranffic", citytrafficLable);
  10775. string otherFeeStr = "";
  10776. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  10777. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  10778. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  10779. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  10780. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  10781. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  10782. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  10783. foreach (var otherInfo in dac5)
  10784. {
  10785. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  10786. }
  10787. #endregion
  10788. if (otherFeeStr.Length > 0)
  10789. {
  10790. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  10791. otherFeeStr = $"({otherFeeStr})";
  10792. dic.Add("OtherFeeStr", otherFeeStr);
  10793. }
  10794. foreach (var key in dic.Keys)
  10795. {
  10796. builder.MoveToBookmark(key);
  10797. builder.Write(dic[key]);
  10798. }
  10799. //模板文件名
  10800. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10801. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10802. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10803. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10804. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10805. }
  10806. }
  10807. else if (dto.ExportType == 3)
  10808. {
  10809. if (dto.SubTypeId == 1) //团组成员名单
  10810. {
  10811. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  10812. //获取模板
  10813. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  10814. //载入模板
  10815. var doc = new Document(tempPath);
  10816. var builder = new DocumentBuilder(doc);
  10817. //获取word里所有表格
  10818. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10819. //获取所填表格的序数
  10820. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10821. var rowStart = tableOne.Rows[0]; //获取第1行
  10822. //循环赋值
  10823. for (int i = 0; i < DeleClientList.Count; i++)
  10824. {
  10825. builder.MoveToCell(0, i + 1, 0, 0);
  10826. builder.Write(DeleClientList[i].Name);
  10827. builder.MoveToCell(0, i + 1, 1, 0);
  10828. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  10829. builder.Write(sex);
  10830. builder.MoveToCell(0, i + 1, 2, 0);
  10831. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  10832. builder.MoveToCell(0, i + 1, 3, 0);
  10833. builder.Write(DeleClientList[i].Company);
  10834. builder.MoveToCell(0, i + 1, 4, 0);
  10835. builder.Write(DeleClientList[i].Job);
  10836. }
  10837. //删除多余行
  10838. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  10839. {
  10840. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  10841. }
  10842. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  10843. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  10844. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  10845. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10846. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10847. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10848. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10849. }
  10850. }
  10851. return Ok(JsonView(400, "操作失败!", ""));
  10852. }
  10853. catch (Exception ex)
  10854. {
  10855. return Ok(JsonView(400, ex.Message, ""));
  10856. }
  10857. }
  10858. /// <summary>
  10859. /// 获取三公费用标准city
  10860. /// </summary>
  10861. /// <param name="placeData"></param>
  10862. /// <param name="nationalTravelFeeId"></param>
  10863. /// <returns></returns>
  10864. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  10865. {
  10866. string _city = string.Empty;
  10867. if (placeData.Count < 1) return _city;
  10868. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  10869. if (data == null) return _city;
  10870. string country = data.Country;
  10871. string city = data.City;
  10872. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  10873. else _city = city;
  10874. return _city;
  10875. }
  10876. ///// <summary>
  10877. ///// 团组模块 - 出入境费用 - 明细表导出
  10878. ///// </summary>
  10879. ///// <returns></returns>
  10880. //[HttpPost]
  10881. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10882. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  10883. //{
  10884. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  10885. // if (data.Code != 0)
  10886. // {
  10887. // return Ok(JsonView(false, data.Msg));
  10888. // }
  10889. // return Ok(JsonView(true, data.Msg, data.Data));
  10890. //}
  10891. /// <summary>
  10892. /// 团组模块 - 出入境费用 - 一键清空
  10893. /// </summary>
  10894. /// <returns></returns>
  10895. [HttpPost]
  10896. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  10897. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10898. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  10899. {
  10900. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  10901. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  10902. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  10903. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  10904. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  10905. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  10906. .SetColumns(x => new Grp_DayOtherPrice
  10907. {
  10908. IsDel = 1,
  10909. DeleteUserId = dto.UserId,
  10910. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10911. })
  10912. .ExecuteCommandAsync();
  10913. if (_view.Code == 0)
  10914. {
  10915. return Ok(JsonView(true, "操作成功"));
  10916. }
  10917. return Ok(JsonView(false, "操作失败"));
  10918. }
  10919. /// <summary>
  10920. /// 团组模块 - 出入境费用 - 子项删除
  10921. /// </summary>
  10922. /// <returns></returns>
  10923. [HttpPost]
  10924. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  10925. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10926. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  10927. {
  10928. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10929. if (data.Code != 0)
  10930. {
  10931. return Ok(JsonView(false, data.Msg));
  10932. }
  10933. return Ok(JsonView(true, "操作成功!", data.Data));
  10934. }
  10935. /// <summary>
  10936. /// 删除三公其他费用
  10937. /// </summary>
  10938. /// <param name="dto"></param>
  10939. /// <returns></returns>
  10940. [HttpPost]
  10941. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  10942. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  10943. {
  10944. var jw = JsonView(false, "删除失败!");
  10945. var data = new Grp_DayOtherPrice()
  10946. {
  10947. Id = dto.Id,
  10948. IsDel = 1,
  10949. DeleteUserId = dto.DeleteUserId,
  10950. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  10951. };
  10952. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  10953. if (del > 0)
  10954. {
  10955. jw.Code = 200;
  10956. jw.Msg = "删除成功!";
  10957. }
  10958. return Ok(jw);
  10959. }
  10960. /// <summary>
  10961. /// 团组模块 - 出入境国家费用标准 List
  10962. /// </summary>
  10963. /// <returns></returns>
  10964. [HttpPost]
  10965. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10966. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  10967. {
  10968. int provinceId = dto.ProvinceId;
  10969. if (provinceId < 1) provinceId = 122; //默认四川省数据
  10970. var nftData = await _sqlSugar
  10971. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  10972. JoinType.Left, ntf.Currency == sd1.Id,
  10973. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  10974. JoinType.Left, ntf.ProvinceId == c.Id
  10975. ))
  10976. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  10977. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  10978. {
  10979. Id = ntf.Id,
  10980. ProvinceId = ntf.ProvinceId,
  10981. ProvinceName = c.Name_CN,
  10982. Continent = ntf.Continent,
  10983. Country = ntf.Country,
  10984. City = ntf.City,
  10985. Currency = ntf.Currency,
  10986. CurrencyCode = sd1.Name,
  10987. CurrencyName = sd1.Remark,
  10988. RoomCost = ntf.RoomCost,
  10989. FoodCost = ntf.FoodCost,
  10990. PublicCost = ntf.PublicCost,
  10991. LastUpdateUserId = ntf.LastUpdateUserId,
  10992. LastUpdateUserName = u.CnName,
  10993. LastUpdateTime = ntf.LastUpdateTime
  10994. })
  10995. .ToListAsync();
  10996. return Ok(JsonView(true, "查询成功!", nftData));
  10997. }
  10998. /// <summary>
  10999. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  11000. /// </summary>
  11001. /// <returns></returns>
  11002. [HttpPost]
  11003. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11004. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  11005. {
  11006. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  11007. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  11008. List<string> countryData = new List<string>();
  11009. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  11010. countryData = countryData.Distinct().ToList();
  11011. List<dynamic> dataSource = new List<dynamic>();
  11012. foreach (var item in countryData)
  11013. {
  11014. var cityData1 = new List<string>();
  11015. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  11016. var countryData2 = new
  11017. {
  11018. CountryName = item,
  11019. CityData = cityData1
  11020. };
  11021. if (!dataSource.Contains(countryData2))
  11022. {
  11023. dataSource.Add(countryData2);
  11024. }
  11025. }
  11026. return Ok(JsonView(true, "查询成功!", dataSource));
  11027. }
  11028. /// <summary>
  11029. /// 团组模块 - 出入境国家费用标准 Page List
  11030. /// </summary>
  11031. /// <returns></returns>
  11032. [HttpPost]
  11033. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11034. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  11035. {
  11036. int portId = dto.PortType,
  11037. pageIndex = dto.PageIndex,
  11038. pageSize = dto.PageSize;
  11039. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  11040. if (pageIndex == 0) pageIndex = 1;
  11041. if (pageSize == 0) pageSize = 10;
  11042. RefAsync<int> total = 0;
  11043. var nationalTravelFeeData = await _sqlSugar
  11044. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  11045. JoinType.Left, ntf.Currency == sd1.Id,
  11046. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  11047. JoinType.Left, ntf.ProvinceId == sd2.Id
  11048. ))
  11049. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  11050. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  11051. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  11052. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  11053. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  11054. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  11055. {
  11056. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  11057. Id = ntf.Id,
  11058. ProvinceId = ntf.ProvinceId,
  11059. ProvinceName = sd2.Name_CN,
  11060. Continent = ntf.Continent,
  11061. Country = ntf.Country,
  11062. City = ntf.City,
  11063. Currency = ntf.Currency,
  11064. CurrencyCode = sd1.Name,
  11065. CurrencyName = sd1.Remark,
  11066. RoomCost = ntf.RoomCost,
  11067. FoodCost = ntf.FoodCost,
  11068. PublicCost = ntf.PublicCost,
  11069. LastUpdateUserId = ntf.LastUpdateUserId,
  11070. LastUpdateUserName = u.CnName,
  11071. LastUpdateTime = ntf.LastUpdateTime,
  11072. Remark = ntf.Remark
  11073. })
  11074. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11075. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  11076. }
  11077. /// <summary>
  11078. /// 团组模块 - 出入境国家费用标准 根据城市查询
  11079. /// </summary>
  11080. /// <returns></returns>
  11081. [HttpPost]
  11082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11083. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  11084. {
  11085. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  11086. int portId = dto.PortType;
  11087. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  11088. string whereSql = string.Empty;
  11089. if (!string.IsNullOrEmpty(dto.Country))
  11090. {
  11091. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  11092. }
  11093. if (!string.IsNullOrEmpty(dto.City))
  11094. {
  11095. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  11096. }
  11097. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  11098. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  11099. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  11100. From Grp_NationalTravelFee gntf
  11101. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  11102. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  11103. Where gntf.Isdel = 0 {0} ", whereSql);
  11104. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  11105. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  11106. }
  11107. /// <summary>
  11108. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  11109. /// </summary>
  11110. /// <returns></returns>
  11111. [HttpPost]
  11112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11113. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  11114. {
  11115. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  11116. }
  11117. /// <summary>
  11118. /// 团组模块 - 出入境国家费用标准 - Del
  11119. /// </summary>
  11120. /// <returns></returns>
  11121. [HttpPost]
  11122. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11123. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  11124. {
  11125. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  11126. {
  11127. Id = dto.Id,
  11128. DeleteUserId = dto.DeleteUserId,
  11129. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11130. IsDel = 1
  11131. };
  11132. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  11133. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  11134. .WhereColumns(it => new { it.Id })
  11135. .ExecuteCommandAsync();
  11136. if (delStatus <= 0)
  11137. {
  11138. return Ok(JsonView(false, "删除失败!"));
  11139. }
  11140. return Ok(JsonView(true, "操作成功!"));
  11141. }
  11142. /// <summary>
  11143. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  11144. /// 注:Get 请求Headers 加 Token
  11145. /// </summary>
  11146. /// <param name="groupId"></param>
  11147. /// <returns></returns>
  11148. [HttpGet("{groupId}")]
  11149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11150. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  11151. {
  11152. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  11153. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  11154. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  11155. data.ForEach(x =>
  11156. {
  11157. x.CreateUserId = _currUserInfo.UserId;
  11158. });
  11159. if (data.Any())
  11160. {
  11161. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  11162. if (add > 0)
  11163. {
  11164. return Ok(JsonView(true, "操作成功!"));
  11165. }
  11166. }
  11167. return Ok(JsonView(false, "未操作!"));
  11168. }
  11169. #endregion
  11170. #region 团组经理模块 出入境费用-草稿
  11171. /// <summary>
  11172. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  11173. /// </summary>
  11174. /// <returns></returns>
  11175. [HttpGet]
  11176. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11177. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  11178. {
  11179. var provData = await _groupRepository.ProvinceBasicSource();
  11180. return Ok(JsonView(true, "查询成功!", provData));
  11181. }
  11182. /// <summary>
  11183. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  11184. /// </summary>
  11185. /// <returns></returns>
  11186. [HttpGet("{provinceId}")]
  11187. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11188. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  11189. {
  11190. //验证城市归属并给默认值
  11191. if (provinceId < 1) provinceId = 122;
  11192. /*
  11193. * 122 四川
  11194. * 108 贵州
  11195. * 103 重庆
  11196. * 132 云南
  11197. */
  11198. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  11199. return Ok(JsonView(true, "查询成功!", new
  11200. {
  11201. WordTypeData = wordTypeData,
  11202. ExcelTypeData = excelTypeData,
  11203. }));
  11204. }
  11205. /// <summary>
  11206. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  11207. /// </summary>
  11208. /// <returns></returns>
  11209. [HttpPost]
  11210. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11211. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  11212. {
  11213. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11214. .Where(x => x.IsDel == 0)
  11215. .OrderByDescending(x => x.CreateTime)
  11216. .Select(x => new { x.Id, x.DraftName })
  11217. .ToListAsync();
  11218. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  11219. //SetDataInfoView
  11220. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11221. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  11222. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  11223. int provinceId = dto.ProvinceId;
  11224. if (provinceId < 1) provinceId = 122;
  11225. /*
  11226. * 122 四川
  11227. * 108 贵州
  11228. * 103 重庆
  11229. * 132 云南
  11230. */
  11231. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  11232. //默认币种显示
  11233. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  11234. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11235. return Ok(JsonView(true, "查询成功!", new
  11236. {
  11237. DraftNameDatas = draftNameDatas,
  11238. CurrencyData = _CurrencyData,
  11239. WordTypeData = wordTypeData,
  11240. ExcelTypeData = excelTypeData,
  11241. CurrencyInit = _currencyInfos,
  11242. ViewPermissionData = viewPermissionData
  11243. }));
  11244. }
  11245. /// <summary>
  11246. /// 团组模块 - 出入境费用-草稿
  11247. /// 实时汇率 tips
  11248. /// 机票费用 tips
  11249. /// </summary>
  11250. /// <returns></returns>
  11251. [HttpPost]
  11252. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11253. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  11254. {
  11255. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  11256. return Ok(JsonView(true, "查询成功!", new
  11257. {
  11258. //GroupNameData = groupNameData.Data,
  11259. //visaData = visaData.Data,
  11260. //airData = airData.Data,
  11261. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  11262. }));
  11263. }
  11264. /// <summary>
  11265. /// 团组模块 - 出入境费用-草稿
  11266. /// 签证费用 tips
  11267. /// </summary>
  11268. /// <returns></returns>
  11269. [HttpPost]
  11270. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11271. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  11272. {
  11273. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  11274. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11275. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11276. .Select(x => x.NationalTravelFeeId)
  11277. .Distinct()
  11278. .ToListAsync();
  11279. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11280. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11281. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11282. .Select(x => x.Country)
  11283. .Distinct()
  11284. .ToArrayAsync();
  11285. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11286. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11287. return Ok(JsonView(true, "查询成功!", new
  11288. {
  11289. totalAmt,
  11290. remark
  11291. }));
  11292. }
  11293. /// <summary>
  11294. /// 团组模块 - 出入境费用-草稿 - Info
  11295. /// </summary>
  11296. /// <returns></returns>
  11297. [HttpPost]
  11298. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  11299. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11300. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  11301. {
  11302. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  11303. }
  11304. /// <summary>
  11305. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  11306. /// </summary>
  11307. /// <returns></returns>
  11308. [HttpPost]
  11309. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11310. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  11311. {
  11312. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11313. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  11314. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11315. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  11316. foreach (var userId in dto.UserIds)
  11317. {
  11318. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11319. }
  11320. if (permissions.Any())
  11321. {
  11322. _sqlSugar.BeginTran();
  11323. try
  11324. {
  11325. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11326. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11327. if (result < 1)
  11328. {
  11329. _sqlSugar.RollbackTran();
  11330. return Ok(JsonView(false));
  11331. }
  11332. }
  11333. catch (Exception ex)
  11334. {
  11335. _sqlSugar.RollbackTran();
  11336. return Ok(JsonView(false, ex.Message));
  11337. }
  11338. _sqlSugar.CommitTran();
  11339. return Ok(JsonView(true));
  11340. }
  11341. return Ok(JsonView(false));
  11342. }
  11343. /// <summary>
  11344. /// 团组模块 - 出入境费用-草稿 - Add And Update
  11345. /// </summary>
  11346. /// <returns></returns>
  11347. [HttpPost]
  11348. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  11349. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11350. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  11351. {
  11352. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  11353. if (data.Code != 0)
  11354. {
  11355. return Ok(JsonView(false, data.Msg));
  11356. }
  11357. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  11358. //汇率信息记录
  11359. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  11360. return Ok(JsonView(true, data.Msg, data.Data));
  11361. }
  11362. /// <summary>
  11363. /// 团组模块 - 出入境费用-草稿 - File downlaod
  11364. /// </summary>
  11365. /// <param name="dto"></param>
  11366. /// <returns></returns>
  11367. [HttpPost]
  11368. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  11369. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11370. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  11371. {
  11372. try
  11373. {
  11374. var id = dto.Id;
  11375. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  11376. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  11377. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  11378. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  11379. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  11380. 3 团组成员名单 1 团组成员名单", ""));
  11381. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  11382. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  11383. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  11384. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  11385. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  11386. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  11387. //数据源
  11388. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  11389. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  11390. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  11391. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  11392. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11393. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  11394. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  11395. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  11396. .Select((x, a, b) => new
  11397. {
  11398. x.Index,
  11399. itemName = a.Name,
  11400. CurrencyStr = b.Name,
  11401. x.Cost,
  11402. x.SubTotal,
  11403. x.Remark
  11404. })
  11405. .OrderBy((x) => x.Index)
  11406. .ToList(); //其他款项费用
  11407. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  11408. var peiceItemCurrencys = new List<string>();
  11409. if (_DayAndCosts.Any())
  11410. {
  11411. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  11412. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  11413. }
  11414. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  11415. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  11416. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  11417. {
  11418. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  11419. }
  11420. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  11421. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  11422. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  11423. if (dto.ExportType == 1) //明细表
  11424. {
  11425. if (dto.SubTypeId == 1005) //1005(默认明细表)
  11426. {
  11427. //获取模板
  11428. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  11429. //载入模板
  11430. Document doc = new Document(tempPath);
  11431. DocumentBuilder builder = new DocumentBuilder(doc);
  11432. //利用键值对存放数据
  11433. Dictionary<string, string> dic = new Dictionary<string, string>();
  11434. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  11435. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  11436. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  11437. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  11438. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  11439. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  11440. //境内费用(其他费用)
  11441. if (_EnterExitCosts.ChoiceOne == 1)
  11442. {
  11443. string row1_1 = "";
  11444. if (_EnterExitCosts.Visa > 0)
  11445. {
  11446. //insidePayTotal += _EnterExitCosts.Visa;
  11447. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  11448. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  11449. //{
  11450. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  11451. //}
  11452. }
  11453. string row1_2 = "";
  11454. if (_EnterExitCosts.YiMiao > 0)
  11455. {
  11456. //insidePayTotal += _EnterExitCosts.YiMiao;
  11457. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  11458. }
  11459. if (_EnterExitCosts.HeSuan > 0)
  11460. {
  11461. //insidePayTotal += _EnterExitCosts.HeSuan;
  11462. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  11463. }
  11464. if (_EnterExitCosts.Service > 0)
  11465. {
  11466. //insidePayTotal += _EnterExitCosts.Service;
  11467. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  11468. }
  11469. string row1_3 = "";
  11470. if (_EnterExitCosts.Safe > 0)
  11471. {
  11472. //insidePayTotal += _EnterExitCosts.Safe;
  11473. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  11474. }
  11475. if (_EnterExitCosts.Ticket > 0)
  11476. {
  11477. //insidePayTotal += _EnterExitCosts.Ticket;
  11478. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  11479. }
  11480. string row1 = "";
  11481. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  11482. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  11483. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  11484. row1 += $"备注:{_EnterExitCosts.Remark}";
  11485. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  11486. dic.Add("Row1Str", row1);
  11487. }
  11488. string airTotalStr = string.Empty,
  11489. airPriceStr = string.Empty;
  11490. //经济舱
  11491. if (_EnterExitCosts.SumJJC == 1)
  11492. {
  11493. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  11494. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  11495. }
  11496. //公务舱
  11497. if (_EnterExitCosts.SumGWC == 1)
  11498. {
  11499. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  11500. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  11501. }
  11502. //头等舱
  11503. if (_EnterExitCosts.SumTDC == 1)
  11504. {
  11505. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  11506. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  11507. }
  11508. //汇率描述
  11509. string rateStr = "";
  11510. if (peiceItemCurrencyInfos.Any())
  11511. {
  11512. rateStr = "\r\n汇率描述:";
  11513. foreach (var item in peiceItemCurrencyInfos)
  11514. {
  11515. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  11516. }
  11517. }
  11518. string twoItemRemark = "备注:";
  11519. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  11520. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  11521. dic.Add("AirTotalStr", airTotalStr);
  11522. dic.Add("AirPriceStr", airPriceStr);
  11523. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  11524. dic.Add("TwoItemRemark", twoItemRemark);
  11525. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11526. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  11527. int table1Row = 0,
  11528. table2Row = 0,
  11529. table3Row = 0,
  11530. table4Row = 0,
  11531. table5Row = 0;
  11532. //住宿费
  11533. if (_EnterExitCosts.ChoiceThree == 1)
  11534. {
  11535. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  11536. table1Row = dac1.Count;
  11537. #region 填充word表格内容
  11538. for (int i = 0; i < dac1.Count; i++)
  11539. {
  11540. var dac = dac1[i];
  11541. if (dac == null) continue;
  11542. builder.MoveToCell(0, i, 0, 0);
  11543. builder.Write("第" + dac.Days.ToString() + "晚:");
  11544. builder.MoveToCell(0, i, 1, 0);
  11545. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  11546. //builder.Write(dac.Place == null ? "" : dac.Place);
  11547. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11548. builder.MoveToCell(0, i, 2, 0);
  11549. builder.Write("费用标准:");
  11550. string curr = "";
  11551. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11552. if (currData != null)
  11553. {
  11554. curr = currData.Name;
  11555. }
  11556. builder.MoveToCell(0, i, 3, 0);
  11557. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11558. builder.MoveToCell(0, i, 4, 0);
  11559. builder.Write("费用小计:");
  11560. builder.MoveToCell(0, i, 5, 0);
  11561. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11562. }
  11563. #endregion
  11564. }
  11565. else dic.Add("SubZS", "0.00");
  11566. //删除多余行
  11567. while (table1.Rows.Count > table1Row)
  11568. {
  11569. table1.Rows.RemoveAt(table1Row);
  11570. }
  11571. //伙食费
  11572. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  11573. if (_EnterExitCosts.ChoiceFour == 1)
  11574. {
  11575. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  11576. table2Row = dac2.Count;
  11577. #region 填充word表格内容
  11578. for (int i = 0; i < dac2.Count; i++)
  11579. {
  11580. var dac = dac2[i];
  11581. if (dac == null) continue;
  11582. builder.MoveToCell(1, i, 0, 0);
  11583. builder.Write("第" + dac.Days.ToString() + "天:");
  11584. builder.MoveToCell(1, i, 1, 0);
  11585. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11586. builder.MoveToCell(1, i, 2, 0);
  11587. builder.Write("费用标准:");
  11588. string curr = "";
  11589. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11590. if (currData != null)
  11591. {
  11592. curr = currData.Name;
  11593. }
  11594. builder.MoveToCell(1, i, 3, 0);
  11595. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11596. builder.MoveToCell(1, i, 4, 0);
  11597. builder.Write("费用小计:");
  11598. builder.MoveToCell(1, i, 5, 0);
  11599. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11600. }
  11601. #endregion
  11602. }
  11603. else dic.Add("SubHS", "0.00");
  11604. //删除多余行
  11605. while (table2.Rows.Count > table2Row)
  11606. {
  11607. table2.Rows.RemoveAt(table2Row);
  11608. }
  11609. //公杂费
  11610. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  11611. if (_EnterExitCosts.ChoiceFive == 1)
  11612. {
  11613. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  11614. table3Row = dac3.Count;
  11615. #region 填充word表格内容
  11616. for (int i = 0; i < dac3.Count; i++)
  11617. {
  11618. var dac = dac3[i];
  11619. if (dac == null) continue;
  11620. builder.MoveToCell(2, i, 0, 0);
  11621. builder.Write("第" + dac.Days.ToString() + "天:");
  11622. builder.MoveToCell(2, i, 1, 0);
  11623. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11624. builder.MoveToCell(2, i, 2, 0);
  11625. builder.Write("费用标准:");
  11626. string curr = "";
  11627. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11628. if (currData != null)
  11629. {
  11630. curr = currData.Name;
  11631. }
  11632. builder.MoveToCell(2, i, 3, 0);
  11633. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11634. builder.MoveToCell(2, i, 4, 0);
  11635. builder.Write("费用小计:");
  11636. builder.MoveToCell(2, i, 5, 0);
  11637. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11638. }
  11639. //删除多余行
  11640. while (table3.Rows.Count > table3Row)
  11641. {
  11642. table3.Rows.RemoveAt(table3Row);
  11643. }
  11644. #endregion
  11645. }
  11646. else dic.Add("SubGZF", "0.00");
  11647. //删除多余行
  11648. while (table3.Rows.Count > table3Row)
  11649. {
  11650. table3.Rows.RemoveAt(table3Row);
  11651. }
  11652. //培训费
  11653. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  11654. if (_EnterExitCosts.ChoiceSix == 1)
  11655. {
  11656. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  11657. dic.Add("SubPX", pxStr);
  11658. table4Row = dac4.Count;
  11659. #region 填充word表格内容
  11660. for (int i = 0; i < dac4.Count; i++)
  11661. {
  11662. var dac = dac4[i];
  11663. if (dac == null) continue;
  11664. builder.MoveToCell(3, i, 0, 0);
  11665. builder.Write("第" + dac.Days.ToString() + "天:");
  11666. builder.MoveToCell(3, i, 1, 0);
  11667. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11668. builder.MoveToCell(3, i, 2, 0);
  11669. builder.Write("费用标准:");
  11670. string curr = "";
  11671. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11672. if (currData != null)
  11673. {
  11674. curr = currData.Name;
  11675. }
  11676. builder.MoveToCell(3, i, 3, 0);
  11677. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11678. builder.MoveToCell(3, i, 4, 0);
  11679. builder.Write("费用小计:");
  11680. builder.MoveToCell(3, i, 5, 0);
  11681. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11682. }
  11683. #endregion
  11684. }
  11685. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  11686. //删除多余行
  11687. while (table4.Rows.Count > table4Row)
  11688. {
  11689. table4.Rows.RemoveAt(table4Row);
  11690. }
  11691. //其他费用
  11692. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  11693. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  11694. {
  11695. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  11696. dic.Add("titleQi", qtStr);
  11697. table5Row = dac5.Count;
  11698. #region 填充word表格内容
  11699. for (int i = 0; i < dac5.Count; i++)
  11700. {
  11701. var dac = dac5[i];
  11702. if (dac == null) continue;
  11703. builder.MoveToCell(4, i, 0, 0);
  11704. builder.Write("第" + dac.Index.ToString() + "项:");
  11705. builder.MoveToCell(4, i, 1, 0);
  11706. builder.Write(dac.itemName);
  11707. builder.MoveToCell(4, i, 2, 0);
  11708. builder.Write("费用标准:");
  11709. builder.MoveToCell(4, i, 3, 0);
  11710. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  11711. builder.MoveToCell(4, i, 4, 0);
  11712. builder.Write("费用小计:");
  11713. builder.MoveToCell(4, i, 5, 0);
  11714. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11715. builder.MoveToCell(4, i, 6, 0);
  11716. builder.Write("备注:");
  11717. builder.MoveToCell(4, i, 7, 0);
  11718. builder.Write(dac.Remark);
  11719. }
  11720. #endregion
  11721. }
  11722. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  11723. //删除多余行
  11724. while (table5.Rows.Count > table5Row)
  11725. {
  11726. table5.Rows.RemoveAt(table5Row);
  11727. }
  11728. //加上其他费用
  11729. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  11730. decimal subJJC = 0.00M,
  11731. subGWC = 0.00M,
  11732. subTDC = 0.00M;
  11733. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  11734. string totalLabel = string.Format("全部费用总计:");
  11735. //经济舱
  11736. if (_EnterExitCosts.SumJJC == 1)
  11737. {
  11738. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  11739. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  11740. }
  11741. //公务舱
  11742. if (_EnterExitCosts.SumGWC == 1)
  11743. {
  11744. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  11745. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  11746. }
  11747. //头等舱
  11748. if (_EnterExitCosts.SumTDC == 1)
  11749. {
  11750. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  11751. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  11752. }
  11753. //TotalLabel
  11754. dic.Add("TotalLabel", totalLabel);
  11755. #region 填充word模板书签内容
  11756. foreach (var key in dic.Keys)
  11757. {
  11758. Bookmark bookmark = doc.Range.Bookmarks[key];
  11759. if (bookmark != null)
  11760. {
  11761. builder.MoveToBookmark(key);
  11762. builder.Write(dic[key]);
  11763. }
  11764. }
  11765. #endregion
  11766. //文件名
  11767. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  11768. strFileName = CommonFun.ValidFileName(strFileName);
  11769. AsposeHelper.removewatermark_v2180();
  11770. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  11771. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  11772. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  11773. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  11774. }
  11775. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  11776. {
  11777. //获取模板
  11778. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  11779. //载入模板
  11780. Document doc = new Document(tempPath);
  11781. DocumentBuilder builder = new DocumentBuilder(doc);
  11782. Dictionary<string, string> dic = new Dictionary<string, string>();
  11783. string returnCodeLabel = string.Empty;
  11784. if (nationalTravelFeeData.Any())
  11785. {
  11786. List<string> list = new List<string>();
  11787. foreach (var item in nationalTravelFeeData)
  11788. {
  11789. list.Add($"{item.Country}({item.City})");
  11790. }
  11791. list = list.Distinct().ToList();
  11792. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  11793. }
  11794. var countryLabel = string.Empty;
  11795. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  11796. if (countryData.Any())
  11797. {
  11798. countryLabel = string.Join("、", countryData);
  11799. }
  11800. dic.Add("ReturnCodeAir", returnCodeLabel);
  11801. dic.Add("VisitStartDate", "-");
  11802. dic.Add("VisitEndDate", "-");
  11803. dic.Add("Day", "-");
  11804. dic.Add("VisitCountry", countryLabel);
  11805. dic.Add("ClientUnit", "-");
  11806. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  11807. //dic.Add("Names", Names);
  11808. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11809. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  11810. decimal dac1totalPrice = 0.00M;
  11811. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  11812. foreach (var dac in dac1)
  11813. {
  11814. if (dac.SubTotal == 0.00M)
  11815. {
  11816. continue;
  11817. }
  11818. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  11819. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  11820. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  11821. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  11822. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  11823. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  11824. builder.Write(currency);//币种
  11825. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  11826. builder.Write(dac.Cost.ToString("#0.00"));//标准
  11827. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  11828. builder.Write("");//人数
  11829. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  11830. builder.Write("");//天数
  11831. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  11832. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  11833. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  11834. decimal rate = 0.00M;
  11835. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  11836. builder.Write(rate.ToString("#0.0000"));//汇率
  11837. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  11838. decimal rbmPrice = dac.SubTotal;
  11839. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  11840. accommodationStartIndex++;
  11841. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  11842. }
  11843. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  11844. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  11845. {
  11846. table1.Rows.RemoveAt(i - 1);
  11847. foodandotherStartIndex--;
  11848. }
  11849. if (dac2.Count == dac3.Count)//国家 币种 金额
  11850. {
  11851. for (int i = 0; i < dac2.Count; i++)
  11852. {
  11853. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  11854. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  11855. }
  11856. }
  11857. decimal dac2totalPrice = 0.00M;
  11858. foreach (var dac in dac2)
  11859. {
  11860. if (dac.SubTotal == 0)
  11861. {
  11862. continue;
  11863. }
  11864. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  11865. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  11866. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  11867. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  11868. builder.Write(currency);//币种
  11869. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  11870. builder.Write(dac.Cost.ToString("#0.00"));//标准
  11871. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  11872. builder.Write("");//人数
  11873. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  11874. builder.Write("");//天数
  11875. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  11876. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  11877. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  11878. decimal rate = 0.00M;
  11879. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  11880. builder.Write(rate.ToString("#0.0000"));//汇率
  11881. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  11882. decimal rbmPrice = dac.SubTotal;
  11883. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  11884. foodandotherStartIndex++;
  11885. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  11886. }
  11887. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  11888. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  11889. {
  11890. table1.Rows.RemoveAt(i - 1);
  11891. }
  11892. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  11893. string otherFeeStr = "";
  11894. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  11895. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  11896. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  11897. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  11898. foreach (var otherInfo in dac5)
  11899. {
  11900. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  11901. }
  11902. #endregion
  11903. if (otherFeeStr.Length > 0)
  11904. {
  11905. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  11906. otherFeeStr = $"({otherFeeStr})";
  11907. dic.Add("OtherFeeStr", otherFeeStr);
  11908. }
  11909. //总计
  11910. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  11911. //国际旅费
  11912. string outsideAir = string.Empty;
  11913. string allPriceAir = string.Empty;
  11914. if (_EnterExitCosts.SumJJC == 1)
  11915. {
  11916. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  11917. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  11918. }
  11919. if (_EnterExitCosts.SumGWC == 1)
  11920. {
  11921. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  11922. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  11923. }
  11924. if (_EnterExitCosts.SumTDC == 1)
  11925. {
  11926. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  11927. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  11928. }
  11929. dic.Add("InTravelPrice", $"({outsideAir})");
  11930. dic.Add("FinalSumPrice", $"({allPriceAir})");
  11931. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  11932. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  11933. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  11934. foreach (var key in dic.Keys)
  11935. {
  11936. builder.MoveToBookmark(key);
  11937. builder.Write(dic[key]);
  11938. }
  11939. //模板文件名
  11940. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  11941. strFileName = CommonFun.ValidFileName(strFileName);
  11942. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  11943. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  11944. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  11945. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  11946. }
  11947. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  11948. {
  11949. //获取模板
  11950. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  11951. //载入模板
  11952. WorkbookDesigner designer = new WorkbookDesigner();
  11953. designer.Workbook = new Workbook(tempPath);
  11954. Dictionary<string, string> dic = new Dictionary<string, string>();
  11955. string returnCodeLabel = string.Empty;
  11956. if (nationalTravelFeeData.Any())
  11957. {
  11958. List<string> list = new List<string>();
  11959. foreach (var item in nationalTravelFeeData)
  11960. {
  11961. list.Add($"{item.Country}({item.City})");
  11962. }
  11963. list = list.Distinct().ToList();
  11964. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  11965. }
  11966. var countryLabel = string.Empty;
  11967. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  11968. if (countryData.Any())
  11969. {
  11970. countryLabel = string.Join("、", countryData);
  11971. }
  11972. dic.Add("ReturnCodeAir", returnCodeLabel);
  11973. dic.Add("VisitStartDate", "-");
  11974. dic.Add("VisitEndDate", "-");
  11975. dic.Add("Day", "0");
  11976. dic.Add("VisitCountry", countryLabel);
  11977. dic.Add("ClientUnit", "-");
  11978. designer.SetDataSource("ClientUnit", "-");
  11979. designer.SetDataSource("VisitCountry", countryLabel);
  11980. designer.SetDataSource("Group", "-");
  11981. designer.SetDataSource("ClientUnitTitle", "-");
  11982. designer.SetDataSource("Name", "-");
  11983. designer.SetDataSource("VisitStartDate", "-");
  11984. designer.SetDataSource("Day", "0");
  11985. designer.SetDataSource("ReturnCode", returnCodeLabel);
  11986. designer.SetDataSource("ReturnCodeAir", "-");
  11987. int startIndex = 10;
  11988. const int startIndexcopy = 10;
  11989. if (dac2.Count == dac3.Count)//国家 币种 金额
  11990. {
  11991. for (int i = 0; i < dac2.Count; i++)
  11992. {
  11993. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  11994. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  11995. }
  11996. }
  11997. DataTable dtdac1 = new DataTable();
  11998. List<string> place = new List<string>();
  11999. dtdac1.Columns.AddRange(new DataColumn[] {
  12000. new DataColumn(){ ColumnName = "city"},
  12001. new DataColumn(){ ColumnName = "curr"},
  12002. new DataColumn(){ ColumnName = "criterion"},
  12003. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  12004. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  12005. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  12006. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  12007. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  12008. });
  12009. DataTable dtdac2 = new DataTable();
  12010. dtdac2.Columns.AddRange(new DataColumn[] {
  12011. new DataColumn(){ ColumnName = "city"},
  12012. new DataColumn(){ ColumnName = "curr"},
  12013. new DataColumn(){ ColumnName = "criterion"},
  12014. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  12015. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  12016. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  12017. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  12018. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  12019. });
  12020. dtdac1.TableName = "tb1";
  12021. dtdac2.TableName = "tb2";
  12022. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  12023. foreach (var item in dac1)
  12024. {
  12025. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  12026. if (place.Contains(item.Place))
  12027. {
  12028. continue;
  12029. }
  12030. DataRow row = dtdac1.NewRow();
  12031. row["city"] = item.Place;
  12032. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  12033. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  12034. row["curr"] = currency;
  12035. row["rate"] = rate.ToString("#0.0000");
  12036. row["criterion"] = item.Cost.ToString("#0.00");
  12037. row["number"] = 1;
  12038. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  12039. //row["costRMB"] = rbmPrice;
  12040. dtdac1.Rows.Add(row);
  12041. place.Add(item.Place);
  12042. }
  12043. place = new List<string>();
  12044. foreach (var item in dac2)
  12045. {
  12046. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  12047. if (place.Contains(item.Place))
  12048. {
  12049. continue;
  12050. }
  12051. DataRow row = dtdac2.NewRow();
  12052. row["city"] = item.Place;
  12053. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  12054. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  12055. row["curr"] = currency;
  12056. row["rate"] = rate.ToString("#0.0000");
  12057. row["criterion"] = item.Cost.ToString("#0.00");
  12058. row["number"] = 1;
  12059. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  12060. //row["cost"] = item.SubTotal;
  12061. //row["costRMB"] = rbmPrice;
  12062. dtdac2.Rows.Add(row);
  12063. place.Add(item.Place);
  12064. //dac2totalPrice += rbmPrice;
  12065. }
  12066. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  12067. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  12068. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  12069. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  12070. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  12071. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  12072. string cell4Str1 = string.Empty;
  12073. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  12074. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  12075. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  12076. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  12077. string cellStr = $" 5.其他费用(";
  12078. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  12079. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  12080. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  12081. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  12082. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  12083. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  12084. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  12085. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  12086. foreach (var otherInfo in dac5)
  12087. {
  12088. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  12089. }
  12090. #endregion
  12091. if (cellStr.Length > 8)
  12092. {
  12093. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  12094. }
  12095. cellStr += ")";
  12096. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  12097. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  12098. decimal pxFee = dac4.Sum(it => it.Cost);
  12099. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  12100. string celllastStr1 = "";
  12101. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  12102. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  12103. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  12104. celllastStr1 += $",国际旅费 元";
  12105. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  12106. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  12107. designer.SetDataSource("cell4Str", cell4Str);
  12108. designer.SetDataSource("cellStr", cellStr);
  12109. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  12110. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  12111. designer.SetDataSource("celllastStr", celllastStr);
  12112. Workbook wb = designer.Workbook;
  12113. var sheet = wb.Worksheets[0];
  12114. //绑定datatable数据集
  12115. designer.SetDataSource(dtdac1);
  12116. designer.SetDataSource(dtdac2);
  12117. designer.Process();
  12118. var rowStart = dtdac1.Rows.Count;
  12119. while (rowStart > 0)
  12120. {
  12121. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  12122. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  12123. startIndex++;
  12124. rowStart--;
  12125. }
  12126. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  12127. startIndex += 1; //总计行
  12128. rowStart = dtdac2.Rows.Count;
  12129. while (rowStart > 0)
  12130. {
  12131. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  12132. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  12133. startIndex++;
  12134. rowStart--;
  12135. }
  12136. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  12137. wb.CalculateFormula(true);
  12138. //模板文件名
  12139. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12140. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  12141. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  12142. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  12143. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  12144. }
  12145. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  12146. {
  12147. //获取模板
  12148. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  12149. //载入模板
  12150. Document doc = new Document(tempPath);
  12151. DocumentBuilder builder = new DocumentBuilder(doc);
  12152. Dictionary<string, string> dic = new Dictionary<string, string>();
  12153. dic.Add("GroupName", "-");
  12154. dic.Add("ClientUnit", "-");
  12155. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  12156. //string missionLeaderJob = "";//负责人job
  12157. //int groupNumber = 0; //团人数
  12158. dic.Add("MissionLeader", "-"); //团负责人
  12159. dic.Add("MissionLeaderJob", "-"); //团负责人job
  12160. dic.Add("GroupNumber", "0"); //团人数
  12161. dic.Add("Day", "0");
  12162. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  12163. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  12164. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12165. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  12166. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  12167. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  12168. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  12169. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  12170. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  12171. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  12172. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  12173. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  12174. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  12175. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  12176. //其他费用
  12177. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  12178. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  12179. //其他费用合计
  12180. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  12181. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  12182. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  12183. //公务舱合计
  12184. //国际旅费
  12185. //string outsideJJ = "";
  12186. //string allPriceJJ = "";
  12187. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  12188. {
  12189. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  12190. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  12191. }
  12192. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  12193. {
  12194. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  12195. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  12196. }
  12197. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  12198. {
  12199. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  12200. dic.Add("AirFeeTotal", airFeeTotalStr);
  12201. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  12202. dic.Add("FeeTotal", feeTotalStr);
  12203. }
  12204. foreach (var key in dic.Keys)
  12205. {
  12206. builder.MoveToBookmark(key);
  12207. builder.Write(dic[key]);
  12208. }
  12209. //模板文件名
  12210. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  12211. strFileName = CommonFun.ValidFileName(strFileName);
  12212. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  12213. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  12214. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  12215. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  12216. }
  12217. }
  12218. else if (dto.ExportType == 2) //表格
  12219. {
  12220. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  12221. }
  12222. else if (dto.ExportType == 3)
  12223. {
  12224. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  12225. }
  12226. return Ok(JsonView(400, "只可导出明细表!", ""));
  12227. }
  12228. catch (Exception ex)
  12229. {
  12230. return Ok(JsonView(400, ex.Message, ""));
  12231. }
  12232. }
  12233. /// <summary>
  12234. /// 获取三公费用标准city
  12235. /// </summary>
  12236. /// <param name="placeData"></param>
  12237. /// <param name="nationalTravelFeeId"></param>
  12238. /// <returns></returns>
  12239. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  12240. {
  12241. string _city = string.Empty;
  12242. if (!placeData.Any()) return _city;
  12243. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  12244. if (data == null) return _city;
  12245. string country = data.Country;
  12246. string city = data.City;
  12247. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  12248. else _city = city;
  12249. return _city;
  12250. }
  12251. /// <summary>
  12252. /// 团组模块 - 出入境费用-草稿 - 一键清空
  12253. /// </summary>
  12254. /// <returns></returns>
  12255. [HttpPost]
  12256. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  12257. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12258. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  12259. {
  12260. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  12261. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  12262. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  12263. if (_view.Code == 0)
  12264. {
  12265. return Ok(JsonView(true, "操作成功"));
  12266. }
  12267. return Ok(JsonView(false, "操作失败"));
  12268. }
  12269. /// <summary>
  12270. /// 团组模块 - 出入境费用-草稿 - 子项删除
  12271. /// </summary>
  12272. /// <returns></returns>
  12273. [HttpPost]
  12274. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  12275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12276. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12277. {
  12278. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12279. if (data.Code != 0)
  12280. {
  12281. return Ok(JsonView(false, data.Msg));
  12282. }
  12283. return Ok(JsonView(true, "操作成功!", data.Data));
  12284. }
  12285. /// <summary>
  12286. /// 三公其他费用草稿 删除
  12287. /// </summary>
  12288. /// <param name="dto"></param>
  12289. /// <returns></returns>
  12290. [HttpPost]
  12291. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  12292. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  12293. {
  12294. var jw = JsonView(false, "删除失败!");
  12295. var data = new Grp_DayOtherPriceDraft()
  12296. {
  12297. Id = dto.Id,
  12298. IsDel = 1,
  12299. DeleteUserId = dto.DeleteUserId,
  12300. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12301. };
  12302. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12303. if (del > 0)
  12304. {
  12305. jw.Code = 200;
  12306. jw.Msg = "删除成功!";
  12307. }
  12308. return Ok(jw);
  12309. }
  12310. /// <summary>
  12311. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  12312. /// </summary>
  12313. /// <returns></returns>
  12314. [HttpPost]
  12315. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  12316. {
  12317. var jw = JsonView(false);
  12318. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  12319. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  12320. jw.Code = StatusCodes.Status200OK;
  12321. jw.Msg = "操作成功!";
  12322. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  12323. return Ok(jw);
  12324. }
  12325. /// <summary>
  12326. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  12327. /// </summary>
  12328. /// <param name="dto"></param>
  12329. /// <returns></returns>
  12330. [HttpPost]
  12331. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  12332. {
  12333. int userId = dto.UserId,
  12334. portId = dto.PortType,
  12335. groupId = dto.GroupId,
  12336. draftId = dto.DraftId;
  12337. _portTypeData.Add(1);
  12338. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12339. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  12340. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  12341. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  12342. _sqlSugar.BeginTran();
  12343. try
  12344. {
  12345. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  12346. if (draftDatas == null)
  12347. {
  12348. _sqlSugar.RollbackTran();
  12349. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  12350. }
  12351. //验证可覆盖已有数据 两边创建人需为同一人;
  12352. int draftCreateUserId = draftDatas.CreateUserId,
  12353. formalCreateUserId = 0;
  12354. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  12355. if (formalData != null)
  12356. {
  12357. formalCreateUserId = formalData.CreateUserId;
  12358. if (draftCreateUserId != formalCreateUserId)
  12359. {
  12360. _sqlSugar.RollbackTran();
  12361. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  12362. }
  12363. }
  12364. //默认添加查看、编辑权限(创建人、自己)
  12365. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  12366. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  12367. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  12368. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  12369. newExterData.DiId = groupId;
  12370. newExterData.CreateUserId = userId;
  12371. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  12372. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  12373. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  12374. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  12375. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  12376. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  12377. //数据如果存在执行删除
  12378. if (enterExitCostInfo != null)
  12379. {
  12380. _sqlSugar.Updateable<Grp_EnterExitCost>()
  12381. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  12382. .Where(x => x.Id == enterExitCostInfo.Id)
  12383. .ExecuteCommand();
  12384. _sqlSugar.Updateable<Grp_DayAndCost>()
  12385. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  12386. .Where(x => x.DiId == groupId)
  12387. .ExecuteCommand();
  12388. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  12389. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  12390. .Where(x => x.Diid == groupId)
  12391. .ExecuteCommand();
  12392. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  12393. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  12394. .Where(x => x.GroupId == groupId)
  12395. .ExecuteCommand();
  12396. }
  12397. //执行insert
  12398. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  12399. if (insertId < 1)
  12400. {
  12401. _sqlSugar.RollbackTran();
  12402. return Ok(JsonView(false, "草稿数据导入失败!"));
  12403. }
  12404. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  12405. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  12406. #region 默认添加权限
  12407. #endregion
  12408. _sqlSugar.CommitTran();
  12409. //执行操作之后
  12410. //生成默认文件pdf并且通知人员
  12411. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12412. {
  12413. DiId = groupId,
  12414. ExportType = 1,
  12415. SubTypeId = 1005
  12416. }, "pdf");
  12417. //发送通知
  12418. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  12419. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  12420. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  12421. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  12422. //汇率信息记录
  12423. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  12424. return Ok(JsonView(true));
  12425. }
  12426. catch (Exception ex)
  12427. {
  12428. _sqlSugar.RollbackTran();
  12429. return Ok(JsonView(false, ex.Message));
  12430. }
  12431. }
  12432. #endregion
  12433. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  12434. /// <summary>
  12435. /// 获取币种基础数据(含逻辑处理)
  12436. /// </summary>
  12437. /// <returns></returns>
  12438. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  12439. {
  12440. return await GeneralMethod.EnterExitCostInitRate();
  12441. }
  12442. /// <summary>
  12443. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  12444. /// </summary>
  12445. /// <returns></returns>
  12446. [HttpPost]
  12447. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12448. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  12449. {
  12450. //验证城市归属并给默认值
  12451. int provinceId = dto.ProvinceId;
  12452. if (provinceId < 1) provinceId = 122;
  12453. var dataSource = await _sqlSugar
  12454. .Queryable<Sys_SetData>()
  12455. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  12456. .ToListAsync();
  12457. var fileTypes = new List<EecSetDataInfoView>();
  12458. //三公费用-Word明细类型
  12459. var wordTypeData = dataSource
  12460. .Where(it => it.STid == 72)
  12461. .Select(x => new EecSetDataInfoView
  12462. {
  12463. ParentId = 1,
  12464. Id = x.Id,
  12465. Name = x.Name
  12466. })
  12467. .ToArray();
  12468. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  12469. var excelTypeData = dataSource
  12470. .Where(it => it.STid == 73)
  12471. .Select(x => new EecSetDataInfoView
  12472. {
  12473. ParentId = 2,
  12474. Id = x.Id,
  12475. Name = x.Name
  12476. })
  12477. .ToArray();
  12478. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  12479. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  12480. fileTypes.Add(groupNameList);
  12481. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  12482. //默认币种显示
  12483. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  12484. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  12485. return Ok(JsonView(true, "查询成功!", new
  12486. {
  12487. FileTypeData = fileTypes,
  12488. CurrencyInit = _currencyInfos,
  12489. viewPermissionData = viewPermissionData
  12490. }));
  12491. }
  12492. /// <summary>
  12493. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  12494. /// </summary>
  12495. /// <returns></returns>
  12496. [HttpPost]
  12497. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12498. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  12499. {
  12500. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12501. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12502. RefAsync<int> total = 0;
  12503. int diId = 0;
  12504. var status = int.TryParse(dto.GroupName, out diId);
  12505. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  12506. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  12507. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  12508. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  12509. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  12510. .OrderByDescending(x => x.VisitStartDate)
  12511. .Select(x => new EnterExitCostMobileGroupView()
  12512. {
  12513. Id = x.Id,
  12514. GroupName = x.TeamName,
  12515. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  12516. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  12517. ProvinceId = x.CityId
  12518. })
  12519. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12520. //处理省份Id
  12521. if (data.Any())
  12522. {
  12523. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  12524. if (provCityDatas.Any())
  12525. {
  12526. foreach (var item in data)
  12527. {
  12528. var provinceId = item.ProvinceId;
  12529. var isDefualtVal = true;
  12530. if (provinceId > 0)
  12531. {
  12532. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  12533. if (parentId != null)
  12534. {
  12535. isDefualtVal = false;
  12536. item.ProvinceId = (int)parentId;
  12537. }
  12538. }
  12539. if (isDefualtVal)
  12540. {
  12541. item.ProvinceId = 122; //默认四川
  12542. }
  12543. }
  12544. }
  12545. }
  12546. //处理是否显示
  12547. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  12548. {
  12549. foreach (var item in data)
  12550. {
  12551. item.IsView = true;
  12552. }
  12553. }
  12554. return Ok(JsonView(true, "查询成功!", data, total));
  12555. }
  12556. /// <summary>
  12557. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  12558. /// </summary>
  12559. /// <returns></returns>
  12560. [HttpPost]
  12561. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12562. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  12563. {
  12564. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12565. RefAsync<int> total = 0;
  12566. var data = await _sqlSugar.Queryable<Sys_SetData>()
  12567. .Where(x => x.IsDel == 0 && x.STid == 66)
  12568. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  12569. .Select(x => new
  12570. {
  12571. id = x.Id,
  12572. name = x.Name,
  12573. remark = x.Remark,
  12574. })
  12575. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12576. return Ok(JsonView(true, "查询成功!", data, total));
  12577. }
  12578. /// <summary>
  12579. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  12580. /// </summary>
  12581. /// <returns></returns>
  12582. [HttpPost]
  12583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12584. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  12585. {
  12586. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12587. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12588. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  12589. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  12590. var groupOtherRateData = groupRateData.TeamRates;
  12591. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  12592. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  12593. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  12594. groupOtherRateData = groupOtherRateData
  12595. .Select(x => new TeamRateDescAddCurrencyIdView
  12596. {
  12597. CurrencyId = x.CurrencyId,
  12598. CurrencyName = x.CurrencyName,
  12599. CurrencyCode = x.CurrencyCode,
  12600. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  12601. }).ToList();
  12602. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  12603. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  12604. }
  12605. /// <summary>
  12606. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  12607. /// </summary>
  12608. /// <returns></returns>
  12609. [HttpPost]
  12610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12611. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  12612. {
  12613. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12614. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12615. var tipsData = new List<int>() { 1, 2, 3 };
  12616. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  12617. if (dto.TipsType == 1)
  12618. {
  12619. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  12620. }
  12621. else if (dto.TipsType == 2)
  12622. {
  12623. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  12624. return Ok(JsonView(true, "查询成功!", visaData.Data));
  12625. }
  12626. else if (dto.TipsType == 3)
  12627. {
  12628. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  12629. return Ok(JsonView(true, "查询成功!", airData));
  12630. }
  12631. return Ok(JsonView(false));
  12632. }
  12633. /// <summary>
  12634. /// 团组模块 - 出入境国家费用标准-移动端 List
  12635. /// </summary>
  12636. /// <returns></returns>
  12637. [HttpPost]
  12638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12639. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  12640. {
  12641. Stopwatch sw = new Stopwatch();
  12642. sw.Start();
  12643. int provinceId = dto.ProvinceId;
  12644. if (provinceId < 1) provinceId = 122; // 默认四川
  12645. RefAsync<int> total = 0;
  12646. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  12647. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  12648. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  12649. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  12650. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  12651. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  12652. .Select((ntf, sd, u, sd1) => new
  12653. {
  12654. Id = ntf.Id,
  12655. Area = $"{ntf.Country}-{ntf.City}",
  12656. Currency = ntf.Currency,
  12657. CurrencyCode = sd.Name,
  12658. CurrencyName = sd.Remark,
  12659. RoomCost = ntf.RoomCost,
  12660. FoodCost = ntf.FoodCost,
  12661. PublicCost = ntf.PublicCost,
  12662. TrainCost = ntf.TrainCost,
  12663. LastUpdateUserId = ntf.LastUpdateUserId,
  12664. LastUpdateUserName = u.CnName,
  12665. LastUpdateTime = ntf.LastUpdateTime
  12666. })
  12667. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12668. sw.Stop();
  12669. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  12670. }
  12671. /// <summary>
  12672. /// 团组模块 - 出入境费用-移动端 - Info
  12673. /// </summary>
  12674. /// <returns></returns>
  12675. [HttpPost]
  12676. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12677. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  12678. {
  12679. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12680. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12681. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12682. return Ok(data);
  12683. }
  12684. /// <summary>
  12685. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  12686. /// </summary>
  12687. /// <returns></returns>
  12688. [HttpPost]
  12689. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12690. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  12691. {
  12692. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12693. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12694. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12695. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  12696. var mobileInfo = new EnterExitCostMobileParentInfoView();
  12697. mobileInfo.DiId = dto.DiId;
  12698. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  12699. if (eecInfo == null) return Ok(mobileInfo);
  12700. //验证查看权限
  12701. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  12702. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  12703. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  12704. mobileInfo.IsAssignPerm = isSet;
  12705. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  12706. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12707. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12708. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  12709. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12710. {
  12711. SubId = dac.Id,
  12712. DiId = dac.DiId,
  12713. Type = dac.Type,
  12714. Days = dac.Days,
  12715. NationalTravelFeeId = dac.NationalTravelFeeId,
  12716. Arae = $"{ntf.Country}-{ntf.City}",
  12717. Cost = dac.Cost,
  12718. Currency = dac.Currency,
  12719. CurrencyName = sd.Name,
  12720. SubTotal = dac.SubTotal,
  12721. })
  12722. .ToList();
  12723. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  12724. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  12725. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  12726. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  12727. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  12728. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  12729. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  12730. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  12731. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  12732. //其他款项
  12733. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  12734. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12735. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12736. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  12737. .OrderBy((dop, sd1, sd2) => dop.Index)
  12738. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  12739. {
  12740. SubId = dop.Id,
  12741. DiId = dop.Diid,
  12742. Index = dop.Index,
  12743. SetDataId = dop.SetDataId,
  12744. SetDataName = sd1.Name,
  12745. Cost = dop.Cost,
  12746. Currency = dop.Currency,
  12747. CurrencyName = sd2.Remark,
  12748. SubTotal = dop.SubTotal,
  12749. Remark = dop.Remark,
  12750. })
  12751. .ToArray();
  12752. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  12753. return Ok(mobileInfo);
  12754. }
  12755. /// <summary>
  12756. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  12757. /// </summary>
  12758. /// <returns></returns>
  12759. [HttpPost]
  12760. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12761. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  12762. {
  12763. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12764. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12765. //验证查看权限
  12766. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  12767. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  12768. var userIds = await _sqlSugar
  12769. .Queryable<Grp_EnterExitCostPermission>()
  12770. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  12771. .Select(x => x.UserId)
  12772. .ToArrayAsync();
  12773. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  12774. var perUsersView = new List<dynamic>();
  12775. foreach (var item in perUsers)
  12776. {
  12777. bool isView1 = false;
  12778. if (userIds.Any(x => x == item.Id)) isView1 = true;
  12779. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  12780. }
  12781. return Ok(JsonView(perUsersView));
  12782. }
  12783. /// <summary>
  12784. /// 团组模块 - 出入境费用-移动端 - SubInfo
  12785. /// </summary>
  12786. /// <returns></returns>
  12787. [HttpPost]
  12788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12789. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  12790. {
  12791. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12792. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12793. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12794. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  12795. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  12796. //验证查看权限
  12797. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  12798. //if (!isView) return Ok(JsonView(false, msg));
  12799. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  12800. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  12801. var subType = dto.SubType;
  12802. if (subType == 1) //1:境内费用
  12803. {
  12804. var oneData = new ChoiceOneMobileSubInfoView()
  12805. {
  12806. Id = eecInfo.Id,
  12807. ChoiceOne = eecInfo.ChoiceOne,
  12808. ChoiceOneTotalCost = eecInfo.InsidePay,
  12809. Visa = eecInfo.Visa,
  12810. VisaRemark = eecInfo.VisaRemark,
  12811. YiMiao = eecInfo.YiMiao,
  12812. HeSuan = eecInfo.HeSuan,
  12813. Service = eecInfo.Service,
  12814. Ticket = eecInfo.Ticket,
  12815. Safe = eecInfo.Safe,
  12816. FirstItemRemark = eecInfo.FirstItemRemark
  12817. };
  12818. return Ok(JsonView(oneData));
  12819. }
  12820. else if (subType == 2) //2:国际旅费
  12821. {
  12822. var twoData = new ChoiceTwoMobileSubInfoView()
  12823. {
  12824. Id = eecInfo.Id,
  12825. ChoiceTwoJJ = eecInfo.SumJJC,
  12826. OutsideJJPay = eecInfo.OutsideJJPay,
  12827. ChoiceTwoGW = eecInfo.SumGWC,
  12828. OutsideGWPay = eecInfo.OutsideGWPay,
  12829. ChoiceTwoTD = eecInfo.SumTDC,
  12830. OutsideTDPay = eecInfo.OutsideTDPay,
  12831. AirJJ = eecInfo.AirJJ,
  12832. AirGW = eecInfo.AirGW,
  12833. AirTD = eecInfo.AirTD,
  12834. CityTranffic = eecInfo.CityTranffic,
  12835. CityTranffic1 = eecInfo.CityTranffic1,
  12836. CityTranffic2 = eecInfo.CityTranffic2,
  12837. TwoItemRemark = eecInfo.TwoItemRemark
  12838. };
  12839. return Ok(JsonView(twoData));
  12840. }
  12841. else if (subType == 3) //3:住宿费
  12842. {
  12843. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12844. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12845. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12846. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  12847. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12848. {
  12849. SubId = dac.Id,
  12850. DiId = dac.DiId,
  12851. Type = dac.Type,
  12852. Days = dac.Days,
  12853. NationalTravelFeeId = dac.NationalTravelFeeId,
  12854. Arae = $"{ntf.Country}-{ntf.City}",
  12855. Cost = dac.Cost,
  12856. Currency = dac.Currency,
  12857. CurrencyName = sd.Name,
  12858. SubTotal = dac.SubTotal,
  12859. })
  12860. .ToArray();
  12861. var data = new ChoiceMobileSubInfo3To6View()
  12862. {
  12863. ParentId = eecInfo.Id,
  12864. Choice = eecInfo.ChoiceThree,
  12865. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12866. Details = dayAndCostDatas
  12867. };
  12868. return Ok(JsonView(data));
  12869. }
  12870. else if (subType == 4) //4:伙食费
  12871. {
  12872. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12873. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12874. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12875. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  12876. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12877. {
  12878. SubId = dac.Id,
  12879. DiId = dac.DiId,
  12880. Type = dac.Type,
  12881. Days = dac.Days,
  12882. NationalTravelFeeId = dac.NationalTravelFeeId,
  12883. Arae = $"{ntf.Country}-{ntf.City}",
  12884. Cost = dac.Cost,
  12885. Currency = dac.Currency,
  12886. CurrencyName = sd.Name,
  12887. SubTotal = dac.SubTotal,
  12888. })
  12889. .ToArray();
  12890. var data = new ChoiceMobileSubInfo3To6View()
  12891. {
  12892. ParentId = eecInfo.Id,
  12893. Choice = eecInfo.ChoiceFour,
  12894. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12895. Details = dayAndCostDatas
  12896. };
  12897. return Ok(JsonView(data));
  12898. }
  12899. else if (subType == 5) //5:公杂费
  12900. {
  12901. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12902. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12903. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12904. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  12905. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12906. {
  12907. SubId = dac.Id,
  12908. DiId = dac.DiId,
  12909. Type = dac.Type,
  12910. Days = dac.Days,
  12911. NationalTravelFeeId = dac.NationalTravelFeeId,
  12912. Arae = $"{ntf.Country}-{ntf.City}",
  12913. Cost = dac.Cost,
  12914. Currency = dac.Currency,
  12915. CurrencyName = sd.Name,
  12916. SubTotal = dac.SubTotal,
  12917. })
  12918. .ToArray();
  12919. var data = new ChoiceMobileSubInfo3To6View()
  12920. {
  12921. ParentId = eecInfo.Id,
  12922. Choice = eecInfo.ChoiceFive,
  12923. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12924. Details = dayAndCostDatas
  12925. };
  12926. return Ok(JsonView(data));
  12927. }
  12928. else if (subType == 6) //6:培训费
  12929. {
  12930. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12931. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12932. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12933. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  12934. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12935. {
  12936. SubId = dac.Id,
  12937. DiId = dac.DiId,
  12938. Type = dac.Type,
  12939. Days = dac.Days,
  12940. NationalTravelFeeId = dac.NationalTravelFeeId,
  12941. Arae = $"{ntf.Country}-{ntf.City}",
  12942. Cost = dac.Cost,
  12943. Currency = dac.Currency,
  12944. CurrencyName = sd.Name,
  12945. SubTotal = dac.SubTotal,
  12946. })
  12947. .ToArray();
  12948. var data = new ChoiceMobileSubInfo3To6View()
  12949. {
  12950. ParentId = eecInfo.Id,
  12951. Choice = eecInfo.ChoiceSix,
  12952. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12953. Details = dayAndCostDatas
  12954. };
  12955. return Ok(JsonView(data));
  12956. }
  12957. else if (subType == 7) //7:其他
  12958. {
  12959. //其他款项
  12960. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  12961. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12962. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12963. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  12964. .OrderBy((dop, sd1, sd2) => dop.Index)
  12965. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  12966. {
  12967. SubId = dop.Id,
  12968. DiId = dop.Diid,
  12969. Index = dop.Index,
  12970. SetDataId = dop.SetDataId,
  12971. SetDataName = sd1.Name,
  12972. Cost = dop.Cost,
  12973. Currency = dop.Currency,
  12974. CurrencyName = sd2.Name,
  12975. SubTotal = dop.SubTotal,
  12976. Remark = dop.Remark,
  12977. })
  12978. .ToArray();
  12979. var data = new ChoiceSevenMobileSubInfoView()
  12980. {
  12981. ParentId = eecInfo.Id,
  12982. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  12983. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  12984. Details = otherData
  12985. };
  12986. return Ok(JsonView(data));
  12987. }
  12988. return Ok(JsonView(false));
  12989. }
  12990. #region op
  12991. ///// <summary>
  12992. ///// 移动端更新费用消息通知
  12993. ///// </summary>
  12994. ///// <param name="diid"></param>
  12995. ///// <param name="id"></param>
  12996. ///// <param name="currUserId"></param>
  12997. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  12998. //{
  12999. // try
  13000. // {
  13001. // ////生成默认文件pdf并且通知人员
  13002. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  13003. // //{
  13004. // // DiId = diid,
  13005. // // ExportType = 1,
  13006. // // SubTypeId = 1005
  13007. // //}, "pdf");
  13008. // ////发送通知
  13009. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  13010. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  13011. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  13012. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  13013. // ////汇率信息记录
  13014. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  13015. // }
  13016. // catch (Exception ex)
  13017. // {
  13018. // //记录日志
  13019. // throw;
  13020. // }
  13021. //}
  13022. /// <summary>
  13023. /// 验证出入境费用数据是否存在
  13024. /// 不存在添加
  13025. /// </summary>
  13026. /// <param name="diId"></param>
  13027. /// <param name="currUserId"></param>
  13028. /// <returns></returns>
  13029. /// <exception cref="CustomException"></exception>
  13030. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  13031. {
  13032. var parentId = 0;
  13033. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  13034. if (info != null)
  13035. {
  13036. parentId = info.Id;
  13037. }
  13038. else
  13039. {
  13040. var currencys = await EnterExitCostMobileGetCurrencyInit();
  13041. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  13042. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  13043. parentId = addId;
  13044. }
  13045. return parentId;
  13046. }
  13047. /// <summary>
  13048. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  13049. /// </summary>
  13050. /// <returns></returns>
  13051. [HttpPost]
  13052. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13053. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  13054. {
  13055. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13056. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13057. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  13058. //验证编辑权限
  13059. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13060. //if (!isEdit) return Ok(JsonView(false, msg));
  13061. var permissions = new List<Grp_EnterExitCostPermission>();
  13062. foreach (var userId in dto.UserIds)
  13063. {
  13064. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  13065. }
  13066. if (permissions.Any())
  13067. {
  13068. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  13069. {
  13070. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  13071. }
  13072. _sqlSugar.BeginTran();
  13073. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  13074. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  13075. if (result < 1)
  13076. {
  13077. _sqlSugar.RollbackTran();
  13078. return Ok(JsonView(false));
  13079. }
  13080. _sqlSugar.CommitTran();
  13081. return Ok(JsonView(true));
  13082. }
  13083. return Ok(JsonView(false));
  13084. }
  13085. /// <summary>
  13086. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  13087. /// </summary>
  13088. /// <returns></returns>
  13089. [HttpPost]
  13090. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13091. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  13092. {
  13093. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13094. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13095. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13096. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  13097. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  13098. int id = dto.Id;
  13099. if (id <= 0) //add
  13100. {
  13101. //int provinceId = dto.ProvinceId;
  13102. int groupId = dto.DiId;
  13103. //if (provinceId < 1) provinceId = 122;
  13104. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  13105. info.LastUpdateUserId = dto.CurrUserId;
  13106. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13107. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  13108. if (add < 1) return Ok(JsonView(false));
  13109. id = add;
  13110. }
  13111. else //update
  13112. {
  13113. ////验证编辑权限
  13114. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13115. //if (!isEdit) return Ok(JsonView(false, msg));
  13116. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  13117. {
  13118. CurrencyRemark = currencyStr,
  13119. LastUpdateUserId = dto.CurrUserId,
  13120. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13121. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  13122. if (upd < 1) return Ok(JsonView(false));
  13123. }
  13124. #region 汇率变更时更改币种相关费用
  13125. var opDayCosts = new List<Grp_DayAndCost>();
  13126. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  13127. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  13128. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  13129. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  13130. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  13131. .Select((dac, sd) => new
  13132. {
  13133. dac.Id,
  13134. dac.DiId,
  13135. CurrencyCode = sd.Name,
  13136. dac.Cost
  13137. })
  13138. .ToList();
  13139. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  13140. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  13141. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  13142. .Select((dop, sd) => new
  13143. {
  13144. dop.Id,
  13145. dop.Diid,
  13146. CurrencyCode = sd.Name,
  13147. dop.Cost
  13148. })
  13149. .ToList();
  13150. if (dayCosts.Count > 0)
  13151. {
  13152. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  13153. foreach (var dc in new_dayCosts)
  13154. {
  13155. var thisCurrency = dc.Key.ToUpper();
  13156. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  13157. if (thisRate == 0.00M) continue;
  13158. foreach (var dcSub in dc)
  13159. {
  13160. opDayCosts.Add(new Grp_DayAndCost()
  13161. {
  13162. Id = dcSub.Id,
  13163. DiId = dcSub.DiId,
  13164. Cost = dcSub.Cost,
  13165. SubTotal = dcSub.Cost * thisRate,
  13166. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  13167. });
  13168. }
  13169. }
  13170. if (opDayCosts.Count > 0)
  13171. {
  13172. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  13173. }
  13174. }
  13175. if (dayOtherCosts.Count > 0)
  13176. {
  13177. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  13178. foreach (var dc in new_dayOtherCosts)
  13179. {
  13180. var thisCurrency = dc.Key.ToUpper();
  13181. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  13182. if (thisRate == 0.00M) continue;
  13183. foreach (var dcSub in dc)
  13184. {
  13185. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  13186. {
  13187. Id = dcSub.Id,
  13188. Diid = dcSub.Diid,
  13189. Cost = dcSub.Cost,
  13190. SubTotal = dcSub.Cost * thisRate,
  13191. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  13192. });
  13193. }
  13194. }
  13195. if (opDayOtherCosts.Count > 0)
  13196. {
  13197. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  13198. }
  13199. }
  13200. #endregion
  13201. //消息通知
  13202. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13203. //汇率信息记录
  13204. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  13205. return Ok(JsonView(new { parentId = id }));
  13206. }
  13207. /// <summary>
  13208. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  13209. /// </summary>
  13210. /// <returns></returns>
  13211. [HttpPost]
  13212. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13213. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  13214. {
  13215. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13216. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13217. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13218. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13219. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  13220. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  13221. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13222. int id = dto.Id;
  13223. if (id <= 0) //add
  13224. {
  13225. checkboxInfo.CreateUserId = dto.CurrUserId;
  13226. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13227. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  13228. if (add < 1) return Ok(JsonView(false));
  13229. }
  13230. else //update
  13231. {
  13232. ////验证编辑权限
  13233. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13234. //if (!isEdit) return Ok(JsonView(false, msg));
  13235. var upd = await _sqlSugar.Updateable(checkboxInfo)
  13236. .UpdateColumns(x => new
  13237. {
  13238. x.ChoiceOne,
  13239. x.ChoiceTwo,
  13240. x.SumJJC,
  13241. x.SumGWC,
  13242. x.SumTDC,
  13243. x.ChoiceThree,
  13244. x.ChoiceFour,
  13245. x.ChoiceFive,
  13246. x.ChoiceSix,
  13247. x.OtherExpenses_Checked
  13248. })
  13249. .Where(x => x.Id == id)
  13250. .ExecuteCommandAsync();
  13251. if (upd < 1) return Ok(JsonView(false));
  13252. }
  13253. return Ok(JsonView(new { parentId = id }));
  13254. }
  13255. /// <summary>
  13256. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  13257. /// </summary>
  13258. /// <returns></returns>
  13259. [HttpPost]
  13260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13261. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  13262. {
  13263. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  13264. // if (provinceId < 1) provinceId = 122;
  13265. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  13266. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13267. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13268. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13269. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  13270. var checkboxInfo = new Grp_EnterExitCost()
  13271. {
  13272. Id = id,
  13273. //ProvinceId = provinceId,
  13274. DiId = diId,
  13275. CreateUserId = currUserId,
  13276. LastUpdateUserId = dto.CurrUserId,
  13277. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13278. };
  13279. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  13280. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  13281. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  13282. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  13283. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  13284. if (id <= 0) //add
  13285. {
  13286. checkboxInfo.CreateUserId = dto.CurrUserId;
  13287. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13288. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  13289. if (add < 1) return Ok(JsonView(false));
  13290. }
  13291. else //update
  13292. {
  13293. ////验证编辑权限
  13294. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13295. //if (!isEdit) return Ok(JsonView(false, msg));
  13296. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  13297. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  13298. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  13299. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  13300. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  13301. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  13302. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  13303. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  13304. .Where(x => x.Id == id)
  13305. .ExecuteCommandAsync();
  13306. if (upd < 1) return Ok(JsonView(false));
  13307. }
  13308. return Ok(JsonView(new { parentId = id }));
  13309. }
  13310. /// <summary>
  13311. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  13312. /// </summary>
  13313. /// <returns></returns>
  13314. [HttpPost]
  13315. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13316. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  13317. {
  13318. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13319. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13320. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13321. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13322. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  13323. info.FirstItemRemark = dto.FirstItemRemark;
  13324. info.LastUpdateUserId = dto.CurrUserId;
  13325. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13326. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  13327. int id = dto.Id;
  13328. if (id <= 0) //add
  13329. {
  13330. info.CreateUserId = dto.CurrUserId;
  13331. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13332. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  13333. if (add < 1) return Ok(JsonView(false));
  13334. id = add;
  13335. }
  13336. else //update
  13337. {
  13338. ////验证编辑权限
  13339. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13340. //if (!isEdit) return Ok(JsonView(false, msg));
  13341. var upd = await _sqlSugar.Updateable(info)
  13342. .UpdateColumns(x => new
  13343. {
  13344. x.ChoiceOne,
  13345. x.InsidePay,
  13346. x.VisaRemark,
  13347. x.Visa,
  13348. x.Service,
  13349. x.Safe,
  13350. x.Ticket,
  13351. x.HeSuan,
  13352. x.YiMiao,
  13353. x.FirstItemRemark,
  13354. x.LastUpdateUserId,
  13355. x.LastUpdateTime
  13356. })
  13357. .Where(x => x.Id == id)
  13358. .ExecuteCommandAsync();
  13359. if (upd < 1) return Ok(JsonView(false));
  13360. }
  13361. //消息通知
  13362. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13363. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  13364. }
  13365. /// <summary>
  13366. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  13367. /// </summary>
  13368. /// <returns></returns>
  13369. [HttpPost]
  13370. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13371. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  13372. {
  13373. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13374. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13375. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13376. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13377. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  13378. info.DiId = dto.DiId;
  13379. //info.ProvinceId = dto.ProvinceId;
  13380. info.OutsideJJPay = dto.OutsideJJPay;
  13381. info.OutsideGWPay = dto.OutsideGWPay;
  13382. info.OutsideTDPay = dto.OutsideTDPay;
  13383. info.AirJJ = dto.AirJJ;
  13384. info.AirGW = dto.AirGW;
  13385. info.AirTD = dto.AirTD;
  13386. info.CityTranffic = dto.CityTranffic;
  13387. info.CityTranffic1 = dto.CityTranffic1;
  13388. info.CityTranffic2 = dto.CityTranffic2;
  13389. info.TwoItemRemark = dto.TwoItemRemark;
  13390. info.SumJJC = dto.ChoiceTwoJJ;
  13391. info.SumGWC = dto.ChoiceTwoGW;
  13392. info.SumTDC = dto.ChoiceTwoTD;
  13393. info.LastUpdateUserId = dto.CurrUserId;
  13394. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13395. int id = dto.Id;
  13396. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  13397. if (id <= 0) //add i
  13398. {
  13399. info.CreateUserId = dto.CurrUserId;
  13400. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13401. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  13402. if (addId <= 0) return Ok(JsonView(false));
  13403. id = addId;
  13404. }
  13405. else //update
  13406. {
  13407. ////验证编辑权限
  13408. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13409. //if (!isEdit) return Ok(JsonView(false, msg));
  13410. var upd = await _sqlSugar.Updateable(info)
  13411. .UpdateColumns(x => new
  13412. {
  13413. x.SumJJC,
  13414. x.OutsideJJPay,
  13415. x.SumGWC,
  13416. x.OutsideGWPay,
  13417. x.SumTDC,
  13418. x.OutsideTDPay,
  13419. x.AirJJ,
  13420. x.AirGW,
  13421. x.AirTD,
  13422. x.CityTranffic,
  13423. x.CityTranffic1,
  13424. x.CityTranffic2,
  13425. x.TwoItemRemark,
  13426. x.LastUpdateTime,
  13427. x.LastUpdateUserId
  13428. })
  13429. .Where(x => x.Id == id)
  13430. .ExecuteCommandAsync();
  13431. if (upd < 1) return Ok(JsonView(false));
  13432. }
  13433. jjcItemTotal = info.AirJJ + info.CityTranffic;
  13434. gwcItemTotal = info.AirGW + info.CityTranffic1;
  13435. tdcItemTotal = info.AirTD + info.CityTranffic2;
  13436. //消息通知
  13437. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13438. return Ok(JsonView(new
  13439. {
  13440. parentId = id,
  13441. choiceTwoJJ = dto.ChoiceTwoJJ,
  13442. jjcItemTotal = jjcItemTotal,
  13443. choiceTwoGW = dto.ChoiceTwoGW,
  13444. gwcItemTotal = gwcItemTotal,
  13445. choiceTwoTD = dto.ChoiceTwoTD,
  13446. tdcItemTotal = tdcItemTotal
  13447. }));
  13448. }
  13449. /// <summary>
  13450. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  13451. /// </summary>
  13452. /// <returns></returns>
  13453. [HttpPost]
  13454. [ApiExplorerSettings(IgnoreApi = true)]
  13455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13456. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  13457. {
  13458. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13459. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13460. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13461. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  13462. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  13463. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  13464. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  13465. var infos = infos1.Select(x => new Grp_DayAndCost
  13466. {
  13467. Id = x.Id,
  13468. DiId = dto.DiId,
  13469. Type = dto.FeeType,
  13470. Days = x.Days,
  13471. NationalTravelFeeId = x.NationalTravelFeeId,
  13472. Cost = x.Cost,
  13473. Currency = x.Currency,
  13474. SubTotal = x.SubTotal,
  13475. CreateUserId = dto.CurrUserId
  13476. })
  13477. .ToList();
  13478. var adds = infos.Where(x => x.Id <= 0).ToList();
  13479. var upds = infos.Where(x => x.Id > 0).ToList();
  13480. if (adds.Count > 0)
  13481. {
  13482. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  13483. if (add < 1) return Ok(JsonView(false));
  13484. }
  13485. if (upds.Count > 0)
  13486. {
  13487. var upd = await _sqlSugar.Updateable(adds)
  13488. .UpdateColumns(x => new
  13489. {
  13490. x.Days,
  13491. x.NationalTravelFeeId,
  13492. x.Cost,
  13493. x.Currency,
  13494. x.SubTotal
  13495. })
  13496. .WhereColumns(x => new { x.Id })
  13497. .ExecuteCommandAsync();
  13498. if (upd < 1) return Ok(JsonView(false));
  13499. }
  13500. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  13501. //消息通知
  13502. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  13503. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13504. return Ok(JsonView(new { itemTotal = itemTotal }));
  13505. }
  13506. /// <summary>
  13507. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  13508. /// </summary>
  13509. /// <returns></returns>
  13510. [HttpPost]
  13511. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13512. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  13513. {
  13514. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  13515. int subId = dto.SubId, feeType = dto.FeeType;
  13516. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13517. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13518. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13519. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  13520. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  13521. subInfo.Id = subId;
  13522. subInfo.DiId = dto.DiId;
  13523. if (feeType == 3) subInfo.Type = 1;
  13524. else if (feeType == 4) subInfo.Type = 2;
  13525. else if (feeType == 5) subInfo.Type = 3;
  13526. else if (feeType == 6) subInfo.Type = 4;
  13527. subInfo.CreateUserId = dto.CurrUserId;
  13528. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  13529. if (parentId < 1) return Ok(JsonView(false));
  13530. //子表op
  13531. if (subId < 1)
  13532. {
  13533. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  13534. if (subAdd < 1) return Ok(JsonView(false));
  13535. }
  13536. else
  13537. {
  13538. ////验证编辑权限
  13539. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13540. //if (!isEdit) return Ok(JsonView(false, msg));
  13541. var subUpd = await _sqlSugar.Updateable(subInfo)
  13542. .UpdateColumns(x => new
  13543. {
  13544. x.Days,
  13545. x.NationalTravelFeeId,
  13546. x.Cost,
  13547. x.Currency,
  13548. x.SubTotal
  13549. })
  13550. .WhereColumns(x => new { x.Id })
  13551. .ExecuteCommandAsync();
  13552. if (subUpd < 1) return Ok(JsonView(false));
  13553. }
  13554. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  13555. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  13556. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  13557. }
  13558. /// <summary>
  13559. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  13560. /// </summary>
  13561. /// <returns></returns>
  13562. [HttpPost]
  13563. [ApiExplorerSettings(IgnoreApi = true)]
  13564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13565. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  13566. {
  13567. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13568. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13569. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13570. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  13571. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  13572. {
  13573. Id = x.Id,
  13574. Diid = dto.DiId,
  13575. SetDataId = x.SetDataId,
  13576. Index = x.Index,
  13577. Cost = x.Cost,
  13578. Currency = x.Currency,
  13579. SubTotal = x.SubTotal,
  13580. CreateUserId = dto.CurrUserId,
  13581. Remark = x.Remark
  13582. }).ToList();
  13583. var adds = infos.Where(x => x.Id <= 0).ToList();
  13584. var upds = infos.Where(x => x.Id > 0).ToList();
  13585. if (adds.Count > 0)
  13586. {
  13587. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  13588. if (add < 1) return Ok(JsonView(false));
  13589. }
  13590. if (upds.Count > 0)
  13591. {
  13592. var upd = await _sqlSugar.Updateable(adds)
  13593. .UpdateColumns(x => new
  13594. {
  13595. x.Index,
  13596. x.SetDataId,
  13597. x.Cost,
  13598. x.Currency,
  13599. x.SubTotal,
  13600. x.Remark
  13601. })
  13602. .WhereColumns(x => new { x.Id })
  13603. .ExecuteCommandAsync();
  13604. if (upd < 1) return Ok(JsonView(false));
  13605. }
  13606. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  13607. //消息通知
  13608. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  13609. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13610. return Ok(JsonView(new { itemTotal = itemTotal }));
  13611. }
  13612. /// <summary>
  13613. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  13614. /// </summary>
  13615. /// <returns></returns>
  13616. [HttpPost]
  13617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13618. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  13619. {
  13620. int subId = dto.SubId;
  13621. int diId = dto.Diid;
  13622. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13623. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13624. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13625. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  13626. subInfo.Id = subId;
  13627. subInfo.Diid = dto.Diid;
  13628. subInfo.CreateUserId = dto.CurrUserId;
  13629. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  13630. if (parentId < 1) return Ok(JsonView(false));
  13631. #region 子表op
  13632. if (subId < 1)//add
  13633. {
  13634. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  13635. if (subAdd < 1) return Ok(JsonView(false));
  13636. }
  13637. else //upd
  13638. {
  13639. ////验证编辑权限
  13640. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  13641. //if (!isEdit) return Ok(JsonView(false, msg));
  13642. var subUpd = await _sqlSugar.Updateable(subInfo)
  13643. .UpdateColumns(x => new
  13644. {
  13645. x.Index,
  13646. x.SetDataId,
  13647. x.Cost,
  13648. x.Currency,
  13649. x.SubTotal,
  13650. x.Remark
  13651. })
  13652. .WhereColumns(x => new { x.Id })
  13653. .ExecuteCommandAsync();
  13654. if (subUpd < 1) return Ok(JsonView(false));
  13655. }
  13656. #endregion
  13657. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  13658. //消息通知
  13659. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  13660. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  13661. }
  13662. /// <summary>
  13663. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  13664. /// </summary>
  13665. /// <returns></returns>
  13666. [HttpPost]
  13667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13668. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  13669. {
  13670. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  13671. if (data.Code != 0)
  13672. {
  13673. return Ok(JsonView(false, data.Msg));
  13674. }
  13675. return Ok(JsonView(true, "操作成功!", data.Data));
  13676. }
  13677. /// <summary>
  13678. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  13679. /// </summary>
  13680. /// <param name="dto"></param>
  13681. /// <returns></returns>
  13682. [HttpPost]
  13683. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  13684. {
  13685. var data = new Grp_DayOtherPrice()
  13686. {
  13687. Id = dto.Id,
  13688. IsDel = 1,
  13689. DeleteUserId = dto.DeleteUserId,
  13690. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  13691. };
  13692. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  13693. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  13694. return Ok(JsonView(false, "删除失败!"));
  13695. }
  13696. #endregion
  13697. #endregion
  13698. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  13699. /// <summary>
  13700. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  13701. /// </summary>
  13702. /// <returns></returns>
  13703. [HttpGet]
  13704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13705. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  13706. {
  13707. var provData = await _groupRepository.ProvinceBasicSource();
  13708. return Ok(JsonView(true, "查询成功!", provData));
  13709. }
  13710. /// <summary>
  13711. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  13712. /// </summary>
  13713. /// <returns></returns>
  13714. [HttpPost]
  13715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13716. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  13717. {
  13718. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13719. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13720. RefAsync<int> total = 0;
  13721. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  13722. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  13723. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  13724. .Select(x => new
  13725. {
  13726. Id = x.Id,
  13727. DraftName = x.DraftName,
  13728. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  13729. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  13730. .Any()
  13731. })
  13732. .OrderByDescending(x => x.Id)
  13733. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13734. return Ok(JsonView(true, "查询成功!", data, total));
  13735. }
  13736. /// <summary>
  13737. /// 出入境费用-草稿 移动端
  13738. /// 获取币种基础数据(含逻辑处理)
  13739. /// </summary>
  13740. /// <returns></returns>
  13741. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  13742. {
  13743. return await GeneralMethod.EnterExitCostInitRate();
  13744. }
  13745. /// <summary>
  13746. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  13747. /// </summary>
  13748. /// <returns></returns>
  13749. [HttpPost]
  13750. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13751. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  13752. {
  13753. //验证城市归属并给默认值
  13754. int provinceId = dto.ProvinceId;
  13755. if (provinceId < 1) provinceId = 122;
  13756. var dataSource = await _sqlSugar
  13757. .Queryable<Sys_SetData>()
  13758. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  13759. .ToListAsync();
  13760. //三公费用-Word明细类型
  13761. var wordTypeData = dataSource.Where(it => it.STid == 72)
  13762. .Select(x => new SetDataInfoView
  13763. {
  13764. Id = x.Id,
  13765. Name = x.Name,
  13766. Remark = x.Remark
  13767. })
  13768. .ToList();
  13769. //三公费用-Excel明细类型
  13770. var excelTypeData = dataSource.Where(it => it.STid == 73)
  13771. .Select(x => new SetDataInfoView
  13772. {
  13773. Id = x.Id,
  13774. Name = x.Name,
  13775. Remark = x.Remark
  13776. })
  13777. .ToList();
  13778. //默认币种显示
  13779. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  13780. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  13781. return Ok(JsonView(true, "查询成功!", new
  13782. {
  13783. WordTypeData = wordTypeData,
  13784. ExcelTypeData = excelTypeData,
  13785. CurrencyInit = _currencyInfos,
  13786. viewPermissionData = viewPermissionData
  13787. }));
  13788. }
  13789. /// <summary>
  13790. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  13791. /// </summary>
  13792. /// <returns></returns>
  13793. [HttpPost]
  13794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13795. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  13796. {
  13797. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13798. RefAsync<int> total = 0;
  13799. int diId = 0;
  13800. var status = int.TryParse(dto.GroupName, out diId);
  13801. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  13802. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  13803. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  13804. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  13805. .OrderByDescending(x => x.VisitStartDate)
  13806. .Select(x => new
  13807. {
  13808. Id = x.Id,
  13809. GroupName = x.TeamName
  13810. })
  13811. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13812. return Ok(JsonView(true, "查询成功!", data, total));
  13813. }
  13814. /// <summary>
  13815. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  13816. /// </summary>
  13817. /// <returns></returns>
  13818. [HttpPost]
  13819. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13820. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  13821. {
  13822. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13823. RefAsync<int> total = 0;
  13824. var data = await _sqlSugar.Queryable<Sys_SetData>()
  13825. .Where(x => x.IsDel == 0 && x.STid == 66)
  13826. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  13827. .Select(x => new
  13828. {
  13829. id = x.Id,
  13830. name = x.Name,
  13831. remark = x.Remark,
  13832. })
  13833. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13834. return Ok(JsonView(true, "查询成功!", data, total));
  13835. }
  13836. /// <summary>
  13837. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  13838. /// </summary>
  13839. /// <returns></returns>
  13840. [HttpPost]
  13841. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13842. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  13843. {
  13844. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13845. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  13846. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  13847. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  13848. var groupOtherRateData = groupRateData.TeamRates;
  13849. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  13850. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  13851. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  13852. groupOtherRateData = groupOtherRateData
  13853. .Select(x => new TeamRateDescAddCurrencyIdView
  13854. {
  13855. CurrencyId = x.CurrencyId,
  13856. CurrencyName = x.CurrencyName,
  13857. CurrencyCode = x.CurrencyCode,
  13858. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  13859. }).ToList();
  13860. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  13861. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  13862. }
  13863. /// <summary>
  13864. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  13865. /// </summary>
  13866. /// <returns></returns>
  13867. [HttpPost]
  13868. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13869. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  13870. {
  13871. int portType = dto.PortType;
  13872. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13873. var tipsData = new List<int>() { 1, 2, 3 };
  13874. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  13875. if (dto.TipsType == 1)
  13876. {
  13877. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  13878. }
  13879. else if (dto.TipsType == 2)
  13880. {
  13881. if (portType == 2)
  13882. {
  13883. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  13884. }
  13885. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  13886. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  13887. .Select(x => x.NationalTravelFeeId)
  13888. .Distinct()
  13889. .ToListAsync();
  13890. if (portType == 2)
  13891. {
  13892. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  13893. }
  13894. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  13895. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  13896. .Select(x => x.Country)
  13897. .Distinct()
  13898. .ToArrayAsync();
  13899. if (portType == 2)
  13900. {
  13901. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  13902. }
  13903. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  13904. return Ok(JsonView(true, "查询成功!", new
  13905. {
  13906. totalAmt = totalAmt,
  13907. remark = remark
  13908. }));
  13909. }
  13910. else if (dto.TipsType == 3)
  13911. {
  13912. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  13913. }
  13914. return Ok(JsonView(false));
  13915. }
  13916. /// <summary>
  13917. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  13918. /// </summary>
  13919. /// <returns></returns>
  13920. [HttpPost]
  13921. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13922. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  13923. {
  13924. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  13925. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13926. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13927. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  13928. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  13929. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  13930. var info = new Grp_EnterExitCostDraft()
  13931. {
  13932. ProvinceId = dto.ProvinceId,
  13933. DraftName = dto.DraftName,
  13934. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  13935. CreateUserId = dto.CurrUserId
  13936. };
  13937. _sqlSugar.BeginTran();
  13938. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  13939. if (draftId < 1)
  13940. {
  13941. _sqlSugar.RollbackTran();
  13942. return Ok(JsonView(false, "草稿创建失败!"));
  13943. }
  13944. //添加默认权限
  13945. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  13946. _sqlSugar.CommitTran();
  13947. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  13948. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  13949. mobileInfo.Id = draftId;
  13950. mobileInfo.DraftName = dto.DraftName;
  13951. mobileInfo.Currencys = rateInfos;
  13952. mobileInfo.IsAssignPerm = assignPerm;
  13953. return Ok(JsonView(mobileInfo));
  13954. }
  13955. /// <summary>
  13956. /// 出入境费用-草稿-移动端 查看编辑提示消息
  13957. /// </summary>
  13958. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  13959. /// <summary>
  13960. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  13961. /// </summary>
  13962. /// <returns></returns>
  13963. [HttpPost]
  13964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13965. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  13966. {
  13967. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13968. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13969. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  13970. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  13971. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  13972. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  13973. //验证查看编辑权限
  13974. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  13975. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  13976. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  13977. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  13978. mobileInfo.IsAssignPerm = assignPerm;
  13979. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  13980. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  13981. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  13982. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  13983. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  13984. {
  13985. ParentId = dac.ParentId,
  13986. SubId = dac.Id,
  13987. Type = dac.Type,
  13988. Days = dac.Days,
  13989. NationalTravelFeeId = dac.NationalTravelFeeId,
  13990. Arae = $"{ntf.Country}-{ntf.City}",
  13991. Cost = dac.Cost,
  13992. Currency = dac.Currency,
  13993. CurrencyName = sd.Name,
  13994. SubTotal = dac.SubTotal,
  13995. })
  13996. .ToList();
  13997. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  13998. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  13999. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  14000. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  14001. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  14002. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  14003. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  14004. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  14005. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  14006. //其他款项
  14007. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  14008. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  14009. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  14010. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  14011. .OrderBy((dop, sd1, sd2) => dop.Index)
  14012. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  14013. {
  14014. ParentId = dop.ParentId,
  14015. SubId = dop.Id,
  14016. Index = dop.Index,
  14017. SetDataId = dop.SetDataId,
  14018. SetDataName = sd1.Name,
  14019. Cost = dop.Cost,
  14020. Currency = dop.Currency,
  14021. CurrencyName = sd2.Remark,
  14022. SubTotal = dop.SubTotal,
  14023. Remark = dop.Remark,
  14024. })
  14025. .ToArray();
  14026. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  14027. return Ok(mobileInfo);
  14028. }
  14029. /// <summary>
  14030. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  14031. /// </summary>
  14032. /// <returns></returns>
  14033. [HttpPost]
  14034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14035. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  14036. {
  14037. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14038. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14039. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14040. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  14041. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  14042. //验证查看编辑权限
  14043. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14044. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14045. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  14046. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  14047. var subType = dto.SubType;
  14048. if (subType == 1) //1:境内费用
  14049. {
  14050. var oneData = new ChoiceOneMobileSubInfoView()
  14051. {
  14052. Id = eecInfo.Id,
  14053. ChoiceOne = eecInfo.ChoiceOne,
  14054. ChoiceOneTotalCost = eecInfo.InsidePay,
  14055. Visa = eecInfo.Visa,
  14056. VisaRemark = eecInfo.VisaRemark,
  14057. YiMiao = eecInfo.YiMiao,
  14058. HeSuan = eecInfo.HeSuan,
  14059. Service = eecInfo.Service,
  14060. Ticket = eecInfo.Ticket,
  14061. Safe = eecInfo.Safe,
  14062. FirstItemRemark = eecInfo.FirstItemRemark
  14063. };
  14064. return Ok(JsonView(oneData));
  14065. }
  14066. else if (subType == 2) //2:国际旅费
  14067. {
  14068. var twoData = new ChoiceTwoMobileSubInfoView()
  14069. {
  14070. Id = eecInfo.Id,
  14071. ChoiceTwoJJ = eecInfo.SumJJC,
  14072. OutsideJJPay = eecInfo.OutsideJJPay,
  14073. ChoiceTwoGW = eecInfo.SumGWC,
  14074. OutsideGWPay = eecInfo.OutsideGWPay,
  14075. ChoiceTwoTD = eecInfo.SumTDC,
  14076. OutsideTDPay = eecInfo.OutsideTDPay,
  14077. AirJJ = eecInfo.AirJJ,
  14078. AirGW = eecInfo.AirGW,
  14079. AirTD = eecInfo.AirTD,
  14080. CityTranffic = eecInfo.CityTranffic,
  14081. TwoItemRemark = eecInfo.TwoItemRemark
  14082. };
  14083. return Ok(JsonView(twoData));
  14084. }
  14085. else if (subType == 3) //3:住宿费
  14086. {
  14087. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14088. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14089. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14090. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  14091. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14092. {
  14093. ParentId = dac.ParentId,
  14094. SubId = dac.Id,
  14095. Type = dac.Type,
  14096. Days = dac.Days,
  14097. NationalTravelFeeId = dac.NationalTravelFeeId,
  14098. Arae = $"{ntf.Country}-{ntf.City}",
  14099. Cost = dac.Cost,
  14100. Currency = dac.Currency,
  14101. CurrencyName = sd.Name,
  14102. SubTotal = dac.SubTotal,
  14103. })
  14104. .ToArray();
  14105. var data = new ChoiceDraftMobileSubInfo3To6View()
  14106. {
  14107. ParentId = eecInfo.Id,
  14108. Choice = eecInfo.ChoiceThree,
  14109. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14110. Details = dayAndCostDatas
  14111. };
  14112. return Ok(JsonView(data));
  14113. }
  14114. else if (subType == 4) //4:伙食费
  14115. {
  14116. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14117. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14118. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14119. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  14120. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14121. {
  14122. ParentId = dac.ParentId,
  14123. SubId = dac.Id,
  14124. Type = dac.Type,
  14125. Days = dac.Days,
  14126. NationalTravelFeeId = dac.NationalTravelFeeId,
  14127. Arae = $"{ntf.Country}-{ntf.City}",
  14128. Cost = dac.Cost,
  14129. Currency = dac.Currency,
  14130. CurrencyName = sd.Name,
  14131. SubTotal = dac.SubTotal,
  14132. })
  14133. .ToArray();
  14134. var data = new ChoiceDraftMobileSubInfo3To6View()
  14135. {
  14136. ParentId = eecInfo.Id,
  14137. Choice = eecInfo.ChoiceFour,
  14138. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14139. Details = dayAndCostDatas
  14140. };
  14141. return Ok(JsonView(data));
  14142. }
  14143. else if (subType == 5) //5:公杂费
  14144. {
  14145. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14146. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14147. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14148. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  14149. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14150. {
  14151. ParentId = dac.ParentId,
  14152. SubId = dac.Id,
  14153. Type = dac.Type,
  14154. Days = dac.Days,
  14155. NationalTravelFeeId = dac.NationalTravelFeeId,
  14156. Arae = $"{ntf.Country}-{ntf.City}",
  14157. Cost = dac.Cost,
  14158. Currency = dac.Currency,
  14159. CurrencyName = sd.Name,
  14160. SubTotal = dac.SubTotal,
  14161. })
  14162. .ToArray();
  14163. var data = new ChoiceDraftMobileSubInfo3To6View()
  14164. {
  14165. ParentId = eecInfo.Id,
  14166. Choice = eecInfo.ChoiceFive,
  14167. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14168. Details = dayAndCostDatas
  14169. };
  14170. return Ok(JsonView(data));
  14171. }
  14172. else if (subType == 6) //6:培训费
  14173. {
  14174. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14175. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14176. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14177. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  14178. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14179. {
  14180. ParentId = dac.ParentId,
  14181. SubId = dac.Id,
  14182. Type = dac.Type,
  14183. Days = dac.Days,
  14184. NationalTravelFeeId = dac.NationalTravelFeeId,
  14185. Arae = $"{ntf.Country}-{ntf.City}",
  14186. Cost = dac.Cost,
  14187. Currency = dac.Currency,
  14188. CurrencyName = sd.Name,
  14189. SubTotal = dac.SubTotal,
  14190. })
  14191. .ToArray();
  14192. var data = new ChoiceDraftMobileSubInfo3To6View()
  14193. {
  14194. ParentId = eecInfo.Id,
  14195. Choice = eecInfo.ChoiceSix,
  14196. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14197. Details = dayAndCostDatas
  14198. };
  14199. return Ok(JsonView(data));
  14200. }
  14201. else if (subType == 7) //7:其他
  14202. {
  14203. //其他款项
  14204. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  14205. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  14206. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  14207. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  14208. .OrderBy((dop, sd1, sd2) => dop.Index)
  14209. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  14210. {
  14211. ParentId = dop.ParentId,
  14212. SubId = dop.Id,
  14213. Index = dop.Index,
  14214. SetDataId = dop.SetDataId,
  14215. SetDataName = sd1.Name,
  14216. Cost = dop.Cost,
  14217. Currency = dop.Currency,
  14218. CurrencyName = sd2.Name,
  14219. SubTotal = dop.SubTotal,
  14220. Remark = dop.Remark,
  14221. })
  14222. .ToArray();
  14223. var data = new ChoiceSevenDraftMobileSubInfoView()
  14224. {
  14225. ParentId = eecInfo.Id,
  14226. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  14227. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  14228. Details = otherData
  14229. };
  14230. return Ok(JsonView(data));
  14231. }
  14232. return Ok(JsonView(false));
  14233. }
  14234. #region op
  14235. ///// <summary>
  14236. ///// 移动端更新费用消息通知
  14237. ///// </summary>
  14238. ///// <param name="draftId"></param>
  14239. ///// <param name="id"></param>
  14240. ///// <param name="currUserId"></param>
  14241. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  14242. //{
  14243. // try
  14244. // {
  14245. // ////生成默认文件pdf并且通知人员
  14246. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  14247. // //{
  14248. // // DiId = draftId,
  14249. // // ExportType = 1,
  14250. // // SubTypeId = 1005
  14251. // //}, "pdf");
  14252. // ////发送通知
  14253. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  14254. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  14255. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  14256. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  14257. // ////汇率信息记录
  14258. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  14259. // }
  14260. // catch (Exception ex)
  14261. // {
  14262. // //记录日志
  14263. // throw;
  14264. // }
  14265. //}
  14266. /// <summary>
  14267. /// 验证出入境费用数据是否存在
  14268. /// 不存在添加
  14269. /// </summary>
  14270. /// <param name="draftId"></param>
  14271. /// <param name="currUserId"></param>
  14272. /// <returns></returns>
  14273. /// <exception cref="CustomException"></exception>
  14274. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  14275. {
  14276. var parentId = 0;
  14277. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  14278. if (info != null) parentId = info.Id;
  14279. else
  14280. {
  14281. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  14282. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  14283. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  14284. parentId = addId;
  14285. }
  14286. return parentId;
  14287. }
  14288. /// <summary>
  14289. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  14290. /// </summary>
  14291. /// <returns></returns>
  14292. [HttpPost]
  14293. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14294. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  14295. {
  14296. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14297. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14298. //验证查看权限
  14299. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14300. if (!isView) return Ok(JsonView(false, _viewPermStr));
  14301. var userIds = await _sqlSugar
  14302. .Queryable<Grp_EnterExitCostDraftPermission>()
  14303. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  14304. .Select(x => x.UserId)
  14305. .ToArrayAsync();
  14306. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  14307. var perUsersView = new List<dynamic>();
  14308. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  14309. var viewPermissionData = new List<PermissionViewUserview>();
  14310. if (feeBasePerm.Any())
  14311. {
  14312. foreach (var item in feeBasePerm)
  14313. {
  14314. if (item.Users.Any())
  14315. {
  14316. viewPermissionData.AddRange(item.Users);
  14317. }
  14318. }
  14319. }
  14320. foreach (var item in perUsers)
  14321. {
  14322. bool isView1 = false;
  14323. if (userIds.Any(x => x == item.Id)) isView1 = true;
  14324. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  14325. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  14326. }
  14327. return Ok(JsonView(perUsersView));
  14328. }
  14329. /// <summary>
  14330. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  14331. /// </summary>
  14332. /// <returns></returns>
  14333. [HttpPost]
  14334. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14335. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  14336. {
  14337. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14338. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14339. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  14340. //验证查看编辑权限
  14341. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14342. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14343. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  14344. foreach (var userId in dto.UserIds)
  14345. {
  14346. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  14347. }
  14348. if (permissions.Any())
  14349. {
  14350. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  14351. {
  14352. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  14353. }
  14354. _sqlSugar.BeginTran();
  14355. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  14356. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  14357. if (result < 1)
  14358. {
  14359. _sqlSugar.RollbackTran();
  14360. return Ok(JsonView(false));
  14361. }
  14362. _sqlSugar.CommitTran();
  14363. return Ok(JsonView(true));
  14364. }
  14365. return Ok(JsonView(false));
  14366. }
  14367. /// <summary>
  14368. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  14369. /// </summary>
  14370. /// <returns></returns>
  14371. [HttpPost]
  14372. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14373. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  14374. {
  14375. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14376. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14377. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14378. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  14379. int id = dto.DraftId;
  14380. if (id <= 0) //add
  14381. {
  14382. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14383. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  14384. if (add < 1) return Ok(JsonView(false));
  14385. id = add;
  14386. }
  14387. else //update
  14388. {
  14389. //验证查看编辑权限
  14390. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14391. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14392. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  14393. if (upd < 1) return Ok(JsonView(false));
  14394. }
  14395. return Ok(JsonView(new { parentId = id }));
  14396. }
  14397. /// <summary>
  14398. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  14399. /// </summary>
  14400. /// <returns></returns>
  14401. [HttpPost]
  14402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14403. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  14404. {
  14405. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14406. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14407. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14408. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  14409. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  14410. int id = dto.DraftId;
  14411. if (id <= 0) //add
  14412. {
  14413. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14414. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  14415. if (add < 1) return Ok(JsonView(false));
  14416. id = add;
  14417. }
  14418. else //update
  14419. {
  14420. //验证查看编辑权限
  14421. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14422. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14423. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  14424. if (upd < 1) return Ok(JsonView(false));
  14425. }
  14426. #region 汇率变更时更改币种相关费用
  14427. var opDayCosts = new List<Grp_DayAndCostDraft>();
  14428. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  14429. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  14430. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14431. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  14432. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  14433. .Select((dac, sd) => new
  14434. {
  14435. dac.Id,
  14436. dac.ParentId,
  14437. CurrencyCode = sd.Name,
  14438. dac.Cost
  14439. })
  14440. .ToList();
  14441. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  14442. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  14443. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  14444. .Select((dop, sd) => new
  14445. {
  14446. dop.Id,
  14447. dop.ParentId,
  14448. CurrencyCode = sd.Name,
  14449. dop.Cost
  14450. })
  14451. .ToList();
  14452. if (dayCosts.Count > 0)
  14453. {
  14454. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  14455. foreach (var dc in new_dayCosts)
  14456. {
  14457. var thisCurrency = dc.Key.ToUpper();
  14458. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  14459. if (thisRate == 0.00M) continue;
  14460. foreach (var dcSub in dc)
  14461. {
  14462. opDayCosts.Add(new Grp_DayAndCostDraft()
  14463. {
  14464. Id = dcSub.Id,
  14465. ParentId = dcSub.ParentId,
  14466. Cost = dcSub.Cost,
  14467. SubTotal = dcSub.Cost * thisRate,
  14468. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  14469. });
  14470. }
  14471. }
  14472. if (opDayCosts.Count > 0)
  14473. {
  14474. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  14475. }
  14476. }
  14477. if (dayOtherCosts.Count > 0)
  14478. {
  14479. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  14480. foreach (var dc in new_dayOtherCosts)
  14481. {
  14482. var thisCurrency = dc.Key.ToUpper();
  14483. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  14484. if (thisRate == 0.00M) continue;
  14485. foreach (var dcSub in dc)
  14486. {
  14487. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  14488. {
  14489. Id = dcSub.Id,
  14490. ParentId = dcSub.ParentId,
  14491. Cost = dcSub.Cost,
  14492. SubTotal = dcSub.Cost * thisRate,
  14493. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  14494. });
  14495. }
  14496. }
  14497. if (opDayOtherCosts.Count > 0)
  14498. {
  14499. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  14500. }
  14501. }
  14502. #endregion
  14503. ////消息通知
  14504. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14505. ////汇率信息记录
  14506. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  14507. return Ok(JsonView(new { parentId = id }));
  14508. }
  14509. /// <summary>
  14510. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  14511. /// </summary>
  14512. /// <returns></returns>
  14513. [HttpPost]
  14514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14515. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  14516. {
  14517. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14518. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14519. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14520. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  14521. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14522. int id = dto.DraftId;
  14523. if (id <= 0) //add
  14524. {
  14525. checkboxInfo.ProvinceId = dto.ProvinceId;
  14526. checkboxInfo.CreateUserId = dto.CurrUserId;
  14527. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  14528. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  14529. if (add < 1) return Ok(JsonView(false));
  14530. }
  14531. else //update
  14532. {
  14533. var upd = await _sqlSugar.Updateable(checkboxInfo)
  14534. .UpdateColumns(x => new
  14535. {
  14536. x.ChoiceOne,
  14537. x.ChoiceTwo,
  14538. x.SumJJC,
  14539. x.SumGWC,
  14540. x.SumTDC,
  14541. x.ChoiceThree,
  14542. x.ChoiceFour,
  14543. x.ChoiceFive,
  14544. x.ChoiceSix,
  14545. x.OtherExpenses_Checked
  14546. })
  14547. .Where(x => x.Id == id)
  14548. .ExecuteCommandAsync();
  14549. if (upd < 1) return Ok(JsonView(false));
  14550. }
  14551. return Ok(JsonView(new { parentId = id }));
  14552. }
  14553. /// <summary>
  14554. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  14555. /// </summary>
  14556. /// <returns></returns>
  14557. [HttpPost]
  14558. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14559. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  14560. {
  14561. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  14562. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  14563. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14564. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14565. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14566. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  14567. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14568. var checkboxInfo = new Grp_EnterExitCostDraft()
  14569. {
  14570. Id = draftId,
  14571. ProvinceId = dto.ProvinceId,
  14572. CreateUserId = currUserId
  14573. };
  14574. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  14575. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  14576. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  14577. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  14578. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  14579. if (draftId <= 0) //add
  14580. {
  14581. checkboxInfo.CreateUserId = dto.CurrUserId;
  14582. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  14583. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  14584. if (add < 1) return Ok(JsonView(false));
  14585. }
  14586. else //update
  14587. {
  14588. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  14589. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  14590. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  14591. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  14592. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  14593. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  14594. .Where(x => x.Id == draftId)
  14595. .ExecuteCommandAsync();
  14596. if (upd < 1) return Ok(JsonView(false));
  14597. }
  14598. return Ok(JsonView(new { parentId = draftId }));
  14599. }
  14600. /// <summary>
  14601. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  14602. /// </summary>
  14603. /// <returns></returns>
  14604. [HttpPost]
  14605. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14606. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  14607. {
  14608. int id = dto.DraftId, currUserId = dto.CurrUserId;
  14609. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14610. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  14611. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14612. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14613. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  14614. info.ProvinceId = dto.ProvinceId;
  14615. info.FirstItemRemark = dto.FirstItemRemark;
  14616. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  14617. if (id <= 0) //add
  14618. {
  14619. info.CreateUserId = dto.CurrUserId;
  14620. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  14621. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  14622. if (add < 1) return Ok(JsonView(false));
  14623. id = add;
  14624. }
  14625. else //update
  14626. {
  14627. var upd = await _sqlSugar.Updateable(info)
  14628. .UpdateColumns(x => new
  14629. {
  14630. x.ChoiceOne,
  14631. x.InsidePay,
  14632. x.VisaRemark,
  14633. x.Visa,
  14634. x.Service,
  14635. x.Safe,
  14636. x.Ticket,
  14637. x.HeSuan,
  14638. x.YiMiao,
  14639. x.FirstItemRemark
  14640. })
  14641. .Where(x => x.Id == id)
  14642. .ExecuteCommandAsync();
  14643. if (upd < 1) return Ok(JsonView(false));
  14644. }
  14645. ////消息通知
  14646. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14647. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  14648. }
  14649. /// <summary>
  14650. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  14651. /// </summary>
  14652. /// <returns></returns>
  14653. [HttpPost]
  14654. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14655. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  14656. {
  14657. int id = dto.DraftId;
  14658. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14659. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  14660. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14661. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14662. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  14663. info.ProvinceId = dto.ProvinceId;
  14664. info.OutsideJJPay = dto.OutsideJJPay;
  14665. info.OutsideGWPay = dto.OutsideGWPay;
  14666. info.OutsideTDPay = dto.OutsideTDPay;
  14667. info.AirJJ = dto.AirJJ;
  14668. info.AirGW = dto.AirGW;
  14669. info.AirTD = dto.AirTD;
  14670. info.CityTranffic = dto.CityTranffic;
  14671. info.TwoItemRemark = dto.TwoItemRemark;
  14672. info.SumJJC = dto.ChoiceTwoJJ;
  14673. info.SumGWC = dto.ChoiceTwoGW;
  14674. info.SumTDC = dto.ChoiceTwoTD;
  14675. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  14676. if (id <= 0) //add
  14677. {
  14678. info.CreateUserId = dto.CurrUserId;
  14679. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  14680. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  14681. if (addId <= 0) return Ok(JsonView(false));
  14682. id = addId;
  14683. }
  14684. else //update
  14685. {
  14686. var upd = await _sqlSugar.Updateable(info)
  14687. .UpdateColumns(x => new
  14688. {
  14689. x.SumJJC,
  14690. x.OutsideJJPay,
  14691. x.SumGWC,
  14692. x.OutsideGWPay,
  14693. x.SumTDC,
  14694. x.OutsideTDPay,
  14695. x.AirJJ,
  14696. x.AirGW,
  14697. x.AirTD,
  14698. x.CityTranffic,
  14699. x.TwoItemRemark
  14700. })
  14701. .Where(x => x.Id == id)
  14702. .ExecuteCommandAsync();
  14703. if (upd < 1) return Ok(JsonView(false));
  14704. }
  14705. jjcItemTotal = info.AirJJ + info.CityTranffic;
  14706. gwcItemTotal = info.AirGW + info.CityTranffic;
  14707. tdcItemTotal = info.AirTD + info.CityTranffic;
  14708. ////消息通知
  14709. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14710. return Ok(JsonView(new
  14711. {
  14712. parentId = id,
  14713. choiceTwoJJ = dto.ChoiceTwoJJ,
  14714. jjcItemTotal = jjcItemTotal,
  14715. choiceTwoGW = dto.ChoiceTwoGW,
  14716. gwcItemTotal = gwcItemTotal,
  14717. choiceTwoTD = dto.ChoiceTwoTD,
  14718. tdcItemTotal = tdcItemTotal
  14719. }));
  14720. }
  14721. /// <summary>
  14722. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  14723. /// </summary>
  14724. /// <returns></returns>
  14725. [HttpPost]
  14726. [ApiExplorerSettings(IgnoreApi = true)]
  14727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14728. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  14729. {
  14730. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14731. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14732. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14733. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  14734. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  14735. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  14736. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  14737. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  14738. {
  14739. Id = x.Id,
  14740. ParentId = dto.DraftId,
  14741. Type = dto.FeeType,
  14742. Days = x.Days,
  14743. NationalTravelFeeId = x.NationalTravelFeeId,
  14744. Cost = x.Cost,
  14745. Currency = x.Currency,
  14746. SubTotal = x.SubTotal,
  14747. CreateUserId = dto.CurrUserId
  14748. })
  14749. .ToList();
  14750. var adds = infos.Where(x => x.Id <= 0).ToList();
  14751. var upds = infos.Where(x => x.Id > 0).ToList();
  14752. if (adds.Count > 0)
  14753. {
  14754. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  14755. if (add < 1) return Ok(JsonView(false));
  14756. }
  14757. if (upds.Count > 0)
  14758. {
  14759. var upd = await _sqlSugar.Updateable(adds)
  14760. .UpdateColumns(x => new
  14761. {
  14762. x.Days,
  14763. x.NationalTravelFeeId,
  14764. x.Cost,
  14765. x.Currency,
  14766. x.SubTotal
  14767. })
  14768. .WhereColumns(x => new { x.Id })
  14769. .ExecuteCommandAsync();
  14770. if (upd < 1) return Ok(JsonView(false));
  14771. }
  14772. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  14773. ////消息通知
  14774. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  14775. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14776. return Ok(JsonView(new { itemTotal = itemTotal }));
  14777. }
  14778. /// <summary>
  14779. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  14780. /// </summary>
  14781. /// <returns></returns>
  14782. [HttpPost]
  14783. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14784. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  14785. {
  14786. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  14787. int subId = dto.SubId, feeType = dto.FeeType;
  14788. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14789. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14790. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14791. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  14792. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  14793. subInfo.Id = subId;
  14794. subInfo.ParentId = dto.DraftId;
  14795. if (feeType == 3) subInfo.Type = 1;
  14796. else if (feeType == 4) subInfo.Type = 2;
  14797. else if (feeType == 5) subInfo.Type = 3;
  14798. else if (feeType == 6) subInfo.Type = 4;
  14799. subInfo.CreateUserId = dto.CurrUserId;
  14800. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  14801. if (parentId < 1) return Ok(JsonView(false));
  14802. //子表op
  14803. if (subId < 1)
  14804. {
  14805. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  14806. if (subAdd < 1) return Ok(JsonView(false));
  14807. }
  14808. else
  14809. {
  14810. var subUpd = await _sqlSugar.Updateable(subInfo)
  14811. .UpdateColumns(x => new
  14812. {
  14813. x.Days,
  14814. x.NationalTravelFeeId,
  14815. x.Cost,
  14816. x.Currency,
  14817. x.SubTotal
  14818. })
  14819. .WhereColumns(x => new { x.Id })
  14820. .ExecuteCommandAsync();
  14821. if (subUpd < 1) return Ok(JsonView(false));
  14822. }
  14823. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  14824. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  14825. }
  14826. /// <summary>
  14827. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  14828. /// </summary>
  14829. /// <returns></returns>
  14830. [HttpPost]
  14831. [ApiExplorerSettings(IgnoreApi = true)]
  14832. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14833. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  14834. {
  14835. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14836. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14837. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14838. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  14839. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  14840. {
  14841. Id = x.Id,
  14842. ParentId = dto.DraftId,
  14843. SetDataId = x.SetDataId,
  14844. Index = x.Index,
  14845. Cost = x.Cost,
  14846. Currency = x.Currency,
  14847. SubTotal = x.SubTotal,
  14848. CreateUserId = dto.CurrUserId,
  14849. Remark = x.Remark
  14850. }).ToList();
  14851. var adds = infos.Where(x => x.Id <= 0).ToList();
  14852. var upds = infos.Where(x => x.Id > 0).ToList();
  14853. if (adds.Count > 0)
  14854. {
  14855. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  14856. if (add < 1) return Ok(JsonView(false));
  14857. }
  14858. if (upds.Count > 0)
  14859. {
  14860. var upd = await _sqlSugar.Updateable(adds)
  14861. .UpdateColumns(x => new
  14862. {
  14863. x.Index,
  14864. x.SetDataId,
  14865. x.Cost,
  14866. x.Currency,
  14867. x.SubTotal,
  14868. x.Remark
  14869. })
  14870. .WhereColumns(x => new { x.Id })
  14871. .ExecuteCommandAsync();
  14872. if (upd < 1) return Ok(JsonView(false));
  14873. }
  14874. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  14875. //消息通知
  14876. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  14877. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14878. return Ok(JsonView(new { itemTotal = itemTotal }));
  14879. }
  14880. /// <summary>
  14881. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  14882. /// </summary>
  14883. /// <returns></returns>
  14884. [HttpPost]
  14885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14886. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  14887. {
  14888. int subId = dto.SubId, id = dto.DraftId;
  14889. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14890. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  14891. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14892. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  14893. subInfo.Id = subId;
  14894. subInfo.ParentId = id;
  14895. subInfo.CreateUserId = dto.CurrUserId;
  14896. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  14897. if (parentId < 1) return Ok(JsonView(false));
  14898. #region 子表op
  14899. if (subId < 1)//add
  14900. {
  14901. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  14902. if (subAdd < 1) return Ok(JsonView(false));
  14903. }
  14904. else //upd
  14905. {
  14906. var subUpd = await _sqlSugar.Updateable(subInfo)
  14907. .UpdateColumns(x => new
  14908. {
  14909. x.Index,
  14910. x.SetDataId,
  14911. x.Cost,
  14912. x.Currency,
  14913. x.SubTotal,
  14914. x.Remark
  14915. })
  14916. .WhereColumns(x => new { x.Id })
  14917. .ExecuteCommandAsync();
  14918. if (subUpd < 1) return Ok(JsonView(false));
  14919. }
  14920. #endregion
  14921. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  14922. ////消息通知
  14923. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  14924. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  14925. }
  14926. /// <summary>
  14927. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  14928. /// </summary>
  14929. /// <returns></returns>
  14930. [HttpPost]
  14931. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14932. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  14933. {
  14934. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  14935. if (data.Code != 0)
  14936. {
  14937. return Ok(JsonView(false, data.Msg));
  14938. }
  14939. return Ok(JsonView(true, "操作成功!", data.Data));
  14940. }
  14941. /// <summary>
  14942. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  14943. /// </summary>
  14944. /// <param name="dto"></param>
  14945. /// <returns></returns>
  14946. [HttpPost]
  14947. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  14948. {
  14949. var data = new Grp_DayOtherPriceDraft()
  14950. {
  14951. Id = dto.Id,
  14952. IsDel = 1,
  14953. DeleteUserId = dto.DeleteUserId,
  14954. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  14955. };
  14956. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  14957. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  14958. return Ok(JsonView(false, "删除失败!"));
  14959. }
  14960. #endregion
  14961. #endregion
  14962. #region 团组经理模块 出入境费用报价表
  14963. /// <summary>
  14964. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  14965. /// </summary>
  14966. /// <returns></returns>
  14967. [HttpPost]
  14968. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14969. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  14970. {
  14971. var initRates = await GeneralMethod.EnterExitCostInitRate();
  14972. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  14973. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  14974. initRates.Insert(0, cnyInfo);
  14975. liveRates.Insert(0, cnyInfo);
  14976. return Ok(JsonView(true, "查询成功!", new
  14977. {
  14978. InitRates = initRates,
  14979. LiveRates = liveRates
  14980. }));
  14981. }
  14982. /// <summary>
  14983. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  14984. /// </summary>
  14985. /// <returns></returns>
  14986. [HttpPost]
  14987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14988. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  14989. {
  14990. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  14991. }
  14992. /// <summary>
  14993. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  14994. /// </summary>
  14995. /// <returns></returns>
  14996. [HttpPost]
  14997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14998. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  14999. {
  15000. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  15001. }
  15002. /// <summary>
  15003. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  15004. /// </summary>
  15005. /// <returns></returns>
  15006. [HttpPost]
  15007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15008. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  15009. {
  15010. int groupId = dto.DiId,
  15011. currUserId = dto.CurrUserId;
  15012. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  15013. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  15014. //验证报价数据是否存在
  15015. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  15016. if (isNull != null)
  15017. {
  15018. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  15019. if (!info1.Rates.Any())
  15020. {
  15021. var rates = await GeneralMethod.EnterExitCostInitRate();
  15022. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15023. info1.Rates = rates.ToArray();
  15024. }
  15025. return Ok(JsonView(info1));
  15026. }
  15027. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  15028. result.GroupId = groupId;
  15029. //处理报价名称
  15030. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  15031. if (groupInfo != null)
  15032. {
  15033. var visitCountry = groupInfo.VisitCountry;
  15034. if (!string.IsNullOrEmpty(visitCountry))
  15035. {
  15036. string quoteName = string.Empty;
  15037. if (visitCountry.Contains("|"))
  15038. {
  15039. var countrys = visitCountry.Split("|");
  15040. quoteName = string.Join("、", countrys);
  15041. }
  15042. else quoteName = visitCountry;
  15043. quoteName += $"团组报价表";
  15044. result.Name = quoteName;
  15045. }
  15046. }
  15047. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  15048. if (info.Code != StatusCodes.Status200OK)
  15049. {
  15050. if (!result.Rates.Any())
  15051. {
  15052. var rates = await GeneralMethod.EnterExitCostInitRate();
  15053. result.Rates = rates.ToArray();
  15054. }
  15055. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  15056. }
  15057. var infoView = info.Data as EnterExitCostInfoView;
  15058. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  15059. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  15060. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  15061. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  15062. var eecRates = infoView.Currencys;
  15063. //默认添加人名币
  15064. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  15065. {
  15066. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15067. }
  15068. //处理团组人数
  15069. int pplNum = 1;
  15070. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  15071. var views = new List<QuoteSubItemInfo>();
  15072. #region 数据填充
  15073. var intTravelCosts = new List<QuoteSubItemInfo>();
  15074. #region 机票费用 1354
  15075. int intTravelIndex = 1;
  15076. if (infoView.SumJJC == 1)
  15077. {
  15078. intTravelCosts.Add(new QuoteSubItemInfo
  15079. {
  15080. ItemId = 1354,
  15081. Index = intTravelIndex,
  15082. FeeName = "经济舱",
  15083. UnitPrice = infoView.AirJJ,
  15084. Currency = "CNY",
  15085. Quantity = 1,
  15086. PplNum = 1,
  15087. TotalAmt = infoView.AirJJ,
  15088. Remark = "",
  15089. });
  15090. intTravelIndex++;
  15091. }
  15092. if (infoView.SumGWC == 1)
  15093. {
  15094. intTravelCosts.Add(new QuoteSubItemInfo
  15095. {
  15096. ItemId = 1354,
  15097. Index = intTravelIndex,
  15098. FeeName = "公务舱",
  15099. UnitPrice = infoView.AirGW,
  15100. Currency = "CNY",
  15101. Quantity = 1,
  15102. PplNum = 1,
  15103. TotalAmt = infoView.AirGW,
  15104. Remark = "",
  15105. });
  15106. intTravelIndex++;
  15107. }
  15108. if (infoView.SumTDC == 1)
  15109. {
  15110. intTravelCosts.Add(new QuoteSubItemInfo
  15111. {
  15112. ItemId = 1354,
  15113. Index = intTravelIndex,
  15114. FeeName = "头等舱",
  15115. UnitPrice = infoView.AirTD,
  15116. Currency = "CNY",
  15117. Quantity = 1,
  15118. PplNum = 1,
  15119. TotalAmt = infoView.AirTD,
  15120. Remark = "",
  15121. });
  15122. intTravelIndex++;
  15123. }
  15124. intTravelCosts.Add(new QuoteSubItemInfo
  15125. {
  15126. ItemId = 1354,
  15127. Index = intTravelIndex,
  15128. FeeName = "城市间交通费用(经济舱)",
  15129. UnitPrice = infoView.CityTranffic,
  15130. Currency = "CNY",
  15131. Quantity = 1,
  15132. PplNum = pplNum,
  15133. TotalAmt = infoView.CityTranffic * pplNum,
  15134. Remark = "",
  15135. });
  15136. intTravelCosts.Add(new QuoteSubItemInfo
  15137. {
  15138. ItemId = 1354,
  15139. Index = intTravelIndex,
  15140. FeeName = "城市间交通费用(公务舱)",
  15141. UnitPrice = infoView.CityTranffic1,
  15142. Currency = "CNY",
  15143. Quantity = 1,
  15144. PplNum = pplNum,
  15145. TotalAmt = infoView.CityTranffic1 * pplNum,
  15146. Remark = "",
  15147. });
  15148. intTravelCosts.Add(new QuoteSubItemInfo
  15149. {
  15150. ItemId = 1354,
  15151. Index = intTravelIndex,
  15152. FeeName = "城市间交通费用(头等舱)",
  15153. UnitPrice = infoView.CityTranffic2,
  15154. Currency = "CNY",
  15155. Quantity = 1,
  15156. PplNum = pplNum,
  15157. TotalAmt = infoView.CityTranffic2 * pplNum,
  15158. Remark = "",
  15159. });
  15160. views.AddRange(intTravelCosts);
  15161. #endregion
  15162. var accomCosts = new List<QuoteSubItemInfo>();
  15163. #region 住宿费 1355
  15164. if (infoView.QuarterageData.Any())
  15165. {
  15166. int accomIndex = 1;
  15167. int accomItemTypeId = 1355;
  15168. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  15169. foreach (var item in groupData)
  15170. {
  15171. string feeName = string.Empty;
  15172. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  15173. if (countryInfo != null)
  15174. {
  15175. feeName = countryInfo.Country;
  15176. var city = countryInfo.City;
  15177. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  15178. {
  15179. feeName += $"-{city}";
  15180. }
  15181. }
  15182. var hotelInfo = item.FirstOrDefault();
  15183. if (hotelInfo == null) continue;
  15184. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  15185. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  15186. int quantity = item.ToList().Count;
  15187. accomCosts.Add(new QuoteSubItemInfo
  15188. {
  15189. ItemId = accomItemTypeId,
  15190. Index = accomIndex,
  15191. FeeName = feeName,
  15192. UnitPrice = hotelInfo.Cost,
  15193. Currency = thisCurrency,
  15194. Quantity = quantity,
  15195. PplNum = pplNum,
  15196. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  15197. Remark = "",
  15198. });
  15199. accomIndex++;
  15200. }
  15201. views.AddRange(accomCosts);
  15202. }
  15203. #endregion
  15204. var mealCosts = new List<QuoteSubItemInfo>();
  15205. #region 餐饮费 1356
  15206. if (infoView.BoardWagesData.Any())
  15207. {
  15208. var mealIndex = 1;
  15209. int mealItemTypeId = 1356;
  15210. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  15211. foreach (var item in groupData)
  15212. {
  15213. string feeName = string.Empty;
  15214. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  15215. if (countryInfo != null)
  15216. {
  15217. feeName = countryInfo.Country;
  15218. var city = countryInfo.City;
  15219. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  15220. {
  15221. feeName += $"-{city}";
  15222. }
  15223. }
  15224. var mealInfo = item.FirstOrDefault();
  15225. if (mealInfo == null) continue;
  15226. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  15227. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  15228. int quantity = item.ToList().Count;
  15229. mealCosts.Add(new QuoteSubItemInfo
  15230. {
  15231. ItemId = mealItemTypeId,
  15232. Index = mealIndex,
  15233. FeeName = feeName,
  15234. UnitPrice = mealInfo.Cost,
  15235. Currency = thisCurrency,
  15236. Quantity = quantity,
  15237. PplNum = pplNum,
  15238. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  15239. Remark = "",
  15240. });
  15241. mealIndex++;
  15242. }
  15243. views.AddRange(mealCosts);
  15244. }
  15245. #endregion
  15246. var miscCosts = new List<QuoteSubItemInfo>();
  15247. #region 公杂费 1364
  15248. if (infoView.MiscellaneousFeeData.Any())
  15249. {
  15250. var miscIndex = 1;
  15251. int miscItemTypeId = 1364;
  15252. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  15253. foreach (var item in groupData)
  15254. {
  15255. string feeName = string.Empty;
  15256. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  15257. if (countryInfo != null)
  15258. {
  15259. feeName = countryInfo.Country;
  15260. var city = countryInfo.City;
  15261. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  15262. {
  15263. feeName += $"-{city}";
  15264. }
  15265. }
  15266. var miscInfo = item.FirstOrDefault();
  15267. if (miscInfo == null) continue;
  15268. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  15269. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  15270. int quantity = item.ToList().Count;
  15271. miscCosts.Add(new QuoteSubItemInfo
  15272. {
  15273. ItemId = miscItemTypeId,
  15274. Index = miscIndex,
  15275. FeeName = feeName,
  15276. UnitPrice = miscInfo.Cost,
  15277. Currency = thisCurrency,
  15278. Quantity = quantity,
  15279. PplNum = pplNum,
  15280. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  15281. Remark = "",
  15282. });
  15283. miscIndex++;
  15284. }
  15285. views.AddRange(miscCosts);
  15286. }
  15287. #endregion
  15288. #region 签证+保险 1362
  15289. int visaInsIndex = 1;
  15290. int visaInsItemTypeId = 1362;
  15291. if (infoView.Visa > 0)
  15292. {
  15293. views.Add(new QuoteSubItemInfo()
  15294. {
  15295. ItemId = visaInsItemTypeId,
  15296. Index = visaInsIndex,
  15297. FeeName = $"签证",
  15298. UnitPrice = infoView.Visa,
  15299. Currency = $"CNY",
  15300. Quantity = 1,
  15301. PplNum = pplNum,
  15302. TotalAmt = infoView.Visa * pplNum,
  15303. Remark = "",
  15304. });
  15305. visaInsIndex++;
  15306. }
  15307. if (infoView.Safe > 0)
  15308. {
  15309. views.Add(new QuoteSubItemInfo()
  15310. {
  15311. ItemId = visaInsItemTypeId,
  15312. Index = visaInsIndex,
  15313. FeeName = $"保险",
  15314. UnitPrice = infoView.Safe,
  15315. Currency = $"CNY",
  15316. Quantity = 1,
  15317. PplNum = pplNum,
  15318. TotalAmt = infoView.Safe * pplNum,
  15319. Remark = "",
  15320. });
  15321. }
  15322. #endregion
  15323. #region 服务费 1363
  15324. int serviceFeeIndex = 1;
  15325. int serviceFeeItemTypeId = 1363;
  15326. if (infoView.Service > 0)
  15327. {
  15328. views.Add(new QuoteSubItemInfo()
  15329. {
  15330. ItemId = serviceFeeItemTypeId,
  15331. Index = serviceFeeIndex,
  15332. FeeName = $"服务费",
  15333. UnitPrice = infoView.Service,
  15334. Currency = $"CNY",
  15335. Quantity = 1,
  15336. PplNum = pplNum,
  15337. TotalAmt = infoView.Service * pplNum,
  15338. Remark = "",
  15339. });
  15340. }
  15341. #endregion
  15342. #endregion
  15343. if (result.FeeItems.Any())
  15344. {
  15345. result.FeeItems.Select(x =>
  15346. {
  15347. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  15348. if (feeInfos.Any()) x.Infos = feeInfos;
  15349. return x;
  15350. }
  15351. ).OrderBy(x => x.Index)
  15352. .ToList();
  15353. if (!result.Rates.Any())
  15354. {
  15355. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  15356. else
  15357. {
  15358. var rates = await GeneralMethod.EnterExitCostInitRate();
  15359. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15360. result.Rates = rates.ToArray();
  15361. }
  15362. }
  15363. }
  15364. return Ok(JsonView(result));
  15365. }
  15366. /// <summary>
  15367. /// 团组模块 - 出入境费用报价表 - Info
  15368. /// </summary>
  15369. /// <returns></returns>
  15370. [HttpPost]
  15371. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15372. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  15373. {
  15374. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  15375. if (!info.Rates.Any())
  15376. {
  15377. var rates = await GeneralMethod.EnterExitCostInitRate();
  15378. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15379. info.Rates = rates.ToArray();
  15380. }
  15381. return Ok(JsonView(info));
  15382. }
  15383. /// <summary>
  15384. /// 团组模块 - 出入境费用报价表 - OP
  15385. /// </summary>
  15386. /// <returns></returns>
  15387. [HttpPost]
  15388. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15389. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  15390. {
  15391. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  15392. }
  15393. /// <summary>
  15394. /// 团组模块 - 出入境费用报价表 - 删除 项
  15395. /// </summary>
  15396. /// <returns></returns>
  15397. [HttpPost]
  15398. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15399. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  15400. {
  15401. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  15402. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15403. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  15404. }
  15405. /// <summary>
  15406. /// 团组模块 - 出入境费用报价表 - 导出
  15407. /// </summary>
  15408. /// <returns></returns>
  15409. [HttpPost]
  15410. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15411. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  15412. {
  15413. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  15414. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15415. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  15416. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  15417. var rates = info.Rates;
  15418. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  15419. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  15420. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  15421. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  15422. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  15423. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  15424. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  15425. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  15426. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  15427. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  15428. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  15429. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  15430. //获取模板
  15431. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  15432. var designer = new WorkbookDesigner();
  15433. designer.Workbook = new Workbook(tempPath);
  15434. designer.SetDataSource("QuoteName", info.Name);
  15435. designer.SetDataSource("CompanyTitle", "公司名称");
  15436. designer.SetDataSource("CompanyLabel", "");
  15437. #region 国际旅费
  15438. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  15439. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  15440. {
  15441. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  15442. var label = new StringBuilder();
  15443. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  15444. if (infos.Any())
  15445. {
  15446. label.Append(infos.Sum(x => x.PplNum));
  15447. label.Append("人全程机票:");
  15448. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  15449. label.AppendLine("元");
  15450. }
  15451. foreach (var item in intTravelCosts.Infos)
  15452. {
  15453. label.Append(item.FeeName);
  15454. label.Append(":");
  15455. label.Append(item.UnitPrice.TruncDecimals(2));
  15456. label.Append("元/人*");
  15457. label.Append(item.PplNum);
  15458. label.AppendLine("人");
  15459. }
  15460. if (label.HasValue())
  15461. {
  15462. label.Append("\r\n以上小计:");
  15463. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  15464. label.Append("元");
  15465. }
  15466. designer.SetDataSource("IntTravelLabel", label.ToString());
  15467. }
  15468. #endregion
  15469. #region 住宿费
  15470. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  15471. if (accomCosts != null && accomCosts.Infos.Any())
  15472. {
  15473. string currencyName = string.Empty,
  15474. countryName = string.Empty;
  15475. decimal rate = 1.0000M;
  15476. var label = new StringBuilder();
  15477. label.AppendLine("全程五星酒店,每人1间房");
  15478. foreach (var item in accomCosts.Infos)
  15479. {
  15480. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  15481. string name = string.Empty, thisCountryName = string.Empty;
  15482. if (item.FeeName.Contains('-'))
  15483. {
  15484. var feeName = item.FeeName.Split('-');
  15485. thisCountryName = feeName[0];
  15486. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  15487. name = feeName[1];
  15488. }
  15489. else name = item.FeeName;
  15490. string thisFeeName = string.Empty;
  15491. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  15492. else thisFeeName = $"\r\n{name}:";
  15493. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  15494. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  15495. rate = rateInfo?.Rate ?? 1.0000M;
  15496. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  15497. label.AppendLine(subLabel);
  15498. }
  15499. if (label.HasValue())
  15500. {
  15501. //以上小计:52440元(美金汇率:7.5 )
  15502. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  15503. label.AppendLine(subLabel);
  15504. }
  15505. designer.SetDataSource("AccomLabel", label.ToString());
  15506. }
  15507. #endregion
  15508. #region 餐饮费
  15509. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  15510. if (mealCosts != null && mealCosts.Infos.Any())
  15511. {
  15512. string currencyName = string.Empty;
  15513. decimal rate = 1.0000M;
  15514. var label = new StringBuilder();
  15515. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  15516. foreach (var item in mealCosts.Infos)
  15517. {
  15518. string name = string.Empty;
  15519. if (item.FeeName.Contains('-'))
  15520. {
  15521. var feeName = item.FeeName.Split('-');
  15522. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  15523. }
  15524. else name = $"\r\n{item.FeeName}:";
  15525. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  15526. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  15527. rate = rateInfo?.Rate ?? 1.0000M;
  15528. label.Append(name);
  15529. label.Append(item.UnitPrice.TruncDecimals(2));
  15530. label.Append(currencyName);
  15531. label.Append("/天*");
  15532. label.Append(item.Quantity.ToString("#0"));
  15533. label.Append('*');
  15534. label.Append(item.PplNum);
  15535. label.Append("人\r\n");
  15536. }
  15537. if (label.HasValue())
  15538. {
  15539. label.Append("\r\n以上小计:");
  15540. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  15541. label.Append("元\r\n(");
  15542. label.Append("汇率:");
  15543. label.Append(rate.TruncDecimals(4));
  15544. label.Append(')');
  15545. }
  15546. designer.SetDataSource("MealLabel", label.ToString());
  15547. }
  15548. #endregion
  15549. #region 车辆安排
  15550. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  15551. if (vehArranges != null && vehArranges.Infos.Any())
  15552. {
  15553. string currencyName = string.Empty;
  15554. //decimal rate = 1.0000M;
  15555. var label = new StringBuilder();
  15556. foreach (var item in vehArranges.Infos)
  15557. {
  15558. label.AppendLine();
  15559. label.AppendLine();
  15560. label.Append(item.FeeName);
  15561. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  15562. }
  15563. designer.SetDataSource("VehArrangeLabel", label.ToString());
  15564. }
  15565. #endregion
  15566. #region 邀请函发放对象
  15567. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  15568. designer.SetDataSource("InviteToContent", "");
  15569. #endregion
  15570. #region 邀请函费
  15571. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  15572. var is_label = new StringBuilder();
  15573. if (inviteCosts != null && inviteCosts.Infos.Any())
  15574. {
  15575. string currencyName = string.Empty;
  15576. decimal rate = 1.0000M;
  15577. foreach (var item in inviteCosts.Infos)
  15578. {
  15579. //乌兹别克斯坦:2000美金
  15580. currencyName = item.Currency;
  15581. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  15582. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  15583. is_label.AppendLine(label);
  15584. }
  15585. if (is_label.HasValue())
  15586. {
  15587. //以上小计:28500元(美金汇率:7.5)
  15588. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  15589. is_label.AppendLine(label);
  15590. }
  15591. }
  15592. designer.SetDataSource("InviteCostContent", is_label.ToString());
  15593. #endregion
  15594. #region 邀请函发放时间
  15595. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  15596. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  15597. #endregion
  15598. #region 公务活动(含翻译)
  15599. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  15600. var oa_label = new StringBuilder();
  15601. if (officialActs != null && officialActs.Infos.Any())
  15602. {
  15603. string currencyName = string.Empty;
  15604. decimal rate = 1.0000M;
  15605. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  15606. foreach (var item in officialActs.Infos)
  15607. {
  15608. //乌兹别克斯坦:1000美金/场
  15609. currencyName = item.Currency;
  15610. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  15611. string label_remark = string.Empty;
  15612. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  15613. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  15614. }
  15615. label_content += "*总费用中未含超出公务活动价格";
  15616. //8场公务活动(以上小计:60000元)
  15617. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  15618. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  15619. oa_label.AppendLine(label_title);
  15620. oa_label.AppendLine(label_content);
  15621. }
  15622. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  15623. #endregion
  15624. #region 签证+保险
  15625. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  15626. var vi_label = new StringBuilder();
  15627. if (visaIns != null && visaIns.Infos.Any())
  15628. {
  15629. foreach (var item in visaIns.Infos)
  15630. {
  15631. //签证:500元/人
  15632. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  15633. vi_label.AppendLine(label);
  15634. }
  15635. if (vi_label.HasValue())
  15636. {
  15637. //以上小计:6000元
  15638. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  15639. vi_label.AppendLine(label);
  15640. }
  15641. }
  15642. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  15643. #endregion
  15644. #region 服务费
  15645. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  15646. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  15647. #endregion
  15648. #region 公杂费
  15649. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  15650. var pm_label = new StringBuilder();
  15651. if (pubMiscs != null && pubMiscs.Infos.Any())
  15652. {
  15653. string currencyName = string.Empty,
  15654. countryName = string.Empty;
  15655. decimal rate = 1.0000M;
  15656. foreach (var item in pubMiscs.Infos)
  15657. {
  15658. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  15659. string name = string.Empty, thisCountryName = string.Empty;
  15660. if (item.FeeName.Contains('-'))
  15661. {
  15662. var feeName = item.FeeName.Split('-');
  15663. thisCountryName = feeName[0];
  15664. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  15665. name = feeName[1];
  15666. }
  15667. else name = item.FeeName;
  15668. string thisFeeName = string.Empty;
  15669. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  15670. else thisFeeName = $"\r\n{name}:";
  15671. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  15672. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  15673. rate = rateInfo?.Rate ?? 1.0000M;
  15674. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  15675. pm_label.AppendLine(label);
  15676. }
  15677. if (pm_label.HasValue())
  15678. {
  15679. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  15680. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  15681. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  15682. pm_label.AppendLine(string.Format("部分发放成员"));
  15683. }
  15684. }
  15685. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  15686. #endregion
  15687. #region 税费
  15688. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  15689. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  15690. #endregion
  15691. #region 合计(单位:元)
  15692. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  15693. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  15694. #endregion
  15695. #region 汇率 Remark
  15696. var rate_label = new StringBuilder();
  15697. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  15698. foreach (var item in rateGroups)
  15699. {
  15700. //美元汇率按\r\n1:7.5
  15701. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  15702. rate_label.AppendLine(label);
  15703. }
  15704. designer.SetDataSource("RateLabel", rate_label.ToString());
  15705. #endregion
  15706. designer.Process();
  15707. //文件名
  15708. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  15709. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  15710. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  15711. return Ok(JsonView(true, "成功", url));
  15712. }
  15713. #endregion
  15714. #region 签证费用录入
  15715. /// <summary>
  15716. /// 根据diid查询签证费用列表
  15717. /// </summary>
  15718. /// <param name="dto"></param>
  15719. /// <returns></returns>
  15720. [HttpPost]
  15721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15722. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  15723. {
  15724. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  15725. if (groupData.Code != 0)
  15726. {
  15727. return Ok(JsonView(false, groupData.Msg));
  15728. }
  15729. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15730. }
  15731. /// <summary>
  15732. /// 根据签证费用Id查询单条数据及c表数据
  15733. /// </summary>
  15734. /// <param name="dto"></param>
  15735. /// <returns></returns>
  15736. [HttpPost]
  15737. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15738. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  15739. {
  15740. Result groupData = await _visaPriceRep.PostVisaById(dto);
  15741. if (groupData.Code != 0)
  15742. {
  15743. return Ok(JsonView(false, groupData.Msg));
  15744. }
  15745. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15746. }
  15747. /// <summary>
  15748. /// 签证费用删除
  15749. /// </summary>
  15750. /// <param name="dto"></param>
  15751. /// <returns></returns>
  15752. [HttpPost]
  15753. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15754. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  15755. {
  15756. _sqlSugar.BeginTran();
  15757. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  15758. if (!res)
  15759. {
  15760. _sqlSugar.RollbackTran();
  15761. return Ok(JsonView(false, "删除失败"));
  15762. }
  15763. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  15764. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  15765. .SetColumns(a => new Grp_CreditCardPayment()
  15766. {
  15767. IsDel = 1,
  15768. DeleteUserId = dto.DeleteUserId,
  15769. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15770. })
  15771. .ExecuteCommand();
  15772. if (resSub < 1)
  15773. {
  15774. _sqlSugar.RollbackTran();
  15775. return Ok(JsonView(false, "删除失败"));
  15776. }
  15777. _sqlSugar.CommitTran();
  15778. return Ok(JsonView(true, "删除成功!"));
  15779. }
  15780. /// <summary>
  15781. /// 签证费用录入下拉框初始化
  15782. /// </summary>
  15783. /// <returns></returns>
  15784. [HttpPost]
  15785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15786. public async Task<IActionResult> VisaPriceAddSelect()
  15787. {
  15788. //支付方式
  15789. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  15790. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  15791. //币种
  15792. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  15793. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  15794. //乘客类型
  15795. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  15796. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  15797. //卡类型
  15798. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  15799. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  15800. //代办费类型
  15801. var agencyFeeTypeData = new List<dynamic>() {
  15802. new { id = 0 , Text = "未选择" },
  15803. new { id = 1 , Text = "小公务" },
  15804. new { id = 2 , Text = "大公务" },
  15805. };
  15806. //签证费用标准国家Data
  15807. var visaSql = string.Format(@"select
  15808. id,
  15809. case
  15810. when FeeType = 0 then Country+'(因公)'
  15811. when FeeType = 1 then Country+'(因私)'
  15812. else Country+'(未设置)'
  15813. end as 'country'
  15814. from Res_VisaFeeStandard where isdel = 0");
  15815. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  15816. var data = new
  15817. {
  15818. Payment = _Payment,
  15819. CurrencyList = _CurrencyList,
  15820. PassengerType = _PassengerType,
  15821. BankCard = _BankCard,
  15822. AgencyFeeType = agencyFeeTypeData,
  15823. CountryFeeData = visaCountryFeeData
  15824. };
  15825. return Ok(JsonView(true, "查询成功!", data));
  15826. }
  15827. /// <summary>
  15828. /// 签证费用录入操作(Status:1.新增,2.修改)
  15829. /// </summary>
  15830. /// <param name="dto"></param>
  15831. /// <returns></returns>
  15832. [HttpPost]
  15833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15834. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  15835. {
  15836. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  15837. if (groupData.Code != 0)
  15838. {
  15839. return Ok(JsonView(false, groupData.Msg));
  15840. }
  15841. #region 应用推送
  15842. try
  15843. {
  15844. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15845. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15846. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15847. //2024-10-21 新增LZ UID
  15848. var userIds = new List<int>() { 21 };
  15849. string title = $"系统通知";
  15850. string content = "";
  15851. var diId = dto.DiId;
  15852. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15853. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15854. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  15855. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  15856. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15857. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  15858. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15859. }
  15860. catch (Exception ex)
  15861. {
  15862. }
  15863. #endregion
  15864. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15865. }
  15866. #endregion
  15867. #region 签证提成录入
  15868. /// <summary>
  15869. /// 签证提成录入
  15870. /// 基础数据
  15871. /// </summary>
  15872. /// <returns></returns>
  15873. [HttpGet]
  15874. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15875. public async Task<IActionResult> VisaCommissionInit()
  15876. {
  15877. return Ok(await _visaCommissionRep.Init());
  15878. }
  15879. /// <summary>
  15880. /// 签证提成录入
  15881. /// Item
  15882. /// </summary>
  15883. /// <param name="_dto"></param>
  15884. /// <returns></returns>
  15885. [HttpPost]
  15886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15887. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  15888. {
  15889. var validator = new VisaCommissionItemDtoValidator();
  15890. var validatorRes = await validator.ValidateAsync(_dto);
  15891. if (!validatorRes.IsValid)
  15892. {
  15893. var sb = new StringBuilder();
  15894. foreach (var item in validatorRes.Errors)
  15895. {
  15896. sb.AppendLine(item.ErrorMessage);
  15897. }
  15898. return Ok(JsonView(false, sb.ToString()));
  15899. }
  15900. return Ok(await _visaCommissionRep.Item(_dto));
  15901. }
  15902. /// <summary>
  15903. /// 签证提成录入
  15904. /// Save
  15905. /// </summary>
  15906. /// <param name="_dto"></param>
  15907. /// <returns></returns>
  15908. [HttpPost]
  15909. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15910. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  15911. {
  15912. //参数验证
  15913. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  15914. foreach (var item in _dto.Items)
  15915. {
  15916. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  15917. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  15918. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  15919. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  15920. }
  15921. return Ok(await _visaCommissionRep.Save(_dto));
  15922. }
  15923. /// <summary>
  15924. /// 签证提成录入
  15925. /// Create
  15926. /// </summary>
  15927. /// <param name="_dto"></param>
  15928. /// <returns></returns>
  15929. [HttpPost]
  15930. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15931. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  15932. {
  15933. var validator = new VisaCommissionCreateDtoValidator();
  15934. var validatorRes = await validator.ValidateAsync(_dto);
  15935. if (!validatorRes.IsValid)
  15936. {
  15937. var sb = new StringBuilder();
  15938. foreach (var item in validatorRes.Errors)
  15939. {
  15940. sb.AppendLine(item.ErrorMessage);
  15941. }
  15942. return Ok(JsonView(false, sb.ToString()));
  15943. }
  15944. return Ok(await _visaCommissionRep.Create(_dto));
  15945. }
  15946. /// <summary>
  15947. /// 签证提成录入
  15948. /// Put(编辑)
  15949. /// </summary>
  15950. /// <param name="id"></param>
  15951. /// <param name="_dto"></param>
  15952. /// <returns></returns>
  15953. [HttpPut]
  15954. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15955. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  15956. {
  15957. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  15958. var validator = new VisaCommissionCreateDtoValidator();
  15959. var validatorRes = await validator.ValidateAsync(_dto);
  15960. if (!validatorRes.IsValid)
  15961. {
  15962. var sb = new StringBuilder();
  15963. foreach (var item in validatorRes.Errors)
  15964. {
  15965. sb.AppendLine(item.ErrorMessage);
  15966. }
  15967. return Ok(JsonView(false, sb.ToString()));
  15968. }
  15969. return Ok(await _visaCommissionRep.Edit(id, _dto));
  15970. }
  15971. /// <summary>
  15972. /// 签证提成录入
  15973. /// Del
  15974. /// </summary>
  15975. /// <param name="id"></param>
  15976. /// <param name="currUserId"></param>
  15977. /// <returns></returns>
  15978. [HttpPost]
  15979. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15980. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  15981. {
  15982. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  15983. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  15984. return Ok(await _visaCommissionRep.Del(id, currUserId));
  15985. }
  15986. #endregion
  15987. #region op费用录入
  15988. /// <summary>
  15989. /// 根据diid查询op费用列表
  15990. /// </summary>
  15991. /// <param name="dto"></param>
  15992. /// <returns></returns>
  15993. [HttpPost]
  15994. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15995. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  15996. {
  15997. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  15998. if (groupData.Code != 0)
  15999. {
  16000. return Ok(JsonView(false, groupData.Msg));
  16001. }
  16002. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16003. }
  16004. /// <summary>
  16005. /// 根据op费用Id查询单条数据及c表数据
  16006. /// </summary>
  16007. /// <param name="dto"></param>
  16008. /// <returns></returns>
  16009. [HttpPost]
  16010. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16011. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  16012. {
  16013. try
  16014. {
  16015. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  16016. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  16017. var data = new
  16018. {
  16019. CarTouristGuideGround = _groupData,
  16020. CreditCardPayment = _creditCardPayment
  16021. };
  16022. return Ok(JsonView(true, "查询成功!", data));
  16023. }
  16024. catch (Exception ex)
  16025. {
  16026. return Ok(JsonView(false, "程序错误!"));
  16027. }
  16028. }
  16029. /// <summary>
  16030. /// op费用删除
  16031. /// </summary>
  16032. /// <param name="dto"></param>
  16033. /// <returns></returns>
  16034. [HttpPost]
  16035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16036. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  16037. {
  16038. try
  16039. {
  16040. _sqlSugar.BeginTran();
  16041. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  16042. if (!res)
  16043. {
  16044. return Ok(JsonView(false, "删除失败"));
  16045. }
  16046. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  16047. {
  16048. IsDel = 1,
  16049. DeleteUserId = dto.DeleteUserId,
  16050. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16051. }).ExecuteCommandAsync();
  16052. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  16053. {
  16054. IsDel = 1,
  16055. DeleteUserId = dto.DeleteUserId,
  16056. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16057. }).ExecuteCommandAsync();
  16058. #region 删除超支相关数据
  16059. //删除导入的超支数据
  16060. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  16061. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  16062. {
  16063. IsDel = 1,
  16064. DeleteUserId = dto.DeleteUserId,
  16065. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16066. }).ExecuteCommand();
  16067. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  16068. {
  16069. IsDel = 1,
  16070. DeleteUserId = dto.DeleteUserId,
  16071. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16072. }).ExecuteCommand();
  16073. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  16074. {
  16075. IsDel = 1,
  16076. DeleteUserId = dto.DeleteUserId,
  16077. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16078. }).ExecuteCommand();
  16079. #endregion
  16080. _sqlSugar.CommitTran();
  16081. return Ok(JsonView(true, "删除成功!"));
  16082. }
  16083. catch (Exception ex)
  16084. {
  16085. _sqlSugar.RollbackTran();
  16086. return Ok(JsonView(false, "程序错误!" + ex.Message));
  16087. }
  16088. }
  16089. /// <summary>
  16090. /// op费用录入操作(Status:1.新增,2.修改)
  16091. /// </summary>
  16092. /// <param name="dto"></param>
  16093. /// <returns></returns>
  16094. [HttpPost]
  16095. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16096. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  16097. {
  16098. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  16099. if (groupData.Code != 0)
  16100. {
  16101. return Ok(JsonView(false, groupData.Msg));
  16102. }
  16103. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16104. }
  16105. /// <summary>
  16106. /// 填写费用详细页面初始化绑定
  16107. /// </summary>
  16108. /// <param name="dto"></param>
  16109. /// <returns></returns>
  16110. [HttpPost]
  16111. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16112. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  16113. {
  16114. try
  16115. {
  16116. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  16117. if (groupData.Code != 0)
  16118. {
  16119. return Ok(JsonView(false, groupData.Msg));
  16120. }
  16121. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16122. }
  16123. catch (Exception ex)
  16124. {
  16125. return Ok(JsonView(false, ex.Message));
  16126. }
  16127. }
  16128. /// <summary>
  16129. /// 根据op费用Id查询详细数据
  16130. /// </summary>
  16131. /// <param name="dto"></param>
  16132. /// <returns></returns>
  16133. [HttpPost]
  16134. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16135. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  16136. {
  16137. try
  16138. {
  16139. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  16140. if (groupData.Code != 0)
  16141. {
  16142. return Ok(JsonView(false, groupData.Msg));
  16143. }
  16144. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16145. }
  16146. catch (Exception ex)
  16147. {
  16148. return Ok(JsonView(false, ex.Message));
  16149. }
  16150. }
  16151. /// <summary>
  16152. /// OP费用录入填写详情
  16153. /// </summary>
  16154. /// <param name="dto"></param>
  16155. /// <returns></returns>
  16156. [HttpPost]
  16157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16158. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  16159. {
  16160. try
  16161. {
  16162. #region 参数校验
  16163. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  16164. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  16165. if (di == null) return Ok(JsonView(false, "团组错误!"));
  16166. #endregion
  16167. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  16168. if (groupData.Code != 0)
  16169. {
  16170. return Ok(JsonView(false, groupData.Msg));
  16171. }
  16172. //自动审核
  16173. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  16174. #region 尾款自动审核
  16175. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  16176. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  16177. if (opinfos.PriceType == 1062)
  16178. {
  16179. var isAuto = false;
  16180. //找对应的首付款
  16181. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  16182. .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))
  16183. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  16184. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  16185. x.PriceType == 1061 && x.DiId == dto.DiId);
  16186. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  16187. {
  16188. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  16189. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  16190. //合计中排除城市税
  16191. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  16192. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  16193. .Sum(x => x.Price * x.Count);
  16194. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  16195. if (balance >= opinfos.ServiceQuotedPrice)
  16196. {
  16197. isAuto = true;
  16198. }
  16199. }
  16200. if (isAuto)
  16201. {
  16202. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  16203. .SetColumns(a => new Grp_CreditCardPayment
  16204. {
  16205. IsAuditGM = 3, //自动审核通过
  16206. AuditGMOperate = 4,
  16207. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16208. })
  16209. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  16210. .ExecuteCommand();
  16211. }
  16212. }
  16213. #endregion
  16214. #region 应用推送
  16215. try
  16216. {
  16217. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16218. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16219. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16220. //2024-10-21 新增LZ UID
  16221. var userIds = new List<int>() { 21 };
  16222. string title = $"系统通知";
  16223. var diId = dto.DiId;
  16224. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16225. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16226. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  16227. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16228. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  16229. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16230. }
  16231. catch (Exception ex)
  16232. {
  16233. }
  16234. #endregion
  16235. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16236. }
  16237. catch (Exception ex)
  16238. {
  16239. return Ok(JsonView(false, ex.Message));
  16240. }
  16241. }
  16242. /// <summary>
  16243. /// 获取三公详细所有城市
  16244. /// </summary>
  16245. /// <returns></returns>
  16246. [HttpGet]
  16247. public IActionResult OpCarCityResult()
  16248. {
  16249. var jw = JsonView(false);
  16250. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  16251. {
  16252. x.Id,
  16253. x.Country,
  16254. x.City,
  16255. }).ToList();
  16256. if (data.Count > 0)
  16257. {
  16258. jw = JsonView(true, "获取成功!", data);
  16259. }
  16260. else
  16261. {
  16262. jw.Msg = "城市数据为空!";
  16263. jw.Data = Array.Empty<string>();
  16264. }
  16265. return Ok(jw);
  16266. }
  16267. /// <summary>
  16268. /// 导出地接费用明细
  16269. /// </summary>
  16270. /// <param name="dto"></param>
  16271. /// <returns></returns>
  16272. [HttpPost]
  16273. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  16274. {
  16275. var jw = JsonView(false);
  16276. if (dto.Diid < 1)
  16277. {
  16278. jw.Msg = "请输入正确的diid!";
  16279. return Ok(jw);
  16280. }
  16281. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16282. if (group == null)
  16283. {
  16284. jw.Msg = "未找到团组信息!";
  16285. return Ok(jw);
  16286. }
  16287. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  16288. if (localGuideArr.Count == 0)
  16289. {
  16290. jw.Msg = "该团组暂无地接信息!";
  16291. return Ok(jw);
  16292. }
  16293. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  16294. var overspendSoure = new Dictionary<int, int>
  16295. {
  16296. { 91, 982 }, //车
  16297. { 92 , 1059} ,//导游
  16298. { 994 , 1073}, //翻译
  16299. { 988 , 1074 }, //早餐
  16300. { 93 , 1075 }, //午餐
  16301. { 989 , 1076 }, //晚餐
  16302. };
  16303. var Zips = new Dictionary<string, Stream>();
  16304. foreach (var groupArr in localGroup)
  16305. {
  16306. var keyValue = groupArr.Key;
  16307. if (int.TryParse(keyValue, out int cityid))
  16308. {
  16309. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  16310. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  16311. }
  16312. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  16313. foreach (var item in groupArr)
  16314. {
  16315. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  16316. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  16317. new Grp_CarTouristGuideGroundReservationsContentExtend
  16318. {
  16319. Count = a.Count,
  16320. CreateTime = a.CreateTime,
  16321. CreateUserId = a.CreateUserId,
  16322. CTGGRId = a.CTGGRId,
  16323. Currency = a.Currency,
  16324. DatePrice = a.DatePrice,
  16325. DeleteTime = a.DeleteTime,
  16326. DeleteUserId = a.DeleteUserId,
  16327. DiId = a.DiId,
  16328. Id = a.Id,
  16329. IsDel = a.IsDel,
  16330. Price = a.Price,
  16331. PriceContent = a.PriceContent,
  16332. Remark = a.Remark,
  16333. SId = a.SId,
  16334. SidName = b.Name,
  16335. Units = a.Units,
  16336. }
  16337. ).ToList();
  16338. if (content.Count > 0)
  16339. {
  16340. contentArr.Add(content);
  16341. }
  16342. }
  16343. //open excel
  16344. //set excel
  16345. //save excel
  16346. try
  16347. {
  16348. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  16349. IWorkbook workbook;
  16350. if (Path.GetExtension(filePath).ToLower() == ".xls")
  16351. {
  16352. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  16353. }
  16354. else
  16355. {
  16356. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  16357. }
  16358. ISheet sheet = workbook.GetSheetAt(0);
  16359. var rowStartIndex = 2;
  16360. var clounmCount = 10;
  16361. var initStyleRow = sheet.GetRow(2);
  16362. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  16363. //var overspendArrDetail =
  16364. var existsId = new List<CarCompare>();
  16365. var lastElem = arr.Last();
  16366. var thisSid = -1;
  16367. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  16368. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  16369. {
  16370. Name = "未知币种!",
  16371. Remark = "未知币种!",
  16372. };
  16373. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  16374. Action cloneRowFn = () =>
  16375. {
  16376. rowStartIndex++;
  16377. var cloneRow = sheet.CreateRow(rowStartIndex);
  16378. // 复制样式
  16379. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  16380. {
  16381. ICell sourceCell = initStyleRow.GetCell(i);
  16382. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  16383. // 确保单元格存在样式
  16384. if (sourceCell.CellStyle != null)
  16385. {
  16386. targetCell.CellStyle = sourceCell.CellStyle;
  16387. }
  16388. }
  16389. };
  16390. var mergeRow = () =>
  16391. {
  16392. for (int i = 2; i < sheet.LastRowNum; i++)
  16393. {
  16394. var row = sheet.GetRow(i);
  16395. var cellFirst = row.GetCell(0);
  16396. var thisIndex = i + 1;
  16397. while (thisIndex < sheet.LastRowNum)
  16398. {
  16399. var nextRow = sheet.GetRow(thisIndex);
  16400. var nextCellFirst = nextRow.GetCell(0);
  16401. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  16402. {
  16403. thisIndex++;
  16404. }
  16405. else
  16406. {
  16407. break;
  16408. }
  16409. }
  16410. thisIndex--;
  16411. if (thisIndex != i)
  16412. {
  16413. //合并row
  16414. var cellRangeAddress = new CellRangeAddress(
  16415. i, // 起始行索引(0-based)
  16416. thisIndex, // 结束行索引(0-based)
  16417. 0, // 起始列索引(0-based)
  16418. 0 // 结束列索引(0-based)
  16419. );
  16420. sheet.AddMergedRegion(cellRangeAddress);
  16421. i = thisIndex;
  16422. }
  16423. }
  16424. };
  16425. var chaoshiNumber = 0;
  16426. var totalNumber = 0.00M;
  16427. string lastStr = "";
  16428. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  16429. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  16430. {
  16431. b.IsAuditGM,
  16432. x.Id,
  16433. x.Area,
  16434. b.PayPercentage,
  16435. b.PayMoney,
  16436. }).ToList();
  16437. string yesPayment = "", noPayment = "";
  16438. foreach (var item in queryCarArrByCityAndDiid)
  16439. {
  16440. if (item.IsAuditGM == 1)
  16441. {
  16442. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  16443. }
  16444. else
  16445. {
  16446. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  16447. }
  16448. }
  16449. lastStr = yesPayment + noPayment;
  16450. foreach (var item in arr)
  16451. {
  16452. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  16453. {
  16454. if (thisSid != item.SId)
  16455. {
  16456. if (thisSid == -1)
  16457. {
  16458. thisSid = item.SId;
  16459. }
  16460. else
  16461. {
  16462. //合并小计行
  16463. //创建合并区域的实例
  16464. var cellRangeAddress = new CellRangeAddress(
  16465. rowStartIndex, // 起始行索引(0-based)
  16466. rowStartIndex, // 结束行索引(0-based)
  16467. 0, // 起始列索引(0-based)
  16468. 3 // 结束列索引(0-based)
  16469. );
  16470. sheet.AddMergedRegion(cellRangeAddress);
  16471. var CellStyle = workbook.CreateCellStyle();
  16472. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16473. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  16474. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  16475. for (int i = 0; i <= clounmCount; i++)
  16476. {
  16477. if (i > 6)
  16478. {
  16479. var CellStyle1 = workbook.CreateCellStyle();
  16480. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16481. IFont Font = workbook.CreateFont(); // 创建字体
  16482. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  16483. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  16484. CellStyle1.SetFont(Font);
  16485. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  16486. }
  16487. else
  16488. {
  16489. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  16490. }
  16491. }
  16492. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  16493. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  16494. //超时合计
  16495. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  16496. //超时数
  16497. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  16498. //超时合计费用
  16499. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  16500. thisSid = item.SId;
  16501. cloneRowFn();
  16502. chaoshiNumber = 0;
  16503. totalNumber = 0;
  16504. }
  16505. }
  16506. IRow row = sheet.GetRow(rowStartIndex);
  16507. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  16508. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  16509. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  16510. if (isOpenOverspendSoure)
  16511. {
  16512. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  16513. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  16514. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  16515. }
  16516. for (int i = 0; i <= clounmCount; i++)
  16517. {
  16518. var cell = row.GetCell(i);
  16519. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  16520. if (cell == null)
  16521. {
  16522. cell = row.CreateCell(i);
  16523. }
  16524. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  16525. fontRed.CloneStyleFrom(cell.CellStyle);
  16526. IFont Font = workbook.CreateFont(); // 创建字体
  16527. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  16528. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  16529. fontRed.SetFont(Font);
  16530. byte[] rgb = new byte[3] { 255, 242, 204 };
  16531. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  16532. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  16533. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  16534. if (workbook is XSSFWorkbook)
  16535. {
  16536. BackgroundColor255_242_204.FillForegroundColor = 0;
  16537. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  16538. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  16539. }
  16540. else
  16541. {
  16542. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  16543. }
  16544. if (i == 1 || i > 6)
  16545. {
  16546. if (i > 6)
  16547. {
  16548. fontRed.FillForegroundColor = 0;
  16549. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  16550. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  16551. }
  16552. cell.CellStyle = fontRed;
  16553. }
  16554. if (i > 2 && i < 7)
  16555. {
  16556. cell.CellStyle = BackgroundColor255_242_204;
  16557. }
  16558. cell.SetCellValue(setCellValue); //写入单元格
  16559. }
  16560. if (overspendSoure.ContainsKey(thisSid))
  16561. {
  16562. var overspendId = overspendSoure[thisSid];
  16563. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  16564. }
  16565. cloneRowFn();
  16566. existsId.Add(new CarCompare
  16567. {
  16568. DataPrice = item.DatePrice.ObjToDate(),
  16569. Sid = item.SId
  16570. });
  16571. }
  16572. if (item.Equals(lastElem))
  16573. {
  16574. //合并小计行
  16575. //创建合并区域的实例
  16576. var cellRangeAddress = new CellRangeAddress(
  16577. rowStartIndex, // 起始行索引(0-based)
  16578. rowStartIndex, // 结束行索引(0-based)
  16579. 0, // 起始列索引(0-based)
  16580. 3 // 结束列索引(0-based)
  16581. );
  16582. sheet.AddMergedRegion(cellRangeAddress);
  16583. var CellStyle = workbook.CreateCellStyle();
  16584. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16585. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  16586. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  16587. for (int i = 0; i <= clounmCount; i++)
  16588. {
  16589. if (i > 6)
  16590. {
  16591. var CellStyle1 = workbook.CreateCellStyle();
  16592. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16593. IFont Font = workbook.CreateFont(); // 创建字体
  16594. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  16595. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  16596. CellStyle1.SetFont(Font);
  16597. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  16598. }
  16599. else
  16600. {
  16601. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  16602. }
  16603. }
  16604. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  16605. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  16606. //超时合计
  16607. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  16608. //超时数
  16609. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  16610. //超时合计费用
  16611. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  16612. cloneRowFn();
  16613. // 创建合并区域的实例
  16614. cellRangeAddress = new CellRangeAddress(
  16615. rowStartIndex, // 起始行索引(0-based)
  16616. rowStartIndex, // 结束行索引(0-based)
  16617. 0, // 起始列索引(0-based)
  16618. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  16619. );
  16620. // 添加合并区域
  16621. sheet.AddMergedRegion(cellRangeAddress);
  16622. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  16623. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  16624. }
  16625. }
  16626. mergeRow();
  16627. // 保存修改后的Excel文件到新文件
  16628. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  16629. // new FileStream(newFilePath, FileMode.CreateNew)
  16630. using (var stream = new MemoryStream())
  16631. {
  16632. workbook.Write(stream, true);
  16633. stream.Flush();
  16634. stream.Seek(0, SeekOrigin.Begin);
  16635. var memoryStream = new MemoryStream();
  16636. stream.CopyTo(memoryStream);
  16637. memoryStream.Seek(0, SeekOrigin.Begin);
  16638. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  16639. }
  16640. workbook.Close();
  16641. workbook.Dispose();
  16642. }
  16643. catch (Exception ex)
  16644. {
  16645. jw.Msg = "出现异常!" + ex.Message;
  16646. return Ok(jw);
  16647. }
  16648. }
  16649. if (Zips.Count > 0)
  16650. {
  16651. var io = new IOOperatorHelper();
  16652. var byts = io.ConvertZipStream(Zips);
  16653. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  16654. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  16655. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  16656. }
  16657. else
  16658. {
  16659. jw.Msg = "暂无生成文件!";
  16660. }
  16661. return Ok(jw);
  16662. }
  16663. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  16664. {
  16665. string outStr = string.Empty;
  16666. switch (i)
  16667. {
  16668. case 0:
  16669. outStr = arr[0].SidName;
  16670. break;
  16671. case 1:
  16672. outStr = arr[0].DataPriceStr;
  16673. break;
  16674. case 2:
  16675. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  16676. break;
  16677. case 4:
  16678. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  16679. break;
  16680. case 7:
  16681. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16682. {
  16683. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  16684. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  16685. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  16686. }
  16687. break;
  16688. case 8:
  16689. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16690. {
  16691. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  16692. }
  16693. break;
  16694. case 9:
  16695. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16696. {
  16697. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  16698. }
  16699. break;
  16700. case 10:
  16701. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16702. {
  16703. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  16704. }
  16705. break;
  16706. }
  16707. return outStr;
  16708. }
  16709. #region OP行程单
  16710. /// <summary>
  16711. /// OP行程单初始化
  16712. /// </summary>
  16713. /// <param name="dto"></param>
  16714. /// <returns></returns>
  16715. [HttpPost]
  16716. public IActionResult InitOpTravel(InitOpTravelDto dto)
  16717. {
  16718. var jw = JsonView(false);
  16719. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  16720. var group = groupList.First();
  16721. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  16722. if (group == null)
  16723. {
  16724. jw.Msg = "暂无团组!";
  16725. return Ok(jw);
  16726. }
  16727. group = groupList.Find(x => x.Id == diid);
  16728. if (group == null)
  16729. {
  16730. jw.Msg = "请输入正确的团组ID!";
  16731. return Ok(jw);
  16732. }
  16733. string city = string.Empty;
  16734. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  16735. if (blackCode.Count > 0)
  16736. {
  16737. var black = blackCode.First();
  16738. black.BlackCode = black.BlackCode ?? "";
  16739. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  16740. if (blackSp.Length > 0)
  16741. {
  16742. try
  16743. {
  16744. var cityArrCode = new List<string>(20);
  16745. foreach (var item in blackSp)
  16746. {
  16747. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  16748. var IndexSelect = itemSp[2];
  16749. var cityArrCodeLength = cityArrCode.Count - 1;
  16750. var startCity = IndexSelect.Substring(0, 3);
  16751. if (cityArrCodeLength > 0)
  16752. {
  16753. var arrEndCity = cityArrCode[cityArrCodeLength];
  16754. if (arrEndCity != startCity)
  16755. {
  16756. cityArrCode.Add(startCity.ToUpper());
  16757. }
  16758. }
  16759. else
  16760. {
  16761. cityArrCode.Add(startCity.ToUpper());
  16762. }
  16763. var endCity = IndexSelect.Substring(3, 3);
  16764. cityArrCode.Add(endCity.ToUpper());
  16765. }
  16766. var cityThree = string.Empty;
  16767. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  16768. cityThree = cityThree.TrimEnd(',');
  16769. if (string.IsNullOrWhiteSpace(cityThree))
  16770. {
  16771. throw new
  16772. Exception("error");
  16773. }
  16774. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  16775. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  16776. foreach (var item in cityArrCode)
  16777. {
  16778. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  16779. if (find != null)
  16780. {
  16781. city += find.City + "/";
  16782. }
  16783. else
  16784. {
  16785. city += item + "三字码未收入/";
  16786. }
  16787. }
  16788. city = city.TrimEnd('/');
  16789. }
  16790. catch (Exception e)
  16791. {
  16792. city = "黑屏代码格式不正确!";
  16793. }
  16794. }
  16795. }
  16796. else
  16797. {
  16798. city = "未录入黑屏代码";
  16799. }
  16800. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  16801. {
  16802. Date = x.Date,
  16803. Days = x.Days,
  16804. Diffgroup = x.Diffgroup,
  16805. Diid = x.Diid,
  16806. Traffic_First = x.Traffic_First,
  16807. Traffic_Second = x.Traffic_Second,
  16808. Trip = x.Trip,
  16809. WeekDay = x.WeekDay,
  16810. Id = x.Id
  16811. }).ToList();
  16812. jw.Data = new
  16813. {
  16814. groupList = groupList.Select(x => new
  16815. {
  16816. x.Id,
  16817. x.TeamName,
  16818. x.TourCode
  16819. }).ToList(),
  16820. groupInfo = new
  16821. {
  16822. group.VisitDays,
  16823. group.TourCode,
  16824. group.VisitPNumber,
  16825. group.TeamName,
  16826. city
  16827. },
  16828. OpTravelList
  16829. };
  16830. jw.Code = 200;
  16831. jw.Msg = "操作成功!";
  16832. return Ok(jw);
  16833. }
  16834. /// <summary>
  16835. /// 删除团组行程单
  16836. /// </summary>
  16837. /// <returns></returns>
  16838. [HttpPost]
  16839. public IActionResult DelTravel(DelOpTravelDto dto)
  16840. {
  16841. var jw = JsonView(false);
  16842. if (dto.UserId <= 0 || dto.Diid <= 0)
  16843. {
  16844. jw.Msg = "请输入正确的参数!";
  16845. return Ok(jw);
  16846. }
  16847. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16848. .SetColumns(x => new Grp_TravelList
  16849. {
  16850. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  16851. DeleteUserId = dto.UserId,
  16852. IsDel = 1,
  16853. }).ExecuteCommand();
  16854. jw = JsonView(true);
  16855. return Ok(jw);
  16856. }
  16857. /// <summary>
  16858. /// 行程单保存
  16859. /// </summary>
  16860. /// <returns></returns>
  16861. [HttpPost]
  16862. public IActionResult TravelSave(TravelSaveDto dto)
  16863. {
  16864. var jw = JsonView(false);
  16865. if (dto.Arr.Count > 0)
  16866. {
  16867. try
  16868. {
  16869. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  16870. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  16871. .ToList();
  16872. _sqlSugar.BeginTran();
  16873. foreach (var item in dto.Arr)
  16874. {
  16875. if (item.Id == 0)
  16876. {
  16877. throw new Exception("请传入正确的Id");
  16878. }
  16879. //比较上一次的差异
  16880. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  16881. if (findTravel != null)
  16882. {
  16883. item.Trip = item.Trip.Replace("[++]", string.Empty);
  16884. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  16885. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  16886. }
  16887. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  16888. .SetColumns(x => new Grp_TravelList
  16889. {
  16890. Trip = item.Trip
  16891. }).ExecuteCommand();
  16892. }
  16893. _sqlSugar.CommitTran();
  16894. jw = JsonView(true);
  16895. }
  16896. catch (Exception ex)
  16897. {
  16898. _sqlSugar.RollbackTran();
  16899. jw.Msg = "程序异常!" + ex.Message;
  16900. }
  16901. }
  16902. else
  16903. {
  16904. jw.Msg = "请传入正确的参数!";
  16905. }
  16906. return Ok(jw);
  16907. }
  16908. private static string CheckStr(string original, string changed)
  16909. {
  16910. // 创建diff_match_patch对象
  16911. var dmp = new diff_match_patch();
  16912. // 计算差异
  16913. List<Diff> diffs = dmp.diff_main(original, changed);
  16914. // 清理和合并差异
  16915. dmp.diff_cleanupSemantic(diffs);
  16916. // 使用StringBuilder构建最终的字符串
  16917. var finalString = new StringBuilder();
  16918. // 输出差异结果,并构建变动后的字符串
  16919. foreach (Diff diff in diffs)
  16920. {
  16921. switch (diff.operation)
  16922. {
  16923. case Operation.EQUAL:
  16924. // 相等的部分,直接添加到最终字符串
  16925. finalString.Append(diff.text);
  16926. break;
  16927. case Operation.INSERT:
  16928. // 插入的部分,添加标记并添加到最终字符串
  16929. finalString.Append("[++]" + diff.text + "[++]");
  16930. break;
  16931. case Operation.DELETE:
  16932. // 删除的部分,不添加到最终字符串
  16933. //finalString.Append("[++]" + diff.text + "[++]");
  16934. break;
  16935. }
  16936. }
  16937. // 输出变动后的字符串
  16938. return finalString.ToString();
  16939. }
  16940. private class tagContent
  16941. {
  16942. public DateTime Date { get; set; }
  16943. public string StartTag { get; set; }
  16944. public string EndTag { get; set; }
  16945. public string Content { get; set; }
  16946. public static int tagLength { get { return 3; } }
  16947. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  16948. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  16949. public bool IsFinally { get; set; }
  16950. }
  16951. private static List<string> ExtractContentBetweenTags(string input, string tag)
  16952. {
  16953. var results = new List<string>();
  16954. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  16955. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  16956. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  16957. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  16958. string[] strValueArr = new string[1];
  16959. foreach (System.Text.RegularExpressions.Match match in matches)
  16960. {
  16961. var strValue = match.Groups[1].Value;
  16962. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  16963. }
  16964. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  16965. return results;
  16966. }
  16967. /// <summary>
  16968. /// 导出行程单
  16969. /// </summary>
  16970. /// <param name="dto"></param>
  16971. /// <returns></returns>
  16972. [HttpPost]
  16973. public IActionResult ExportTravel(ExportTravelDto dto)
  16974. {
  16975. var jw = JsonView(false);
  16976. jw.Data = "";
  16977. int diid = 0;
  16978. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  16979. if (Find == null)
  16980. {
  16981. jw.Msg = "请选择正确的团组!";
  16982. return Ok(jw);
  16983. }
  16984. else
  16985. {
  16986. diid = Find.Id;
  16987. }
  16988. //数据源
  16989. var _travelList = new List<Grp_TravelList>();
  16990. DataTable dtBlack = null;
  16991. try
  16992. {
  16993. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  16994. }
  16995. catch (Exception)
  16996. {
  16997. jw.Msg = "机票黑屏代码有误!";
  16998. return Ok(jw);
  16999. }
  17000. string CityStr = string.Empty;
  17001. if (dtBlack.Rows.Count == 0)
  17002. {
  17003. jw.Msg = "机票黑屏代码有误!";
  17004. return Ok(jw);
  17005. }
  17006. else
  17007. {
  17008. foreach (DataRow row in dtBlack.Rows)
  17009. {
  17010. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17011. {
  17012. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  17013. return Ok(jw);
  17014. }
  17015. }
  17016. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  17017. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  17018. }
  17019. // 指定的文字
  17020. var targetTextDic = new Dictionary<string, List<string>>();
  17021. //创建数据源Table
  17022. var dtSource = new DataTable();
  17023. dtSource.Columns.Add("Days", typeof(string));
  17024. dtSource.Columns.Add("Date", typeof(string));
  17025. dtSource.Columns.Add("Week", typeof(string));
  17026. dtSource.Columns.Add("Traffic", typeof(string));
  17027. dtSource.Columns.Add("Trip", typeof(string));
  17028. //获取数据,放到datatable
  17029. foreach (var item in _travelList)
  17030. {
  17031. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  17032. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  17033. .Replace(tagContent.TagFormat.Item2, string.Empty)
  17034. .Replace("[++]", string.Empty);
  17035. DataRow dr = dtSource.NewRow();
  17036. dr["Days"] = item.Days;
  17037. dr["Date"] = item.Date;
  17038. dr["Week"] = item.WeekDay;
  17039. dr["Traffic"] = item.Traffic_First
  17040. + "\r\n"
  17041. + item.Traffic_Second;
  17042. dr["Trip"] = item.Trip;
  17043. dtSource.Rows.Add(dr);
  17044. }
  17045. var dic = new Dictionary<string, string>
  17046. {
  17047. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  17048. { "City", CityStr },
  17049. { "Days", Find.VisitDays.ToString() },
  17050. { "DeleCode", Find.TourCode },
  17051. { "Pnum", Find.VisitPNumber.ToString() }
  17052. };
  17053. //模板路径
  17054. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  17055. //载入模板
  17056. Document doc = null;
  17057. DocumentBuilder builder = null;
  17058. try
  17059. {
  17060. //载入模板
  17061. doc = new Document(tempPath);
  17062. builder = new DocumentBuilder(doc);
  17063. }
  17064. catch (Exception)
  17065. {
  17066. jw.Msg = "模板位置不存在!";
  17067. return Ok(jw);
  17068. }
  17069. foreach (var key in dic.Keys)
  17070. {
  17071. Bookmark bookmark = doc.Range.Bookmarks[key];
  17072. if (bookmark != null)
  17073. {
  17074. builder.MoveToBookmark(key);
  17075. builder.Write(dic[key]);
  17076. }
  17077. }
  17078. //获取word里所有表格
  17079. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17080. //获取所填表格的序数
  17081. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17082. try
  17083. {
  17084. //循环赋值
  17085. for (int i = 0; i < dtSource.Rows.Count; i++)
  17086. {
  17087. builder.MoveToCell(0, i + 1, 0, 0);
  17088. builder.Write(dtSource.Rows[i]["Days"].ToString());
  17089. builder.MoveToCell(0, i + 1, 1, 0);
  17090. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  17091. builder.MoveToCell(0, i + 1, 2, 0);
  17092. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  17093. var trip = dtSource.Rows[i]["Trip"].ToString();
  17094. builder.MoveToCell(0, i + 1, 3, 0);
  17095. builder.Write(trip);
  17096. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  17097. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  17098. // 获取特定索引的段落
  17099. Paragraph paragraph = (Paragraph)paragraphs[0];
  17100. Run run = paragraph.Runs[0];
  17101. Aspose.Words.Font font = run.Font;
  17102. font.Name = "黑体";
  17103. //设置双休红色
  17104. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  17105. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  17106. paragraph = (Paragraph)paragraphs[1];
  17107. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  17108. {
  17109. run = paragraph.Runs[0];
  17110. font = run.Font;
  17111. font.Color = Color.Red;
  17112. }
  17113. }
  17114. }
  17115. catch (Exception ex)
  17116. {
  17117. }
  17118. //删除多余行
  17119. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  17120. {
  17121. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  17122. }
  17123. var targetTextList = new List<string>();
  17124. // 遍历文档中的表格
  17125. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17126. {
  17127. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17128. {
  17129. var cellIndex = 0;
  17130. foreach (Cell cell in row.Cells)
  17131. {
  17132. if (cellIndex == 1 && row.Cells.Count == 4)
  17133. {
  17134. foreach (var target in targetTextDic.Keys)
  17135. {
  17136. if (cell.GetText().Contains(target))
  17137. {
  17138. targetTextList = targetTextDic[target];
  17139. break;
  17140. }
  17141. }
  17142. }
  17143. // 遍历单元格中的所有段落
  17144. foreach (Paragraph paragraph in cell.Paragraphs)
  17145. {
  17146. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  17147. var runs = new List<Run>();
  17148. foreach (Run run in paragraph.Runs)
  17149. {
  17150. runs.Add(run);
  17151. }
  17152. foreach (Run run in runs)
  17153. {
  17154. foreach (var targetText in targetTextList)
  17155. {
  17156. // 检查文字是否包含指定文字
  17157. if (run.Text.Contains(targetText))
  17158. {
  17159. // 将包含的部分设置为红色
  17160. HighlightText(run, targetText, Color.Red);
  17161. }
  17162. }
  17163. }
  17164. }
  17165. cellIndex++;
  17166. }
  17167. }
  17168. }
  17169. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  17170. if (!Directory.Exists(savePath))
  17171. {
  17172. try
  17173. {
  17174. Directory.CreateDirectory(savePath);
  17175. }
  17176. catch
  17177. {
  17178. }
  17179. }
  17180. string path = savePath + Find.TeamName + "出访日程";
  17181. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  17182. try
  17183. {
  17184. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  17185. string postfix = ".docx";
  17186. if (dto.IsPDF == 1)
  17187. {
  17188. saveFormat = Aspose.Words.SaveFormat.Pdf;
  17189. postfix = ".pdf";
  17190. }
  17191. doc.Save(path + postfix, saveFormat);
  17192. jw = JsonView(true, "导出成功", ftpPath + postfix);
  17193. }
  17194. catch (Exception)
  17195. {
  17196. jw = JsonView(false);
  17197. }
  17198. return Ok(jw);
  17199. }
  17200. /// <summary>
  17201. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  17202. /// </summary>
  17203. /// <param name="num"></param>
  17204. /// <returns></returns>
  17205. static string GetNum(string num)
  17206. {
  17207. string str = "";
  17208. switch (num)
  17209. {
  17210. case "1":
  17211. str = "一";
  17212. break;
  17213. case "2":
  17214. str = "二";
  17215. break;
  17216. case "3":
  17217. str = "三";
  17218. break;
  17219. case "4":
  17220. str = "四";
  17221. break;
  17222. case "5":
  17223. str = "五";
  17224. break;
  17225. case "6":
  17226. str = "六";
  17227. break;
  17228. case "7":
  17229. str = "七";
  17230. break;
  17231. case "8":
  17232. str = "八";
  17233. break;
  17234. case "9":
  17235. str = "九";
  17236. break;
  17237. case "10":
  17238. str = "十";
  17239. break;
  17240. case "11":
  17241. str = "十一";
  17242. break;
  17243. case "12":
  17244. str = "十二";
  17245. break;
  17246. case "一":
  17247. str = "1";
  17248. break;
  17249. case "二":
  17250. str = "2";
  17251. break;
  17252. case "三":
  17253. str = "3";
  17254. break;
  17255. case "四":
  17256. str = "4";
  17257. break;
  17258. case "五":
  17259. str = "5";
  17260. break;
  17261. case "六":
  17262. str = "6";
  17263. break;
  17264. case "七":
  17265. str = "7";
  17266. break;
  17267. case "八":
  17268. str = "8";
  17269. break;
  17270. case "九":
  17271. str = "9";
  17272. break;
  17273. case "十":
  17274. str = "10";
  17275. break;
  17276. case "十一":
  17277. str = "11";
  17278. break;
  17279. case "十二":
  17280. str = "12";
  17281. break;
  17282. }
  17283. return str;
  17284. }
  17285. /// <summary>
  17286. /// 高亮包含指定文字的部分
  17287. /// </summary>
  17288. /// <param name="run"></param>
  17289. /// <param name="targetText"></param>
  17290. /// <param name="color"></param>
  17291. static void HighlightText(Run run, string targetText, Color color)
  17292. {
  17293. string text = run.Text;
  17294. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  17295. if (startIndex >= 0)
  17296. {
  17297. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  17298. // 前部分
  17299. if (startIndex > 0)
  17300. {
  17301. Run beforeRun = (Run)run.Clone(true);
  17302. beforeRun.Text = text.Substring(0, startIndex);
  17303. parentParagraph.InsertBefore(beforeRun, run);
  17304. }
  17305. // 匹配部分
  17306. Run matchRun = (Run)run.Clone(true);
  17307. matchRun.Text = text.Substring(startIndex, targetText.Length);
  17308. matchRun.Font.Color = color;
  17309. parentParagraph.InsertBefore(matchRun, run);
  17310. // 后部分
  17311. if (startIndex + targetText.Length < text.Length)
  17312. {
  17313. Run afterRun = (Run)run.Clone(true);
  17314. afterRun.Text = text.Substring(startIndex + targetText.Length);
  17315. parentParagraph.InsertBefore(afterRun, run);
  17316. }
  17317. // 删除原始Run
  17318. run.Remove();
  17319. }
  17320. }
  17321. #endregion
  17322. #endregion
  17323. #region 团组成本
  17324. /// <summary>
  17325. /// 团组成本数据初始化
  17326. /// </summary>
  17327. /// <param name="dto"></param>
  17328. /// <returns></returns>
  17329. [HttpPost]
  17330. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  17331. {
  17332. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17333. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17334. WHEN COUNT(*) >= 0 THEN 'True'
  17335. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17336. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  17337. ").ToList(); //团组列表
  17338. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  17339. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  17340. var visaCountryInfoArr = new ArrayList();
  17341. var groupinfoValue = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == diid && x.IsDel == 0);
  17342. if (groupinfoValue != null)
  17343. {
  17344. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  17345. var dicity = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == groupinfoValue.CityId);
  17346. dicity ??= new Sys_Cities()
  17347. {
  17348. ParentId = 122
  17349. };
  17350. var diparent = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == dicity.ParentId);
  17351. var spArr = new string[1] { countryArr };
  17352. if (countryArr.Contains("|"))
  17353. {
  17354. spArr = countryArr.Split("|");
  17355. }
  17356. else if (countryArr.Contains("、"))
  17357. {
  17358. spArr = countryArr.Split("、");
  17359. }
  17360. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  17361. {
  17362. try
  17363. {
  17364. var visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  17365. .Where(x => x.IsDel == 0 && x.Country == item)
  17366. .ToList();
  17367. if (!visa.Any())
  17368. {
  17369. visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  17370. .Where(x => x.IsDel == 0 && x.Country.Contains(item))
  17371. .ToList();
  17372. }
  17373. if (visa.Any())
  17374. {
  17375. var visainfo = _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  17376. .Where(x => x.IsDel == 0 && visa.Select(x => x.Id).Contains(x.ParentId))
  17377. .ToList();
  17378. var visaMain = visainfo.FirstOrDefault(x => x.ProvinceId == diparent.Id);
  17379. var visayinsiValue = visainfo.FirstOrDefault(x => x.ParentId == visa.FirstOrDefault(x => x.FeeType == 1)?.Id);
  17380. visaCountryInfoArr.Add(new
  17381. {
  17382. country = item,
  17383. yinsi = new
  17384. {
  17385. Id = visayinsiValue.Id,
  17386. value = visayinsiValue.SmallVisaPrice
  17387. },
  17388. visaMain = new
  17389. {
  17390. Id = visaMain.Id,
  17391. IsVisaOnArrival = visaMain.IsVisaOnArrival ? "是" : "否",
  17392. IsElectronicSign = visaMain.IsElectronicSign ? "是" : "否",
  17393. VisaTime = visaMain.VisaTime,
  17394. IsVisaExemptionLarge = visaMain.IsVisaExemptionLarge ? "是" : "否",
  17395. LargeVisaPrice = visaMain.LargeVisaPrice,
  17396. LargeAgencyFee = visaMain.LargeAgencyFee,
  17397. IsVisaExemptionSmall = visaMain.IsVisaExemptionSmall ? "是" : "否",
  17398. SmallVisaPrice = visaMain.SmallVisaPrice,
  17399. SmallAgencyFee = visaMain.SmallAgencyFee,
  17400. NormExtFee = visaMain.NormExtFee,
  17401. UrgExtFee = visaMain.UrgExtFee,
  17402. IsUrgent = visaMain.IsUrgent ? "是" : "否",
  17403. UrgentTime = visaMain.UrgentTime,
  17404. UrgentPrice = visaMain.UrgentPrice,
  17405. UrgentPriceDesc = visaMain.UrgentPriceDesc,
  17406. Remark = visaMain.Remark,
  17407. }
  17408. });
  17409. }
  17410. }
  17411. catch (Exception ex)
  17412. {
  17413. //写入日志
  17414. _logger.LogError(ex, "团组成本解析签证异常!");
  17415. }
  17416. }
  17417. }
  17418. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  17419. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  17420. #region 屏蔽黑屏代码生成
  17421. //var create = _GroupCostRepository.
  17422. // CreateGroupCostByBlackCode(dto.Diid);
  17423. //if (groupCost.Count == 0 && create.Code == 0)
  17424. //{
  17425. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  17426. //}
  17427. #endregion
  17428. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  17429. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  17430. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  17431. groupCostMap = groupCostMap.Select(x =>
  17432. {
  17433. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  17434. {
  17435. x.Date = dataForamt.ToString("yyyy-MM-dd");
  17436. }
  17437. return x;
  17438. }).ToList();
  17439. //GroupCostParameter.Add(new
  17440. // Grp_GroupCostParameter());
  17441. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  17442. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  17443. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  17444. return Ok(JsonView(new
  17445. {
  17446. groupList,
  17447. groupInfo,
  17448. groupChecks,
  17449. groupCost = groupCostMap,
  17450. hotelNumber,
  17451. GroupCostParameter = GroupCostParameterMap,
  17452. visaCountryInfoArr = visaCountryInfoArr,
  17453. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  17454. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  17455. hotelIsTrue,
  17456. groupModuleOperators
  17457. }));
  17458. }
  17459. /// <summary>
  17460. /// 团组成本信息保存
  17461. /// </summary>
  17462. /// <param name="dto"></param>
  17463. /// <returns></returns>
  17464. [HttpPost]
  17465. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  17466. {
  17467. if (dto.Diid <= 0 || dto.Userid <= 0)
  17468. {
  17469. return Ok(JsonView(false));
  17470. }
  17471. JsonView jw = null;
  17472. bool isTrue = false;
  17473. #region 复制团组成本
  17474. //if (dto.Diid == 2581)
  17475. //{
  17476. // dto.Diid = 2599;
  17477. // dto.CheckBoxs.ForEach(x =>
  17478. // {
  17479. // x.Diid = 2599;
  17480. // });
  17481. // dto.GroupCosts.ForEach(x =>
  17482. // {
  17483. // x.Diid = 2599;
  17484. // });
  17485. // dto.CostTypeHotelNumbers.ForEach(x =>
  17486. // {
  17487. // x.Diid = 2599;
  17488. // });
  17489. // dto.GroupCostParameters.ForEach(x =>
  17490. // {
  17491. // x.DiId = 2599;
  17492. // });
  17493. //}
  17494. #endregion
  17495. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  17496. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  17497. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  17498. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  17499. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  17500. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  17501. try
  17502. {
  17503. _sqlSugar.BeginTran();
  17504. isTrue = await _GroupCostRepository.
  17505. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  17506. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  17507. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  17508. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  17509. _sqlSugar.CommitTran();
  17510. jw = JsonView(true, "保存成功!", isTrue);
  17511. }
  17512. catch (Exception)
  17513. {
  17514. _sqlSugar.RollbackTran();
  17515. jw = JsonView(false);
  17516. }
  17517. return Ok(jw);
  17518. }
  17519. /// <summary>
  17520. /// 复制团组成本信息
  17521. /// </summary>
  17522. /// <param name="dto"></param>
  17523. /// <returns></returns>
  17524. [HttpPost]
  17525. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  17526. {
  17527. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  17528. {
  17529. return Ok(JsonView(false, "参数有误!"));
  17530. }
  17531. #region 复制团组成本
  17532. dto.Diid = dto.ToGroupId;
  17533. dto.CheckBoxs.ForEach(x =>
  17534. {
  17535. x.Diid = dto.ToGroupId;
  17536. });
  17537. dto.GroupCosts.ForEach(x =>
  17538. {
  17539. x.Diid = dto.ToGroupId;
  17540. });
  17541. dto.CostTypeHotelNumbers.ForEach(x =>
  17542. {
  17543. x.Diid = dto.ToGroupId;
  17544. });
  17545. dto.GroupCostParameters.ForEach(x =>
  17546. {
  17547. x.DiId = dto.ToGroupId;
  17548. });
  17549. #endregion
  17550. JsonView jw = null;
  17551. bool isTrue = false;
  17552. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  17553. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  17554. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  17555. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  17556. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  17557. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  17558. try
  17559. {
  17560. _sqlSugar.BeginTran();
  17561. isTrue = await _GroupCostRepository.
  17562. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  17563. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  17564. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  17565. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  17566. _sqlSugar.CommitTran();
  17567. jw = JsonView(true, "保存成功!", isTrue);
  17568. }
  17569. catch (Exception)
  17570. {
  17571. _sqlSugar.RollbackTran();
  17572. jw = JsonView(false);
  17573. }
  17574. return Ok(jw);
  17575. }
  17576. /// <summary>
  17577. /// 司兼导数据
  17578. /// </summary>
  17579. /// <param name="dto"></param>
  17580. /// <returns></returns>
  17581. [HttpPost]
  17582. public IActionResult GetCarGuides(CarGuidesDto dto)
  17583. {
  17584. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  17585. return Ok(JsonView(true, "获取成功!", Data));
  17586. }
  17587. /// <summary>
  17588. /// 导游数据
  17589. /// </summary>
  17590. /// <param name="dto"></param>
  17591. /// <returns></returns>
  17592. [HttpPost]
  17593. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  17594. {
  17595. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  17596. // 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
  17597. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  17598. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  17599. return Ok(JsonView(true, "获取成功!", Data));
  17600. }
  17601. /// <summary>
  17602. /// 成本车数据
  17603. /// </summary>
  17604. /// <param name="dto"></param>
  17605. /// <returns></returns>
  17606. [HttpPost]
  17607. public IActionResult GetCarInfo(CarGuidesDto dto)
  17608. {
  17609. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  17610. return Ok(JsonView(true, "获取成功!", Data));
  17611. }
  17612. /// <summary>
  17613. /// 景点数据
  17614. /// </summary>
  17615. /// <param name="dto"></param>
  17616. /// <returns></returns>
  17617. [HttpPost]
  17618. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  17619. {
  17620. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  17621. return Ok(JsonView(true, "获取成功!", Data));
  17622. }
  17623. /// <summary>
  17624. /// 成本通知
  17625. /// </summary>
  17626. /// <param name="dto"></param>
  17627. /// <returns></returns>
  17628. [HttpPost]
  17629. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  17630. {
  17631. if (dto.Diid < 0)
  17632. {
  17633. return Ok(JsonView(false));
  17634. }
  17635. JsonView jw;
  17636. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17637. if (GroupCostParameter != null)
  17638. {
  17639. int IsShare = 0;
  17640. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  17641. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  17642. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  17643. string msg = string.Empty;
  17644. if (isTrue)
  17645. {
  17646. if (IsShare == 0)
  17647. {
  17648. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  17649. }
  17650. else
  17651. {
  17652. #region 企微通知对应岗位用户
  17653. try
  17654. {
  17655. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  17656. //机票预算群通知
  17657. await AppNoticeLibrary.SendChatMsg_AirCostChat(dto.Diid, QiyeWeChatEnum.AirCostChat01);
  17658. }
  17659. catch (Exception)
  17660. {
  17661. }
  17662. #endregion
  17663. msg = "通知成功,其他模块操作人员可见此成本信息!";
  17664. }
  17665. jw = JsonView(isTrue, msg, new { IsShare });
  17666. }
  17667. else
  17668. {
  17669. msg = "修改失败!";
  17670. jw = JsonView(isTrue, msg);
  17671. }
  17672. }
  17673. else
  17674. {
  17675. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  17676. }
  17677. return Ok(jw);
  17678. }
  17679. /// <summary>
  17680. /// 导出报价单
  17681. /// </summary>
  17682. /// <param name="dto"></param>
  17683. /// <returns></returns>
  17684. [HttpPost]
  17685. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  17686. {
  17687. if (dto.Diid == 0)
  17688. {
  17689. return Ok(JsonView(false, "请传递团组id"));
  17690. }
  17691. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  17692. if (deleInfo.Code != 0)
  17693. {
  17694. return Ok(JsonView(false, "团组信息查询失败!"));
  17695. }
  17696. var di = deleInfo.Data as DelegationInfoWebView;
  17697. if (di != null)
  17698. {
  17699. di.TeamName = di.TeamName.Replace("|", "、");
  17700. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  17701. //文件名
  17702. string strFileName = di.TeamName + "-收款账单.doc";
  17703. //获取模板
  17704. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  17705. //载入模板
  17706. Document doc = new Document(tmppath);
  17707. decimal TotalPrice = 0.00M;
  17708. string itemStr = string.Empty;
  17709. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  17710. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  17711. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  17712. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  17713. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  17714. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  17715. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  17716. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  17717. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  17718. foreach (var cost in groupCostType)
  17719. {
  17720. var List = cost.ToList();
  17721. if (cost.Key == "A")
  17722. {
  17723. foreach (var ListItem in List)
  17724. {
  17725. if (ListItem.number > 0)
  17726. {
  17727. if (ListItem.code.Contains("TBR"))
  17728. {
  17729. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17730. }
  17731. else
  17732. {
  17733. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17734. }
  17735. TotalPrice += (ListItem.number * ListItem.price);
  17736. }
  17737. }
  17738. }
  17739. else
  17740. {
  17741. itemStr = itemStr.Insert(0, "A段\r\n");
  17742. itemStr += "B段\r\n";
  17743. foreach (var ListItem in List)
  17744. {
  17745. if (ListItem.number > 0)
  17746. {
  17747. if (ListItem.code.Contains("TBR"))
  17748. {
  17749. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17750. }
  17751. else
  17752. {
  17753. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17754. }
  17755. TotalPrice += (ListItem.number * ListItem.price);
  17756. }
  17757. }
  17758. }
  17759. }
  17760. #region 替换Word模板书签内容
  17761. Dictionary<string, string> marks = new Dictionary<string, string>();
  17762. marks.Add("To", di.ClientUnit);//付款方
  17763. marks.Add("ToTel", di.TellPhone);//付款方电话
  17764. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17765. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17766. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17767. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17768. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17769. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17770. marks.Add("PayItemContent", itemStr);//详细信息
  17771. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  17772. #endregion
  17773. ////注
  17774. //if (doc.Range.Bookmarks["Attention"] != null)
  17775. //{
  17776. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  17777. // mark.Text = frList[0].Attention;
  17778. //}
  17779. foreach (var item in marks.Keys)
  17780. {
  17781. if (doc.Range.Bookmarks[item] != null)
  17782. {
  17783. Bookmark mark = doc.Range.Bookmarks[item];
  17784. mark.Text = marks[item];
  17785. }
  17786. }
  17787. byte[] bytes = null;
  17788. using (MemoryStream stream = new MemoryStream())
  17789. {
  17790. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  17791. bytes = stream.ToArray();
  17792. }
  17793. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  17794. return Ok(JsonView(true, "", new
  17795. {
  17796. Data = bytes,
  17797. strFileName,
  17798. }));
  17799. }
  17800. else
  17801. {
  17802. return Ok(JsonView(false, "团组信息不存在!"));
  17803. }
  17804. }
  17805. /// <summary>
  17806. /// 导出团组成本
  17807. /// </summary>
  17808. /// <param name="dto"></param>
  17809. /// <returns></returns>
  17810. [HttpPost]
  17811. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  17812. {
  17813. var jw = JsonView(false);
  17814. if (dto.Diid == 0)
  17815. {
  17816. return Ok(JsonView(false, "请传递团组id"));
  17817. }
  17818. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  17819. if (deleInfo.Code != 0)
  17820. {
  17821. return Ok(JsonView(false, "团组信息查询失败!"));
  17822. }
  17823. var di = deleInfo.Data as DelegationInfoWebView;
  17824. if (di == null)
  17825. {
  17826. return Ok(JsonView(false, "团组信息查询失败!"));
  17827. }
  17828. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  17829. WorkbookDesigner designer = new WorkbookDesigner();
  17830. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  17831. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  17832. List<int> hideColumnList = new List<int>();
  17833. var ColumnSetting = new[]
  17834. {
  17835. new { tag = "VF", Index = 4, P = "CarCost" },
  17836. new { tag = "VN", Index = 5, P = "CarNumber" },
  17837. new { tag = "VRD", Index = 6, P = "CarTiming" },
  17838. new { tag = "T/G S", Index = 7, P = "TGS" },
  17839. new { tag = "TGWH", Index = 8, P = "TGWH" },
  17840. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  17841. new { tag = "T/G M", Index = 10, P = "TGM" },
  17842. new { tag = "T/G A", Index = 11, P = "TGA" },
  17843. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  17844. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  17845. new { tag = "C/F S", Index = 14, P = "CFS" },
  17846. new { tag = "C/F M", Index = 15, P = "CFM" },
  17847. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  17848. new { tag = "B", Index = 17, P = "B" },
  17849. new { tag = "L", Index = 18, P = "L" },
  17850. new { tag = "D", Index = 19, P = "D" },
  17851. new { tag = "TBR", Index = 20, P = "TBR" },
  17852. new { tag = "SGR", Index = 21, P = "SGR" },
  17853. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  17854. new { tag = "Suite", Index = 23, P = "Suite" },
  17855. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  17856. new { tag = "T/V", Index = 25, P = "TV" },
  17857. new { tag = "1/L", Index = 26, P = "iL" },
  17858. new { tag = "I/F", Index = 27, P = "IF" },
  17859. new { tag = "EF", Index = 28, P = "EF" },
  17860. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  17861. new { tag = "TE", Index = 30, P = "TE" },
  17862. new { tag = "T/G T", Index = 31, P = "TGTips" },
  17863. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  17864. new { tag = "P/C", Index = 33, P = "PC" },
  17865. new { tag = "T/L F", Index = 34, P = "TLF" },
  17866. new { tag = "E/C T", Index = 35, P = "ECT" }
  17867. };
  17868. Func<string, bool> isEmpty = (str) =>
  17869. {
  17870. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  17871. {
  17872. return true;
  17873. }
  17874. if (string.IsNullOrWhiteSpace(str))
  17875. {
  17876. return true;
  17877. }
  17878. return false;
  17879. };
  17880. for (int i = 0; i < List_GC.Count; i++)
  17881. {
  17882. GroupCost_Excel gc = new GroupCost_Excel();
  17883. gc.Id = List_GC[i].Id;
  17884. gc.Diid = List_GC[i].Diid.ToString();
  17885. gc.DAY = List_GC[i].DAY;
  17886. string week = "";
  17887. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  17888. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  17889. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  17890. gc.ITIN = List_GC[i].ITIN;
  17891. gc.CarType = List_GC[i].CarType;
  17892. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  17893. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  17894. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  17895. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  17896. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  17897. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  17898. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  17899. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  17900. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  17901. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  17902. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  17903. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  17904. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  17905. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  17906. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  17907. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  17908. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  17909. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  17910. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  17911. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  17912. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  17913. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  17914. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  17915. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  17916. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  17917. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  17918. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  17919. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  17920. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  17921. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  17922. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  17923. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  17924. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  17925. gc.EFR = List_GC[i].EFR;
  17926. List_GC1.Add(gc);
  17927. }
  17928. if (List_GC1.Count > 0)
  17929. {
  17930. var p = List_GC1[0];
  17931. var prs = p.GetType().GetProperties();
  17932. foreach (var item in prs)
  17933. {
  17934. var tp = item.PropertyType;
  17935. if (tp == typeof(int))
  17936. {
  17937. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  17938. if (val == 0)
  17939. {
  17940. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  17941. if (columnSetting != null)
  17942. {
  17943. hideColumnList.Add(columnSetting.Index);
  17944. }
  17945. }
  17946. }
  17947. if (tp == typeof(decimal))
  17948. {
  17949. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  17950. if (val == 0)
  17951. {
  17952. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  17953. if (columnSetting != null)
  17954. {
  17955. hideColumnList.Add(columnSetting.Index);
  17956. }
  17957. }
  17958. }
  17959. if (tp == typeof(string))
  17960. {
  17961. var val = List_GC1.Sum(x =>
  17962. {
  17963. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  17964. if (decimal.TryParse(str, out decimal str_De))
  17965. {
  17966. return str_De;
  17967. }
  17968. else
  17969. {
  17970. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  17971. }
  17972. });
  17973. if (val == 0)
  17974. {
  17975. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  17976. if (columnSetting != null)
  17977. {
  17978. hideColumnList.Add(columnSetting.Index);
  17979. }
  17980. }
  17981. }
  17982. }
  17983. }
  17984. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  17985. dt.TableName = "TB";
  17986. //报表标题等不用dt的值
  17987. designer.SetDataSource("TeamName", dto.title.TeamName);
  17988. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  17989. designer.SetDataSource("Tax", dto.title.Tax);
  17990. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  17991. designer.SetDataSource("Currency", dto.title.Currency);
  17992. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  17993. designer.SetDataSource("Rate", dto.title.Rate);
  17994. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  17995. var Aparams = hotels.Find(x => x.Type == "Default");
  17996. if (Aparams == null)
  17997. {
  17998. return Ok(jw);
  17999. }
  18000. //酒店数量
  18001. var txtSGRNumber = Aparams.SGR.ToString();
  18002. var txtTBRNumber = Aparams.TBR.ToString();
  18003. var txtJSESNumber = Aparams.JSES.ToString();
  18004. var txtSUITENumbe = Aparams.SUITE.ToString();
  18005. if (dto.costType == "B")
  18006. {
  18007. Aparams = hotels.Find(x => x.Type == "A");
  18008. var Bparams = hotels.Find(x => x.Type == "B");
  18009. if (Aparams == null || Bparams == null)
  18010. {
  18011. return Ok(jw);
  18012. }
  18013. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  18014. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  18015. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  18016. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  18017. }
  18018. designer.SetDataSource("SGRNumber", txtSGRNumber);
  18019. designer.SetDataSource("TBRNumber", txtTBRNumber);
  18020. designer.SetDataSource("JSESNumber", txtJSESNumber);
  18021. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  18022. var ws = designer.Workbook.Worksheets[1];
  18023. int Row = List_GC.Count;
  18024. int startIndex = 0;
  18025. int HideRows = 0;
  18026. Row = 0;
  18027. List<int> hideRowsList = new List<int>();
  18028. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  18029. #region A段left数据
  18030. var left = dto.leftInfo.Find(x => x.Type == "A");
  18031. if (left == null)
  18032. {
  18033. return Ok(jw);
  18034. }
  18035. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  18036. if (leftBindData != null)
  18037. {
  18038. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  18039. designer.SetDataSource("VisaRS", leftBindData.rs);
  18040. designer.SetDataSource("VisaXS", leftBindData.xs);
  18041. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18042. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18043. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18044. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18045. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18046. }
  18047. else
  18048. {
  18049. hideRowsList.Add(Row + startIndex + HideRows);
  18050. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18051. }
  18052. HideRows += 2;
  18053. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  18054. if (leftBindData != null)
  18055. {
  18056. designer.SetDataSource("BXDRCB", leftBindData.cb);
  18057. designer.SetDataSource("BXRS", leftBindData.rs);
  18058. designer.SetDataSource("BXXS", leftBindData.xs);
  18059. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18060. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18061. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18062. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18063. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18064. }
  18065. else
  18066. {
  18067. hideRowsList.Add(Row + startIndex + HideRows);
  18068. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18069. }
  18070. HideRows += 2;
  18071. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  18072. if (leftBindData != null)
  18073. {
  18074. designer.SetDataSource("HSDRCB", leftBindData.cb);
  18075. designer.SetDataSource("HSRS", leftBindData.rs);
  18076. designer.SetDataSource("HSXS", leftBindData.xs);
  18077. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18078. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18079. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18080. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18081. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18082. }
  18083. else
  18084. {
  18085. hideRowsList.Add(Row + startIndex + HideRows);
  18086. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18087. }
  18088. HideRows += 2;
  18089. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  18090. if (leftBindData != null)
  18091. {
  18092. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  18093. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  18094. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  18095. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18096. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18097. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18098. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18099. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18100. }
  18101. else
  18102. {
  18103. hideRowsList.Add(Row + startIndex + HideRows);
  18104. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18105. }
  18106. HideRows += 2;
  18107. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  18108. if (leftBindData != null)
  18109. {
  18110. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  18111. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  18112. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  18113. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18114. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18115. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18116. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18117. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18118. }
  18119. else
  18120. {
  18121. hideRowsList.Add(Row + startIndex + HideRows);
  18122. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18123. }
  18124. HideRows += 2;
  18125. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  18126. if (leftBindData != null)
  18127. {
  18128. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  18129. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  18130. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  18131. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18132. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18133. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18134. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18135. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18136. }
  18137. else
  18138. {
  18139. hideRowsList.Add(Row + startIndex + HideRows);
  18140. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18141. }
  18142. HideRows += 2;
  18143. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  18144. if (leftBindData != null)
  18145. {
  18146. ////TBR
  18147. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  18148. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  18149. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  18150. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18151. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18152. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18153. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18154. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18155. }
  18156. else
  18157. {
  18158. hideRowsList.Add(Row + startIndex + HideRows);
  18159. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18160. }
  18161. HideRows += 2;
  18162. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  18163. if (leftBindData != null)
  18164. {
  18165. ////SGR
  18166. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  18167. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  18168. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  18169. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18170. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18171. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18172. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18173. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18174. }
  18175. else
  18176. {
  18177. hideRowsList.Add(Row + startIndex + HideRows);
  18178. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18179. }
  18180. HideRows += 2;
  18181. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  18182. if (leftBindData != null)
  18183. {
  18184. ////JS/ES
  18185. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  18186. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  18187. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  18188. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18189. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18190. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18191. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18192. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18193. }
  18194. else
  18195. {
  18196. hideRowsList.Add(Row + startIndex + HideRows);
  18197. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18198. }
  18199. HideRows += 2;
  18200. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  18201. if (leftBindData != null)
  18202. {
  18203. ////SUITE
  18204. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  18205. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  18206. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  18207. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18208. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18209. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18210. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18211. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18212. }
  18213. else
  18214. {
  18215. hideRowsList.Add(Row + startIndex + HideRows);
  18216. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18217. }
  18218. HideRows += 2;
  18219. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  18220. if (leftBindData != null)
  18221. {
  18222. designer.SetDataSource("DJDRCB", leftBindData.cb);
  18223. designer.SetDataSource("DJRS", leftBindData.rs);
  18224. designer.SetDataSource("DJXS", leftBindData.xs);
  18225. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18226. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18227. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18228. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18229. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18230. }
  18231. else
  18232. {
  18233. hideRowsList.Add(Row + startIndex + HideRows);
  18234. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18235. }
  18236. HideRows += 2;
  18237. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  18238. if (leftBindData != null)
  18239. {
  18240. designer.SetDataSource("HCPCB", leftBindData.cb);
  18241. designer.SetDataSource("HCPRS", leftBindData.rs);
  18242. designer.SetDataSource("HCPXS", leftBindData.xs);
  18243. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18244. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18245. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18246. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18247. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18248. }
  18249. else
  18250. {
  18251. hideRowsList.Add(Row + startIndex + HideRows);
  18252. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18253. }
  18254. HideRows += 2;
  18255. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  18256. if (leftBindData != null)
  18257. {
  18258. designer.SetDataSource("CPCB", leftBindData.cb);
  18259. designer.SetDataSource("CPRS", leftBindData.rs);
  18260. designer.SetDataSource("CPXS", leftBindData.xs);
  18261. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18262. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18263. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18264. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18265. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18266. }
  18267. else
  18268. {
  18269. hideRowsList.Add(Row + startIndex + HideRows);
  18270. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18271. }
  18272. HideRows += 2;
  18273. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  18274. if (leftBindData != null)
  18275. {
  18276. designer.SetDataSource("GWDRCD", leftBindData.cb);
  18277. designer.SetDataSource("GWRS", leftBindData.rs);
  18278. designer.SetDataSource("GWXS", leftBindData.xs);
  18279. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18280. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18281. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18282. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18283. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18284. }
  18285. else
  18286. {
  18287. hideRowsList.Add(Row + startIndex + HideRows);
  18288. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18289. }
  18290. HideRows += 2;
  18291. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  18292. if (leftBindData != null)
  18293. {
  18294. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  18295. designer.SetDataSource("LYJRS", leftBindData.rs);
  18296. designer.SetDataSource("LYJXS", leftBindData.xs);
  18297. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18298. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18299. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18300. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18301. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18302. }
  18303. else
  18304. {
  18305. hideRowsList.Add(Row + startIndex + HideRows);
  18306. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18307. }
  18308. #endregion
  18309. #region A段Right信息
  18310. var right = dto.rightInfo.Find(x => x.Type == "A");
  18311. if (right == null)
  18312. {
  18313. return Ok(jw);
  18314. }
  18315. HideRows += 4;
  18316. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  18317. if (rightBindData != null)
  18318. {
  18319. //经济舱 + 双人间 TBR
  18320. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  18321. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  18322. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18323. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  18324. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18325. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18326. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18327. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18328. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18329. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18330. }
  18331. else
  18332. {
  18333. hideRowsList.Add(Row + startIndex + HideRows);
  18334. }
  18335. HideRows += 2;
  18336. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  18337. if (rightBindData != null)
  18338. {
  18339. //经济舱 + 单人间 SGR
  18340. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  18341. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  18342. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18343. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  18344. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18345. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18346. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18347. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18348. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18349. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18350. }
  18351. else
  18352. {
  18353. hideRowsList.Add(Row + startIndex + HideRows);
  18354. }
  18355. HideRows += 2;
  18356. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  18357. if (rightBindData != null)
  18358. {
  18359. //公务舱 + 单人间 SGR
  18360. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  18361. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  18362. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18363. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  18364. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18365. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18366. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18367. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18368. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18369. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18370. }
  18371. else
  18372. {
  18373. hideRowsList.Add(Row + startIndex + HideRows);
  18374. }
  18375. HideRows += 2;
  18376. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  18377. if (rightBindData != null)
  18378. {
  18379. //公务舱 + 小套房 JSES
  18380. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  18381. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  18382. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18383. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  18384. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18385. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18386. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18387. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18388. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18389. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18390. }
  18391. else
  18392. {
  18393. hideRowsList.Add(Row + startIndex + HideRows);
  18394. }
  18395. HideRows += 2;
  18396. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  18397. if (rightBindData != null)
  18398. {
  18399. //公务舱 + 小套房 JSES
  18400. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  18401. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  18402. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18403. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  18404. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18405. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18406. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18407. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18408. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18409. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18410. }
  18411. else
  18412. {
  18413. hideRowsList.Add(Row + startIndex + HideRows);
  18414. }
  18415. HideRows += 2;
  18416. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  18417. if (rightBindData != null)
  18418. {
  18419. //经济舱 + 大套房
  18420. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  18421. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  18422. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18423. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  18424. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18425. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18426. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18427. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18428. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18429. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18430. }
  18431. else
  18432. {
  18433. hideRowsList.Add(Row + startIndex + HideRows);
  18434. }
  18435. HideRows += 2;
  18436. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  18437. if (rightBindData != null)
  18438. {
  18439. //头等舱 + 小套房 JSES
  18440. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  18441. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  18442. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18443. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  18444. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18445. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18446. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18447. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18448. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18449. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18450. }
  18451. else
  18452. {
  18453. hideRowsList.Add(Row + startIndex + HideRows);
  18454. }
  18455. HideRows += 2;
  18456. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  18457. if (rightBindData != null)
  18458. {
  18459. //头等舱 + 大套房
  18460. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  18461. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  18462. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18463. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  18464. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18465. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18466. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18467. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18468. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18469. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18470. }
  18471. else
  18472. {
  18473. hideRowsList.Add(Row + startIndex + HideRows);
  18474. }
  18475. #endregion
  18476. #region B段标题清空
  18477. designer.SetDataSource("CostBDRCB", "");
  18478. designer.SetDataSource("CostBRS", "");
  18479. designer.SetDataSource("CostBXS", "");
  18480. designer.SetDataSource("CostBZCB", "");
  18481. designer.SetDataSource("CostBDRBJ", "");
  18482. designer.SetDataSource("CostBZBJ", "");
  18483. designer.SetDataSource("CostBDRLR", "");
  18484. designer.SetDataSource("CostBZLR", "");
  18485. designer.SetDataSource("CostBDRCBOM", "");
  18486. designer.SetDataSource("CostBRSOM", "");
  18487. designer.SetDataSource("CostBZCBOM", "");
  18488. designer.SetDataSource("CostBDRBJOM", "");
  18489. designer.SetDataSource("CostBZBJOM", "");
  18490. designer.SetDataSource("CostBDRLROM", "");
  18491. designer.SetDataSource("CostBZLROM", "");
  18492. #endregion
  18493. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  18494. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  18495. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  18496. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  18497. designer.SetDataSource("DJName", "地接(CNY)");
  18498. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  18499. designer.SetDataSource("CPName", "地接-船票(CNY)");
  18500. designer.SetDataSource("GWName", "公务(CNY)");
  18501. designer.SetDataSource("YQHName", "邀请函(CNY)");
  18502. designer.SetDataSource("LYJName", "零用金(CNY)");
  18503. designer.SetDataSource("HSName", "核酸检测(CNY)");
  18504. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  18505. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  18506. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  18507. designer.SetDataSource("BXName", "保险(CNY)");
  18508. designer.SetDataSource("VisaName", "签证(CNY)");
  18509. #region B段基本数据
  18510. if (dto.costType == "B")
  18511. {
  18512. left = dto.leftInfo.Find(x => x.Type == "B");
  18513. if (left == null)
  18514. {
  18515. return Ok(jw);
  18516. }
  18517. #region B段left数据
  18518. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  18519. if (leftBindData != null)
  18520. {
  18521. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  18522. designer.SetDataSource("BHSRS", leftBindData.rs);
  18523. designer.SetDataSource("BHSXS", leftBindData.xs);
  18524. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18525. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18526. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18527. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18528. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18529. }
  18530. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  18531. if (leftBindData != null)
  18532. {
  18533. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  18534. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  18535. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  18536. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18537. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18538. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18539. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18540. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18541. }
  18542. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  18543. if (leftBindData != null)
  18544. {
  18545. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  18546. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  18547. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  18548. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18549. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18550. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18551. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18552. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18553. }
  18554. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  18555. if (leftBindData != null)
  18556. {
  18557. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  18558. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  18559. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  18560. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18561. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18562. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18563. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18564. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18565. }
  18566. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  18567. if (leftBindData != null)
  18568. {
  18569. designer.SetDataSource("BHCPCB", leftBindData.cb);
  18570. designer.SetDataSource("BHCPRS", leftBindData.rs);
  18571. designer.SetDataSource("BHCPXS", leftBindData.xs);
  18572. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18573. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18574. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18575. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18576. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18577. }
  18578. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  18579. if (leftBindData != null)
  18580. {
  18581. designer.SetDataSource("BCPCB", leftBindData.cb);
  18582. designer.SetDataSource("BCPRS", leftBindData.rs);
  18583. designer.SetDataSource("BCPXS", leftBindData.xs);
  18584. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18585. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18586. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18587. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18588. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18589. }
  18590. //TBR
  18591. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  18592. if (leftBindData != null)
  18593. {
  18594. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  18595. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  18596. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  18597. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18598. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18599. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18600. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18601. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18602. }
  18603. //SGR
  18604. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  18605. if (leftBindData != null)
  18606. {
  18607. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  18608. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  18609. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  18610. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18611. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18612. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18613. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18614. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18615. }
  18616. //JS/ES
  18617. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  18618. if (leftBindData != null)
  18619. {
  18620. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  18621. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  18622. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  18623. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18624. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18625. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18626. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18627. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18628. }
  18629. //SUITE
  18630. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  18631. if (leftBindData != null)
  18632. {
  18633. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  18634. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  18635. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  18636. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18637. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18638. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18639. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18640. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18641. }
  18642. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  18643. if (leftBindData != null)
  18644. {
  18645. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  18646. designer.SetDataSource("BDJRS", leftBindData.rs);
  18647. designer.SetDataSource("BDJXS", leftBindData.xs);
  18648. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18649. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18650. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18651. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18652. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18653. }
  18654. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  18655. if (leftBindData != null)
  18656. {
  18657. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  18658. designer.SetDataSource("BGWRS", leftBindData.rs);
  18659. designer.SetDataSource("BGWXS", leftBindData.xs);
  18660. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18661. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18662. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18663. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18664. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18665. }
  18666. #region 优化方案
  18667. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  18668. //excelBind.Add("零用金", new {
  18669. //cb="",
  18670. //rs="",
  18671. //xs ="",
  18672. //zcb = "",
  18673. //});
  18674. #endregion
  18675. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  18676. if (leftBindData != null)
  18677. {
  18678. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  18679. designer.SetDataSource("BLYJRS", leftBindData.rs);
  18680. designer.SetDataSource("BLYJXS", leftBindData.xs);
  18681. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18682. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18683. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18684. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18685. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18686. }
  18687. #endregion
  18688. #region B段Right信息
  18689. right = dto.rightInfo.Find(x => x.Type == "B");
  18690. if (right == null)
  18691. {
  18692. return Ok(jw);
  18693. }
  18694. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  18695. if (rightBindData != null)
  18696. {
  18697. //经济舱 + 双人间 TBR
  18698. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  18699. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  18700. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18701. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  18702. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18703. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18704. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18705. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18706. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18707. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18708. }
  18709. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  18710. if (rightBindData != null)
  18711. {
  18712. //经济舱 + 单人间 SGR
  18713. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  18714. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  18715. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18716. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  18717. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18718. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18719. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18720. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18721. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18722. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18723. }
  18724. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  18725. if (rightBindData != null)
  18726. {
  18727. //公务舱 + 单人间 SGR
  18728. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  18729. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  18730. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18731. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  18732. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18733. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18734. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18735. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18736. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18737. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18738. }
  18739. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  18740. if (rightBindData != null)
  18741. {
  18742. //公务舱 + 小套房 JSES
  18743. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  18744. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  18745. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18746. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  18747. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18748. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18749. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18750. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18751. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18752. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18753. }
  18754. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  18755. if (rightBindData != null)
  18756. {
  18757. //公务舱 + 小套房 JSES
  18758. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  18759. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  18760. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18761. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  18762. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18763. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18764. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18765. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18766. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18767. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18768. }
  18769. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  18770. if (rightBindData != null)
  18771. {
  18772. //经济舱 + 大套房
  18773. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  18774. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  18775. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18776. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  18777. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18778. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18779. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18780. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18781. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18782. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18783. }
  18784. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  18785. if (rightBindData != null)
  18786. {
  18787. //头等舱 + 小套房 JSES
  18788. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  18789. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  18790. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18791. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  18792. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18793. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18794. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18795. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18796. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18797. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18798. }
  18799. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  18800. if (rightBindData != null)
  18801. {
  18802. //头等舱 + 大套房
  18803. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  18804. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  18805. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18806. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  18807. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18808. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18809. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18810. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18811. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18812. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18813. }
  18814. #endregion
  18815. #region 标题
  18816. designer.SetDataSource("CostBDRCB", "单人成本");
  18817. designer.SetDataSource("CostBRS", "人数");
  18818. designer.SetDataSource("CostBXS", "系数");
  18819. designer.SetDataSource("CostBZCB", "总成本");
  18820. designer.SetDataSource("CostBDRBJ", "单人报价");
  18821. designer.SetDataSource("CostBZBJ", "总报价");
  18822. designer.SetDataSource("CostBDRLR", "单人利润");
  18823. designer.SetDataSource("CostBZLR", "总利润");
  18824. designer.SetDataSource("CostBDRCBOM", "单人成本");
  18825. designer.SetDataSource("CostBRSOM", "人数");
  18826. designer.SetDataSource("CostBZCBOM", "总成本");
  18827. designer.SetDataSource("CostBDRBJOM", "单人报价");
  18828. designer.SetDataSource("CostBZBJOM", "总报价");
  18829. designer.SetDataSource("CostBDRLROM", "单人利润");
  18830. designer.SetDataSource("CostBZLROM", "总利润");
  18831. #endregion
  18832. }
  18833. #endregion
  18834. designer.SetDataSource("TzZCB2", TzZCB2);
  18835. designer.SetDataSource("TzZBJ2", TzZBJ2);
  18836. designer.SetDataSource("TzZLR2", TzZLR2);
  18837. string[] dataSourceKeys = new string[]
  18838. {
  18839. "VF",
  18840. "TGS",
  18841. "TGOF",
  18842. "TGM",
  18843. "TGA",
  18844. "TGTF",
  18845. "TGEF",
  18846. "CFM",
  18847. "CFOF",
  18848. "B",
  18849. "L",
  18850. "D",
  18851. "TBR",
  18852. "SGR",
  18853. "JSES",
  18854. "Suite",
  18855. "TV",
  18856. "1L",
  18857. "IF",
  18858. "EF",
  18859. "BRF",
  18860. "TE",
  18861. "TGT",
  18862. "DRVT",
  18863. "PC",
  18864. "TLF",
  18865. "ECT"
  18866. };
  18867. foreach (var item in dataSourceKeys)
  18868. {
  18869. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  18870. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  18871. var find = dto.titleModel.FirstOrDefault(expr);
  18872. if (find != null)
  18873. {
  18874. designer.SetDataSource(item, find.text);
  18875. }
  18876. else
  18877. {
  18878. designer.SetDataSource(item, 0);
  18879. }
  18880. }
  18881. designer.SetDataSource(dt);
  18882. //根据数据源处理生成报表内容
  18883. designer.Process();
  18884. designer.Workbook.Worksheets[0].Name = "费用明细";
  18885. designer.Workbook.Worksheets[1].Name = "费用总核算";
  18886. Worksheet sheet = designer.Workbook.Worksheets[0];
  18887. #region 隐藏舱位
  18888. var settingAir = new[]
  18889. {
  18890. new { key = "经济舱", index = 7 },
  18891. new { key = "公务舱", index = 19 },
  18892. new { key = "头等舱", index = 11 }
  18893. };
  18894. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  18895. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  18896. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  18897. .Select((c, s) => s.Name)
  18898. .ToList()
  18899. .GroupBy(x => x)
  18900. .Select(x => x.Key);
  18901. foreach (var item in settingAir)
  18902. {
  18903. if (!airType.Contains(item.key))
  18904. {
  18905. hideRowsList.Add(item.index);
  18906. }
  18907. }
  18908. #endregion
  18909. foreach (var Rowindex in hideRowsList)
  18910. {
  18911. ws.Cells.HideRows(Rowindex, 2);
  18912. }
  18913. ws = designer.Workbook.Worksheets[0];
  18914. foreach (var Column in hideColumnList)
  18915. {
  18916. ws.Cells.HideColumns(Column, 1);
  18917. }
  18918. byte[] bytes = null;
  18919. string strFileName = di.TeamName + "-团组-成本.xls";
  18920. using (MemoryStream stream = new MemoryStream())
  18921. {
  18922. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  18923. bytes = stream.ToArray();
  18924. }
  18925. return Ok(JsonView(true, "", new
  18926. {
  18927. Data = bytes,
  18928. strFileName,
  18929. }));
  18930. }
  18931. /// <summary>
  18932. /// 导出客户报表
  18933. /// </summary>
  18934. /// <returns></returns>
  18935. [HttpPost]
  18936. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  18937. {
  18938. var jw = JsonView(false);
  18939. if (dto.Diid == 0)
  18940. {
  18941. return Ok(JsonView(false, "请传递团组id"));
  18942. }
  18943. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  18944. if (deleInfo.Code != 0)
  18945. {
  18946. return Ok(JsonView(false, "团组信息查询失败!"));
  18947. }
  18948. var di = deleInfo.Data as DelegationInfoWebView;
  18949. if (di == null)
  18950. {
  18951. return Ok(JsonView(false, "团组信息查询失败!"));
  18952. }
  18953. //文件名
  18954. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  18955. //获取模板
  18956. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  18957. //载入模板
  18958. Document doc = new Document(tmppath);
  18959. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  18960. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  18961. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  18962. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  18963. var AParameter = ParameterList.Find(x => x.CostType == "A");
  18964. var BParameter = ParameterList.Find(x => x.CostType == "B");
  18965. if (AParameter == null)
  18966. {
  18967. return Ok(JsonView(false, "系数不存在!"));
  18968. }
  18969. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  18970. , TzAirDesc, TzZCost;
  18971. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  18972. = TzAirDesc = TzZCost = string.Empty;
  18973. TzNumber = AParameter.CostTypenumber.ToString();
  18974. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  18975. CarGuides1 = dto.CarGuides1;
  18976. Meal = dto.Meal;
  18977. SubsidizedMeals = dto.SubsidizedMeals;
  18978. NightRepair = dto.NightRepair;
  18979. AttractionsTickets = dto.AttractionsTickets;
  18980. MiscellaneousFees = dto.MiscellaneousFees;
  18981. ATip = dto.ATip;
  18982. TzHotelDesc = "";
  18983. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  18984. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  18985. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  18986. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  18987. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  18988. TzAirDesc = "";
  18989. TzZCost = dto.TzZCost;
  18990. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  18991. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  18992. var index = 1;
  18993. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  18994. foreach (var item in TzHotelDescArr)
  18995. {
  18996. if (AinfoArr != null)
  18997. {
  18998. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  18999. if (Ainfo != null)
  19000. {
  19001. if (int.Parse(Ainfo.rs) <= 0)
  19002. {
  19003. continue;
  19004. }
  19005. var hotelText = string.Empty;
  19006. switch (item)
  19007. {
  19008. case "SGR":
  19009. hotelText = "单人间";
  19010. break;
  19011. case "JSES":
  19012. hotelText = "小套房";
  19013. break;
  19014. case "SUITE":
  19015. hotelText = "套房";
  19016. break;
  19017. case "TBR":
  19018. hotelText = "双人间";
  19019. break;
  19020. }
  19021. if (item != "TBR")
  19022. {
  19023. 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";
  19024. }
  19025. else
  19026. {
  19027. 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";
  19028. }
  19029. index++;
  19030. }
  19031. }
  19032. }
  19033. index = 1;
  19034. foreach (var item in TzAirDescArr)
  19035. {
  19036. if (AinfoArr != null)
  19037. {
  19038. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19039. if (Ainfo != null)
  19040. {
  19041. if (int.Parse(Ainfo.rs) <= 0)
  19042. {
  19043. continue;
  19044. }
  19045. 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";
  19046. index++;
  19047. }
  19048. }
  19049. }
  19050. if (dto.costType == "B")
  19051. {
  19052. if (BParameter == null)
  19053. {
  19054. return Ok(JsonView(false, "B段系数不存在!"));
  19055. }
  19056. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  19057. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  19058. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  19059. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  19060. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  19061. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  19062. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  19063. foreach (var item in TzHotelDescArr)
  19064. {
  19065. if (AinfoArr != null)
  19066. {
  19067. TzHotelDesc += "B段信息 \r\n";
  19068. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19069. if (Ainfo != null)
  19070. {
  19071. if (int.Parse(Ainfo.rs) <= 0)
  19072. {
  19073. continue;
  19074. }
  19075. var hotelText = string.Empty;
  19076. switch (item)
  19077. {
  19078. case "SGR":
  19079. hotelText = "单人间";
  19080. break;
  19081. case "JSES":
  19082. hotelText = "小套房";
  19083. break;
  19084. case "SUITE":
  19085. hotelText = "套房";
  19086. break;
  19087. case "TBR":
  19088. hotelText = "双人间";
  19089. break;
  19090. }
  19091. if (item != "TBR")
  19092. {
  19093. 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";
  19094. }
  19095. else
  19096. {
  19097. 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";
  19098. }
  19099. index++;
  19100. }
  19101. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  19102. }
  19103. }
  19104. index = 1;
  19105. foreach (var item in TzAirDescArr)
  19106. {
  19107. if (AinfoArr != null)
  19108. {
  19109. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19110. if (Ainfo != null)
  19111. {
  19112. if (int.Parse(Ainfo.rs) <= 0)
  19113. {
  19114. continue;
  19115. }
  19116. 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";
  19117. index++;
  19118. }
  19119. }
  19120. }
  19121. }
  19122. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  19123. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  19124. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  19125. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  19126. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  19127. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  19128. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  19129. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  19130. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  19131. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  19132. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  19133. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  19134. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  19135. DickeyValue.Add("Visa", Visa); // 签证单人报价
  19136. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  19137. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  19138. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  19139. DickeyValue.Add("TzZCost", TzZCost);
  19140. foreach (var key in DickeyValue.Keys)
  19141. {
  19142. if (doc.Range.Bookmarks[key] != null)
  19143. {
  19144. Bookmark mark = doc.Range.Bookmarks[key];
  19145. mark.Text = DickeyValue[key];
  19146. }
  19147. }
  19148. byte[] bytes = null;
  19149. string strFileName = di.TeamName + "-客户报价.doc";
  19150. using (MemoryStream stream = new MemoryStream())
  19151. {
  19152. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  19153. bytes = stream.ToArray();
  19154. }
  19155. return Ok(JsonView(true, "", new
  19156. {
  19157. Data = bytes,
  19158. strFileName,
  19159. }));
  19160. }
  19161. /// <summary>
  19162. /// 团组成本 各模块(酒店,地接,机票)成本提示
  19163. /// </summary>
  19164. /// <param name="dto"></param>
  19165. /// <returns></returns>
  19166. [HttpPost]
  19167. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19168. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  19169. {
  19170. try
  19171. {
  19172. #region 参数验证
  19173. if (dto.DiId < 0)
  19174. {
  19175. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  19176. }
  19177. List<int> cTableIds = new List<int>() {
  19178. 76 ,//酒店预订
  19179. 77 ,//行程
  19180. 79 ,//车/导游地接
  19181. 80 ,//签证
  19182. 81 ,//邀请/公务活
  19183. 82 ,//团组客户保险
  19184. 85 ,//机票预订
  19185. 98 ,//其他款项
  19186. 285 ,//收款退还
  19187. 751 ,//酒店早餐
  19188. 1015 // 超支费用
  19189. };
  19190. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  19191. {
  19192. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  19193. }
  19194. #endregion
  19195. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  19196. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  19197. if (_GroupCostParameters.Count <= 0)
  19198. {
  19199. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  19200. }
  19201. if (_GroupCostParameters[0].IsShare == 0)
  19202. {
  19203. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  19204. }
  19205. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  19206. //处理date为空问题
  19207. if (_GroupCosts.Count > 0)
  19208. {
  19209. for (int i = 0; i < _GroupCosts.Count; i++)
  19210. {
  19211. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  19212. {
  19213. if (i > 0)
  19214. {
  19215. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  19216. }
  19217. }
  19218. }
  19219. }
  19220. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  19221. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  19222. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  19223. string currCode = "";
  19224. #region currCode 验证
  19225. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  19226. if (isInt)
  19227. {
  19228. var currData = currDatas.Find(it => it.Id == intCurrency);
  19229. if (currData != null)
  19230. {
  19231. currCode = currData.Name;
  19232. }
  19233. }
  19234. else
  19235. {
  19236. currCode = _GroupCostParameters[0].Currency.Trim();
  19237. }
  19238. #endregion
  19239. //op,酒店单段模式存储
  19240. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  19241. {
  19242. CurrencyCode = currCode,
  19243. Rate = _GroupCostParameters[0].Rate,
  19244. CostType = _GroupCostParameters[0].CostType,
  19245. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  19246. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  19247. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  19248. };
  19249. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  19250. if (_GroupCostParameters.Count == 2)
  19251. {
  19252. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  19253. }
  19254. foreach (var item in _GroupCostParameters)
  19255. {
  19256. decimal _rate = 1;
  19257. decimal _rate1 = item.Rate;
  19258. decimal _scale = 1;
  19259. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  19260. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  19261. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  19262. //if (userInfo != null)
  19263. //{
  19264. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  19265. // {
  19266. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  19267. // {
  19268. // _scale = 1.00M;
  19269. // }
  19270. // }
  19271. //}
  19272. #endregion
  19273. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  19274. {
  19275. CurrencyCode = currCode,
  19276. Rate = _rate1,
  19277. CostType = item.CostType,
  19278. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  19279. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  19280. CostTypeNumber = item.CostTypenumber
  19281. };
  19282. if (_GroupCostParameters.Count > 1)
  19283. {
  19284. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  19285. }
  19286. else
  19287. {
  19288. modulePromptInfo.CostTypeNumber = item.LYJRS;
  19289. }
  19290. if (dto.CTable == 79)//
  19291. {
  19292. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  19293. modulePromptInfo.TotalCost = item.DJCB;
  19294. }
  19295. List<string> costTypes = new List<string>() { "A", "B" };
  19296. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  19297. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  19298. if (_GroupCostsDuplicates.Count() == 1)
  19299. {
  19300. _GroupCostsTypeData = _GroupCosts;
  19301. }
  19302. else
  19303. {
  19304. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  19305. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  19306. }
  19307. /*
  19308. * 76 酒店预订
  19309. * 77 行程
  19310. * 79 车/导游地接
  19311. * 80 签证
  19312. * 81 邀请/公务活动
  19313. * 82 团组客户保险
  19314. * 85 机票预订
  19315. * 98 其他款项
  19316. * 285 收款退还
  19317. * 751 酒店早餐
  19318. * 1015 超支费用
  19319. */
  19320. switch (dto.CTable)
  19321. {
  19322. case 76: // 酒店预订
  19323. _ModuleSubPromptInfo.AddRange(
  19324. _GroupCostsTypeData.Select(it => new
  19325. {
  19326. it.DAY,
  19327. it.Date,
  19328. it.ACCON,
  19329. it.ITIN,
  19330. it.SGR,
  19331. it.TBR,
  19332. it.JS_ES,
  19333. it.Suite
  19334. })
  19335. );
  19336. break;
  19337. case 79: // 车/导游地接
  19338. _ModuleSubPromptInfo.AddRange(
  19339. _GroupCostsTypeData.Select(it => new
  19340. {
  19341. Date = it.Date, //日期
  19342. CarFee = it.CarCost * _rate * _scale, //车费用
  19343. CarType = it.CarType, //车型
  19344. DriverFee = it.CFS * _rate * _scale, //司机工资
  19345. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  19346. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  19347. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  19348. GuideFee = it.TGS * _rate * _scale, //导游费用
  19349. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  19350. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  19351. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  19352. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  19353. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  19354. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  19355. Breakfast = it.B * _rate * _scale, //早餐费
  19356. Lunch = it.L * _rate * _scale, //午餐费
  19357. Dinner = it.D * _rate * _scale, //晚餐费
  19358. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  19359. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  19360. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  19361. TicketFee = it.EF * _rate * _scale, //门票费
  19362. TicketRemark = it.EFR, //门票费描述
  19363. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  19364. TravelSupplies = it.TE * _rate * _scale, //出行物资
  19365. SpentCash = it.PC * _rate * _scale, //零用金
  19366. LeadersFee = it.TLF * _rate * _scale, //领队费
  19367. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  19368. })
  19369. );
  19370. break;
  19371. case 85: // 机票
  19372. List<dynamic> datas = new List<dynamic>();
  19373. datas.Add(
  19374. new
  19375. {
  19376. AirType = "经济舱",
  19377. AirNum = item.JJCRS,
  19378. AirDRCB = item.JJCCB,
  19379. AirZCB = (item.JJCRS * item.JJCCB)
  19380. }
  19381. );
  19382. datas.Add(
  19383. new
  19384. {
  19385. AirType = "公务舱",
  19386. AirNum = item.GWCRS,
  19387. AirDRCB = item.GWCCB,
  19388. AirZCB = (item.GWCRS * item.GWCCB)
  19389. }
  19390. );
  19391. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  19392. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  19393. modulePromptInfo.Data = new
  19394. {
  19395. airFeeData = datas,
  19396. airInitData = initDatas
  19397. };
  19398. _ModulePromptInfos.Add(modulePromptInfo);
  19399. break;
  19400. default:
  19401. break;
  19402. }
  19403. }
  19404. if (dto.CTable != 85)
  19405. {
  19406. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  19407. _ModulePromptInfos.Add(_ModulePromptInfo);
  19408. }
  19409. _view.ModulePromptInfos = _ModulePromptInfos;
  19410. return Ok(JsonView(true, "操作成功!", _view));
  19411. }
  19412. catch (Exception ex)
  19413. {
  19414. return Ok(JsonView(false, ex.Message));
  19415. }
  19416. }
  19417. /// <summary>
  19418. /// 根据黑屏代码重新生成行程
  19419. /// </summary>
  19420. /// <param name="dto"></param>
  19421. /// <returns></returns>
  19422. [HttpPost]
  19423. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  19424. {
  19425. var jw = JsonView(false, "Error");
  19426. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19427. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  19428. .Select(x => new
  19429. {
  19430. x.Id,
  19431. x.Title
  19432. })
  19433. .ToList();
  19434. if (Create.Any())
  19435. {
  19436. jw.Msg = "获取成功!";
  19437. jw.Code = 200;
  19438. jw.Data = new
  19439. {
  19440. BlackCodeListSelect = Create,
  19441. blackCodeIsTrue = true
  19442. };
  19443. }
  19444. else
  19445. {
  19446. jw.Code = 400;
  19447. jw.Data = new
  19448. {
  19449. BlackCodeListSelect = Create,
  19450. blackCodeIsTrue = false,
  19451. };
  19452. }
  19453. return Ok(jw);
  19454. }
  19455. /// <summary>
  19456. /// 根据黑屏代码Id重新生成行程
  19457. /// </summary>
  19458. /// <param name="dto"></param>
  19459. /// <returns></returns>
  19460. [HttpPost]
  19461. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  19462. {
  19463. var jw = JsonView(false, "Error");
  19464. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  19465. if (result.Code == 0)
  19466. {
  19467. jw.Msg = "获取成功!";
  19468. jw.Code = 200;
  19469. jw.Data = new
  19470. {
  19471. groupCost = result.Data,
  19472. blackCodeIsTrue = true
  19473. };
  19474. }
  19475. else
  19476. {
  19477. jw.Code = 400;
  19478. jw.Data = new
  19479. {
  19480. groupCost = result.Data,
  19481. blackCodeIsTrue = false,
  19482. };
  19483. }
  19484. return Ok(jw);
  19485. }
  19486. /// <summary>
  19487. /// 成本获取OP历史车费用
  19488. /// </summary>
  19489. /// <param name="dto"></param>
  19490. /// <returns></returns>
  19491. [HttpPost]
  19492. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  19493. {
  19494. var jw = JsonView(false);
  19495. try
  19496. {
  19497. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  19498. //获取现有所有车的数据
  19499. if (!dto.Param.IsNullOrWhiteSpace())
  19500. {
  19501. string sql = $@"
  19502. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  19503. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  19504. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  19505. 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
  19506. AND gctggr.ServiceEndTime is not NULL
  19507. ORDER by gctggrc.id DESC
  19508. ";
  19509. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  19510. var numeberResult = await Task.Run(() =>
  19511. {
  19512. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  19513. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  19514. return numberArr;
  19515. });
  19516. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  19517. foreach (var item in numeberResult)
  19518. {
  19519. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  19520. {
  19521. Country = "数据异常!",
  19522. City = string.Empty,
  19523. };
  19524. item.Area = find.Country + " " + find.City;
  19525. }
  19526. dbResult.AddRange(numeberResult);
  19527. if (dto.Param.Contains("、"))
  19528. {
  19529. var sp = dto.Param.Split("、");
  19530. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  19531. .Where(x =>
  19532. {
  19533. return System.Array.Exists(sp, e =>
  19534. {
  19535. bool where = false;
  19536. if (x.Area != null)
  19537. {
  19538. where = x.Area.Contains(e);
  19539. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  19540. {
  19541. return false;
  19542. }
  19543. }
  19544. if (x.PriceName != null && !where)
  19545. {
  19546. where = x.PriceName.Contains(e);
  19547. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  19548. {
  19549. return false;
  19550. }
  19551. }
  19552. return where;
  19553. });
  19554. }).ToList();
  19555. }
  19556. else
  19557. {
  19558. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  19559. .Where(x =>
  19560. {
  19561. bool where = false;
  19562. if (x.Area != null)
  19563. {
  19564. where = x.Area.Contains(dto.Param);
  19565. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  19566. {
  19567. return false;
  19568. }
  19569. }
  19570. if (x.PriceName != null && !where)
  19571. {
  19572. where = x.PriceName.Contains(dto.Param);
  19573. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  19574. {
  19575. return false;
  19576. }
  19577. }
  19578. return where;
  19579. }
  19580. )
  19581. .ToList();
  19582. }
  19583. }
  19584. var view = dbResult.Select(x =>
  19585. {
  19586. decimal dp = 0.00M;
  19587. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  19588. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  19589. if (string.IsNullOrWhiteSpace(x.DatePrice))
  19590. {
  19591. if (startB && endB)
  19592. {
  19593. var timesp = endD.Subtract(startD);
  19594. if ((timesp.Days + 1) != 0)
  19595. {
  19596. dp = x.Price / (timesp.Days + 1);
  19597. }
  19598. }
  19599. }
  19600. else
  19601. {
  19602. dp = x.Price;
  19603. }
  19604. return new
  19605. {
  19606. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  19607. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  19608. x.Area,
  19609. x.id,
  19610. price = x.Price.ToString("F2"),
  19611. x.PriceName,
  19612. x.PriceContent,
  19613. x.TeamName,
  19614. x.DatePrice,
  19615. dayPrice = dp.ToString("F2"),
  19616. };
  19617. }).OrderByDescending(x => x.id).ToList();
  19618. jw = JsonView(true, "获取成功!", view);
  19619. }
  19620. catch (Exception e)
  19621. {
  19622. jw = JsonView(false, e.Message);
  19623. }
  19624. return Ok(jw);
  19625. }
  19626. [HttpPost]
  19627. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  19628. {
  19629. var jw = JsonView(true);
  19630. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  19631. #region SQL语句
  19632. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  19633. //{
  19634. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  19635. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  19636. // WHEN COUNT(*) >= 0 THEN 'True'
  19637. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  19638. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  19639. // ")
  19640. // .ToList();
  19641. //}
  19642. //else
  19643. //{
  19644. // string likeKey = string.Empty;
  19645. // foreach (var item in dto.Keyword)
  19646. // {
  19647. // likeKey += "%" + item;
  19648. // }
  19649. // likeKey += "%";
  19650. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  19651. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  19652. // WHEN COUNT(*) >= 0 THEN 'True'
  19653. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  19654. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  19655. // ")
  19656. // .ToList();
  19657. //}
  19658. #endregion
  19659. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  19660. {
  19661. @KeyWord = dto.Keyword
  19662. });
  19663. if (table != null && table.Rows.Count > 0)
  19664. {
  19665. foreach (DataRow row in table.Rows)
  19666. {
  19667. matches.Add(new DelegationInfoAndIsTrueView
  19668. {
  19669. Id = row.Field<int>("Id"),
  19670. GroupName = row.Field<string>("GroupName"),
  19671. isTrue = row.Field<string>("isTrue")
  19672. });
  19673. }
  19674. }
  19675. if (matches.Any())
  19676. {
  19677. jw.Data = matches;
  19678. }
  19679. else
  19680. {
  19681. jw.Code = 201;
  19682. jw.Msg = "empty list";
  19683. jw.Data = new List<string>(1);
  19684. }
  19685. return Ok(jw);
  19686. }
  19687. /// <summary>
  19688. /// 报价Word下载
  19689. /// </summary>
  19690. /// <param name="dto"></param>
  19691. /// <returns></returns>
  19692. [HttpPost]
  19693. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  19694. {
  19695. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  19696. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  19697. if (di == null)
  19698. {
  19699. return Ok(JsonView(false, "团组不存在!"));
  19700. }
  19701. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  19702. if (mainPrice == null || mainPrice.IsShare == 0)
  19703. {
  19704. return Ok(JsonView(false, "团组成本不存在!"));
  19705. }
  19706. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  19707. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  19708. if (costTypeHotelNumbers == null)
  19709. {
  19710. return Ok(JsonView(false, "团组成本不存在!"));
  19711. }
  19712. //文件名
  19713. string strFileName = di.TeamName + "-收款账单.doc";
  19714. //获取模板
  19715. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  19716. //载入模板
  19717. Document doc = new Document(tmppath);
  19718. decimal allPrice = 0.00M;
  19719. string itemStr = string.Empty;
  19720. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  19721. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  19722. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  19723. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  19724. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  19725. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  19726. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  19727. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  19728. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  19729. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  19730. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  19731. {
  19732. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  19733. ("BXRS", "BXCB", "BXXS", "bx"),
  19734. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  19735. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  19736. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  19737. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  19738. ("CPRS", "CPCB", "CPXS", "cp"),
  19739. ("HSRS", "HSCB", "HSXS", "hsjc"),
  19740. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  19741. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  19742. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  19743. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  19744. ("DJRS", "DJCB", "DJXS", "dj"),
  19745. ("GWRS", "GWCB", "GWXS", "gw"),
  19746. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  19747. };
  19748. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  19749. var rightSum = 0.00M;
  19750. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  19751. {
  19752. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  19753. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  19754. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  19755. if (prefix == "tbr")
  19756. {
  19757. rsValue *= 2;
  19758. cbValue /= 2;
  19759. }
  19760. if (OtherCostPropertyBJ.Contains(prefix))
  19761. {
  19762. rightSum += cbValue * xsValue;
  19763. }
  19764. }
  19765. var hotelRooms = new Dictionary<string, int>
  19766. {
  19767. { "SGR", costTypeHotelNumbers.SGR },
  19768. { "TBR", costTypeHotelNumbers.TBR },
  19769. { "JSES", costTypeHotelNumbers.JSES },
  19770. { "SUITE", costTypeHotelNumbers.SUITE }
  19771. };
  19772. var flights = new Dictionary<string, int>
  19773. {
  19774. { "经济舱", mainPrice.JJCRS },
  19775. { "公务舱", mainPrice.GWCRS },
  19776. { "头等舱", mainPrice.TDCRS }
  19777. };
  19778. var flightRoomMatchingRules = new Dictionary<string, string[]>
  19779. {
  19780. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  19781. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  19782. { "头等舱", new[] { "SUITE", "JSES" } }
  19783. };
  19784. var result = new Dictionary<string, int>();
  19785. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  19786. foreach (var flight in flights.Keys)
  19787. {
  19788. // 获取当前舱位的匹配规则
  19789. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  19790. {
  19791. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  19792. }
  19793. }
  19794. #region right计算
  19795. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  19796. {
  19797. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19798. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  19799. airHotelPriceList.Add(new
  19800. AirHotelPrice
  19801. {
  19802. Name = "经济舱TBR",
  19803. Price = rightSum + air + hotel,
  19804. Count = result["经济舱TBR"] * 2
  19805. });
  19806. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  19807. }
  19808. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  19809. {
  19810. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19811. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  19812. airHotelPriceList.Add(new
  19813. AirHotelPrice
  19814. {
  19815. Name = "经济舱SGR",
  19816. Price = rightSum + air + hotel,
  19817. Count = result["经济舱SGR"]
  19818. });
  19819. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  19820. }
  19821. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  19822. {
  19823. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  19824. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  19825. airHotelPriceList.Add(new
  19826. AirHotelPrice
  19827. {
  19828. Name = "公务舱SGR",
  19829. Price = rightSum + air + hotel,
  19830. Count = result["公务舱SGR"]
  19831. });
  19832. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  19833. }
  19834. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  19835. {
  19836. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  19837. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  19838. airHotelPriceList.Add(new
  19839. AirHotelPrice
  19840. {
  19841. Name = "公务舱JSES",
  19842. Price = rightSum + air + hotel,
  19843. Count = result["公务舱JSES"]
  19844. });
  19845. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  19846. }
  19847. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  19848. {
  19849. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  19850. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  19851. airHotelPriceList.Add(new
  19852. AirHotelPrice
  19853. {
  19854. Name = "公务舱SUITE",
  19855. Price = rightSum + air + hotel,
  19856. Count = result["公务舱SUITE"]
  19857. });
  19858. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  19859. }
  19860. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  19861. {
  19862. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19863. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  19864. airHotelPriceList.Add(new
  19865. AirHotelPrice
  19866. {
  19867. Name = "经济舱SUITE",
  19868. Price = rightSum + air + hotel,
  19869. Count = result["经济舱SUITE"]
  19870. });
  19871. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  19872. }
  19873. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  19874. {
  19875. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  19876. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  19877. airHotelPriceList.Add(new
  19878. AirHotelPrice
  19879. {
  19880. Name = "头等舱JSES",
  19881. Price = rightSum + air + hotel,
  19882. Count = result["头等舱JSES"]
  19883. });
  19884. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  19885. }
  19886. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  19887. {
  19888. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  19889. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  19890. airHotelPriceList.Add(new
  19891. AirHotelPrice
  19892. {
  19893. Name = "头等舱SUITE",
  19894. Price = rightSum + air + hotel,
  19895. Count = result["头等舱SUITE"]
  19896. });
  19897. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  19898. }
  19899. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  19900. {
  19901. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19902. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  19903. airHotelPriceList.Add(new
  19904. AirHotelPrice
  19905. {
  19906. Name = "经济舱JSES",
  19907. Price = rightSum + air + hotel,
  19908. Count = result["经济舱JSES"]
  19909. });
  19910. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  19911. }
  19912. #endregion
  19913. foreach (var item in airSouer.Keys)
  19914. {
  19915. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  19916. if (find != null && find.Count > 0)
  19917. {
  19918. if (item.Contains("TBR"))
  19919. {
  19920. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  19921. }
  19922. else
  19923. {
  19924. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  19925. }
  19926. }
  19927. }
  19928. #region 替换Word模板书签内容
  19929. Dictionary<string, string> marks = new Dictionary<string, string>();
  19930. marks.Add("To", di.ClientUnit);//付款方
  19931. marks.Add("ToTel", di.TellPhone);//付款方电话
  19932. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  19933. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  19934. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  19935. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  19936. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  19937. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  19938. marks.Add("PayItemContent", itemStr);//详细信息
  19939. marks.Add("Total", allPrice.ToString("F2"));//合计
  19940. #endregion
  19941. foreach (var item in marks.Keys)
  19942. {
  19943. if (doc.Range.Bookmarks[item] != null)
  19944. {
  19945. Bookmark mark = doc.Range.Bookmarks[item];
  19946. mark.Text = marks[item];
  19947. }
  19948. }
  19949. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  19950. doc.Save(savePaht);
  19951. var jw = new JsonView();
  19952. jw.Msg = "生成成功!";
  19953. jw.Code = 200;
  19954. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  19955. return Ok(jw);
  19956. }
  19957. /// <summary>
  19958. /// 详细报价费用Excel下载
  19959. /// </summary>
  19960. /// <param name="dto"></param>
  19961. /// <returns></returns>
  19962. [HttpPost]
  19963. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  19964. {
  19965. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  19966. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  19967. if (di == null)
  19968. {
  19969. return Ok(JsonView(false, "团组不存在!"));
  19970. }
  19971. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  19972. if (mainPrice == null || mainPrice.IsShare == 0)
  19973. {
  19974. return Ok(JsonView(false, "团组成本不存在!"));
  19975. }
  19976. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  19977. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  19978. if (costTypeHotelNumbers == null)
  19979. {
  19980. return Ok(JsonView(false, "团组成本不存在!"));
  19981. }
  19982. WorkbookDesigner designer = new WorkbookDesigner();
  19983. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  19984. List<int> hideRowsList = new List<int>();
  19985. int conterStartIndex = 3;
  19986. int rowIndex = conterStartIndex;
  19987. designer.SetDataSource("GroupName", di.TeamName);
  19988. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  19989. {
  19990. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  19991. ("BXRS", "BXCB", "BXXS", "bx"),
  19992. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  19993. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  19994. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  19995. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  19996. ("CPRS", "CPCB", "CPXS", "cp") ,
  19997. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  19998. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  19999. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  20000. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  20001. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  20002. ("DJRS", "DJCB", "DJXS", "dj") ,
  20003. ("GWRS", "GWCB", "GWXS", "gw") ,
  20004. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  20005. };
  20006. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  20007. var rightSum = 0.00M;
  20008. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  20009. {
  20010. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  20011. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  20012. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  20013. if (prefix == "tbr")
  20014. {
  20015. rsValue *= 2;
  20016. cbValue /= 2;
  20017. }
  20018. if (OtherCostPropertyBJ.Contains(prefix))
  20019. {
  20020. rightSum += cbValue * xsValue;
  20021. }
  20022. if (rsValue == 0)
  20023. {
  20024. hideRowsList.Add(rowIndex);
  20025. }
  20026. else
  20027. {
  20028. designer.SetDataSource($"{prefix}rs", rsValue);
  20029. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  20030. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  20031. }
  20032. rowIndex += 2;
  20033. }
  20034. var hotelRooms = new Dictionary<string, int>
  20035. {
  20036. { "SGR", costTypeHotelNumbers.SGR },
  20037. { "TBR", costTypeHotelNumbers.TBR },
  20038. { "JSES", costTypeHotelNumbers.JSES },
  20039. { "SUITE", costTypeHotelNumbers.SUITE }
  20040. };
  20041. var flights = new Dictionary<string, int>
  20042. {
  20043. { "经济舱", mainPrice.JJCRS },
  20044. { "公务舱", mainPrice.GWCRS },
  20045. { "头等舱", mainPrice.TDCRS }
  20046. };
  20047. var flightRoomMatchingRules = new Dictionary<string, string[]>
  20048. {
  20049. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  20050. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  20051. { "头等舱", new[] { "SUITE", "JSES" } }
  20052. };
  20053. var result = new Dictionary<string, int>();
  20054. foreach (var flight in flights.Keys)
  20055. {
  20056. // 获取当前舱位的匹配规则
  20057. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  20058. {
  20059. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  20060. }
  20061. }
  20062. var allPrice = 0.00M;
  20063. #region right计算
  20064. int airRowIndex = 35;
  20065. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  20066. {
  20067. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20068. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  20069. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  20070. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  20071. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  20072. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  20073. }
  20074. else
  20075. {
  20076. hideRowsList.Add(airRowIndex);
  20077. }
  20078. airRowIndex += 2;
  20079. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  20080. {
  20081. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20082. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  20083. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  20084. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  20085. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  20086. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  20087. }
  20088. else
  20089. {
  20090. hideRowsList.Add(airRowIndex);
  20091. }
  20092. airRowIndex += 2;
  20093. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  20094. {
  20095. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  20096. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  20097. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  20098. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  20099. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  20100. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  20101. }
  20102. else
  20103. {
  20104. hideRowsList.Add(airRowIndex);
  20105. }
  20106. airRowIndex += 2;
  20107. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  20108. {
  20109. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  20110. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  20111. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  20112. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  20113. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  20114. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  20115. }
  20116. else
  20117. {
  20118. hideRowsList.Add(airRowIndex);
  20119. }
  20120. airRowIndex += 2;
  20121. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  20122. {
  20123. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  20124. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  20125. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  20126. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  20127. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  20128. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  20129. }
  20130. else
  20131. {
  20132. hideRowsList.Add(airRowIndex);
  20133. }
  20134. airRowIndex += 2;
  20135. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  20136. {
  20137. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20138. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  20139. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  20140. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  20141. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  20142. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  20143. }
  20144. else
  20145. {
  20146. hideRowsList.Add(airRowIndex);
  20147. }
  20148. airRowIndex += 2;
  20149. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  20150. {
  20151. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  20152. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  20153. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  20154. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  20155. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  20156. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  20157. }
  20158. else
  20159. {
  20160. hideRowsList.Add(airRowIndex);
  20161. }
  20162. airRowIndex += 2;
  20163. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  20164. {
  20165. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  20166. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  20167. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  20168. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  20169. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  20170. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  20171. }
  20172. else
  20173. {
  20174. hideRowsList.Add(airRowIndex);
  20175. }
  20176. airRowIndex += 2;
  20177. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  20178. {
  20179. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20180. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  20181. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  20182. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  20183. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  20184. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  20185. }
  20186. else
  20187. {
  20188. hideRowsList.Add(airRowIndex);
  20189. }
  20190. #endregion
  20191. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  20192. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  20193. var ws = designer.Workbook.Worksheets[0];
  20194. foreach (var Rowindex in hideRowsList)
  20195. {
  20196. ws.Cells.HideRows(Rowindex, 2);
  20197. }
  20198. designer.Process();
  20199. designer.Workbook.Save(savePaht);
  20200. return Ok(JsonView(true, "生成成功!", new
  20201. {
  20202. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  20203. }));
  20204. }
  20205. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  20206. {
  20207. foreach (var roomType in roomTypes)
  20208. {
  20209. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  20210. {
  20211. hotelRooms[roomType]--;
  20212. flights[flightType]--;
  20213. if (roomType == "TBR")
  20214. {
  20215. flights[flightType]--; // 双人间在减少1
  20216. }
  20217. string key = flightType + roomType;
  20218. if (result.Keys.Contains(key))
  20219. {
  20220. result[key]++;
  20221. }
  20222. else
  20223. {
  20224. result.Add(key, 1);
  20225. }
  20226. }
  20227. }
  20228. }
  20229. private class AirHotelPrice
  20230. {
  20231. public string Name { get; set; }
  20232. public decimal Price { get; set; }
  20233. public int Count { get; set; }
  20234. }
  20235. /// <summary>
  20236. /// 团组系数设置
  20237. /// </summary>
  20238. /// <param name="dto"></param>
  20239. /// <returns></returns>
  20240. [HttpPost]
  20241. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  20242. {
  20243. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  20244. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  20245. if (di == null)
  20246. {
  20247. return Ok(JsonView(false, "团组不存在!"));
  20248. }
  20249. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  20250. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  20251. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  20252. // FirstAsync(firstExpression.ToExpression());
  20253. #region JSON
  20254. string hcpJson = @"
  20255. [
  20256. {
  20257. ""min"": 1,
  20258. ""max"": 500,
  20259. ""value"": 1.50
  20260. },
  20261. {
  20262. ""min"": 501,
  20263. ""max"": 1000,
  20264. ""value"": 1.40
  20265. },
  20266. {
  20267. ""min"": 1001,
  20268. ""max"": 2000,
  20269. ""value"": 1.35
  20270. }
  20271. ]";
  20272. #endregion
  20273. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  20274. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  20275. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  20276. .ToList();
  20277. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  20278. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  20279. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  20280. // new List<(Predicate<decimal>, decimal)>()
  20281. // {
  20282. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  20283. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  20284. // }
  20285. // ));
  20286. #region 签证系数
  20287. var visaXS = 0.00M;
  20288. switch (dto.VisaCB)
  20289. {
  20290. case decimal n when (n > 1 && n < 500):
  20291. switch (dto.VisaRS)
  20292. {
  20293. case 2 or 3:
  20294. visaXS = 1.35M;
  20295. break;
  20296. case 4 or 5:
  20297. visaXS = 1.30M;
  20298. break;
  20299. case 6 or 7:
  20300. visaXS = 1.25M;
  20301. break;
  20302. case 8 or 9 or 10:
  20303. visaXS = 1.20M;
  20304. break;
  20305. case > 10:
  20306. visaXS = 1.15M;
  20307. break;
  20308. default:
  20309. visaXS = 0.00M;
  20310. break;
  20311. }
  20312. break;
  20313. case decimal n when (n >= 500 && n < 1000):
  20314. switch (dto.VisaRS)
  20315. {
  20316. case 2 or 3 or 4:
  20317. visaXS = 1.30M;
  20318. break;
  20319. case 5 or 6 or 7 or 8:
  20320. visaXS = 1.25M;
  20321. break;
  20322. case 9 or 10:
  20323. visaXS = 1.20M;
  20324. break;
  20325. case > 10:
  20326. visaXS = 1.15M;
  20327. break;
  20328. default:
  20329. visaXS = 0.00M;
  20330. break;
  20331. }
  20332. break;
  20333. default:
  20334. switch (dto.VisaRS)
  20335. {
  20336. case 2 or 3 or 4:
  20337. visaXS = 1.30M;
  20338. break;
  20339. case 5 or 6 or 7 or 8:
  20340. visaXS = 1.25M;
  20341. break;
  20342. case 9 or 10:
  20343. visaXS = 1.20M;
  20344. break;
  20345. case > 10:
  20346. visaXS = 1.15M;
  20347. break;
  20348. default:
  20349. visaXS = 0.00M;
  20350. break;
  20351. }
  20352. break;
  20353. }
  20354. #endregion
  20355. #region 火车系数
  20356. var hcpXS = 0.00M;
  20357. foreach (var (condition, result) in hcpSwitchDictionary)
  20358. {
  20359. if (condition(dto.HCPCB))
  20360. {
  20361. hcpXS = result;
  20362. break;
  20363. }
  20364. }
  20365. #endregion
  20366. #region 机票系数
  20367. #region 经济舱系数
  20368. var jjcXS = 0.00M;
  20369. switch (dto.JJCCB)
  20370. {
  20371. case decimal x when (x >= 1000 && x <= 3000):
  20372. jjcXS = 2.6M;
  20373. break;
  20374. case decimal x when (x >= 3001 && x <= 8000):
  20375. jjcXS = 2.3M;
  20376. break;
  20377. case decimal x when (x >= 8001 && x <= 15000):
  20378. jjcXS = 2.1M;
  20379. break;
  20380. case decimal x when (x >= 15001 && x <= 30000):
  20381. jjcXS = 1.95M;
  20382. break;
  20383. case > 30000:
  20384. jjcXS = 1.8M;
  20385. break;
  20386. default:
  20387. break;
  20388. }
  20389. #endregion
  20390. #region 公务舱系数
  20391. var gwcXS = 0.00M;
  20392. switch (dto.GWCCB)
  20393. {
  20394. case decimal x when (x >= 1000 && x <= 3000):
  20395. gwcXS = 2.5M;
  20396. break;
  20397. case decimal x when (x >= 3001 && x <= 8000):
  20398. gwcXS = 2.2M;
  20399. break;
  20400. case decimal x when (x >= 8001 && x <= 15000):
  20401. gwcXS = 2.0M;
  20402. break;
  20403. case decimal x when (x >= 15001 && x <= 30000):
  20404. gwcXS = 1.85M;
  20405. break;
  20406. case > 30000:
  20407. gwcXS = 1.7M;
  20408. break;
  20409. default:
  20410. break;
  20411. }
  20412. #endregion
  20413. #region 头等舱系数
  20414. var tdcXS = 0.00M;
  20415. switch (dto.TDCCB)
  20416. {
  20417. case > 70000:
  20418. tdcXS = 1.5M;
  20419. break;
  20420. default:
  20421. tdcXS = 1.9M;
  20422. break;
  20423. }
  20424. #endregion
  20425. #endregion
  20426. #region 酒店系数
  20427. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  20428. {
  20429. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  20430. {1.5M, new List<string>(){"越南社会主义共和国",
  20431. "老挝",
  20432. "柬埔寨",
  20433. "泰国",
  20434. "缅甸",
  20435. "马来西亚",
  20436. //"新加坡",
  20437. "文莱达鲁萨兰",
  20438. "印度尼西亚",
  20439. "东帝汶"}},
  20440. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  20441. };
  20442. #region SGR
  20443. var sgrXS = 1.25M;
  20444. #endregion
  20445. #region TBR
  20446. var tbrXS = 1.25M;
  20447. #endregion
  20448. #region JSES
  20449. var jsesXS = 1.25M;
  20450. #endregion
  20451. #region SUITE
  20452. var suiteXS = 1.25M;
  20453. #endregion
  20454. var countryArr = di.VisitCountry.Split("|");
  20455. foreach (var item in dic)
  20456. {
  20457. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  20458. .Count();
  20459. if (extsisCount > 0)
  20460. {
  20461. jsesXS = item.Key;
  20462. sgrXS = item.Key;
  20463. tbrXS = item.Key;
  20464. suiteXS = item.Key;
  20465. }
  20466. }
  20467. #endregion
  20468. #region 地接系数
  20469. var djXS = 0.00M;
  20470. switch (dto.DJRS)
  20471. {
  20472. case 2 or 3:
  20473. djXS = 2.65M;
  20474. break;
  20475. case 4:
  20476. djXS = 2.6M;
  20477. break;
  20478. case 5 or 6:
  20479. djXS = 2.5M;
  20480. break;
  20481. case 7 or 8:
  20482. djXS = 2.4M;
  20483. break;
  20484. case 9 or 10:
  20485. djXS = 2.3M;
  20486. break;
  20487. case 11:
  20488. djXS = 2.2M;
  20489. break;
  20490. case 12:
  20491. djXS = 2.1M;
  20492. break;
  20493. case 13 or 14:
  20494. djXS = 2M;
  20495. break;
  20496. case 15:
  20497. djXS = 1.9M;
  20498. break;
  20499. case 16 or 17 or 18:
  20500. djXS = 1.8M;
  20501. break;
  20502. case 19 or 20:
  20503. djXS = 1.7M;
  20504. break;
  20505. }
  20506. #endregion
  20507. #region 零用金系数
  20508. var lyjXS = 0.00M;
  20509. switch (dto.LYJRS)
  20510. {
  20511. case 2:
  20512. lyjXS = 1.25M;
  20513. break;
  20514. case 3 or 4 or 5:
  20515. lyjXS = 1.2M;
  20516. break;
  20517. case int number when (number > 5 && number < 10):
  20518. lyjXS = 1.15M;
  20519. break;
  20520. case > 10:
  20521. lyjXS = 1.1M;
  20522. break;
  20523. default:
  20524. break;
  20525. }
  20526. #endregion
  20527. return Ok(JsonView(true, "查询成功", new ArrayList()
  20528. {
  20529. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  20530. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  20531. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  20532. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  20533. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  20534. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  20535. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  20536. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  20537. new { label = "地接系数", value = djXS, key = "djXS" },
  20538. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  20539. new { label = "公务系数", value = 2M, key = "gwXS" }
  20540. }));
  20541. }
  20542. #endregion
  20543. #region 酒店预订 New 2023-12-28 17:45
  20544. /// <summary>
  20545. /// 酒店预订
  20546. /// 酒店费用列表 根据团组Id查询
  20547. /// </summary>
  20548. /// <param name="_dto"></param>
  20549. /// <returns></returns>
  20550. [HttpPost]
  20551. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20552. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  20553. {
  20554. #region 参数验证
  20555. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20556. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20557. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20558. #region 团组操作权限验证 76 酒店预定模块
  20559. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20560. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20561. #endregion
  20562. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20563. #region 页面操作权限验证
  20564. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20565. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20566. #endregion
  20567. #endregion
  20568. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  20569. }
  20570. /// <summary>
  20571. /// 酒店预订
  20572. /// 基础数据
  20573. /// </summary>
  20574. /// <param name="_dto"></param>
  20575. /// <returns></returns>
  20576. [HttpPost]
  20577. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20578. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  20579. {
  20580. #region 参数验证
  20581. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20582. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20583. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20584. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20585. #region 页面操作权限验证
  20586. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20587. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20588. #endregion
  20589. #region 团组操作权限验证 76 酒店预定模块
  20590. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20591. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20592. #endregion
  20593. #endregion
  20594. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  20595. }
  20596. /// <summary>
  20597. /// 酒店预订
  20598. /// 创建 入住卷号码
  20599. /// </summary>
  20600. /// <param name="_dto"></param>
  20601. /// <returns></returns>
  20602. [HttpPost]
  20603. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20604. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  20605. {
  20606. #region 参数验证
  20607. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20608. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20609. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20610. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20611. #region 页面操作权限验证
  20612. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20613. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20614. #endregion
  20615. #region 团组操作权限验证 76 酒店预定模块
  20616. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20617. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20618. #endregion
  20619. #endregion
  20620. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  20621. if (data.Code != 0)
  20622. {
  20623. return Ok(JsonView(false, data.Msg));
  20624. }
  20625. return Ok(JsonView(true, data.Msg, data.Data));
  20626. }
  20627. /// <summary>
  20628. /// 酒店预订
  20629. /// 详情
  20630. /// </summary>
  20631. /// <param name="_dto"></param>
  20632. /// <returns></returns>
  20633. [HttpPost]
  20634. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20635. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  20636. {
  20637. #region 参数验证
  20638. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  20639. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20640. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  20641. #region 团组操作权限验证 76 酒店预定模块
  20642. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20643. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20644. #endregion
  20645. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20646. #region 页面操作权限验证
  20647. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20648. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20649. #endregion
  20650. #endregion
  20651. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  20652. }
  20653. /// <summary>
  20654. /// 酒店预订
  20655. /// Add Or Edit
  20656. /// </summary>
  20657. /// <param name="_dto"></param>
  20658. /// <returns></returns>
  20659. [HttpPost]
  20660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20661. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  20662. {
  20663. #region 参数验证
  20664. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20665. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20666. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20667. #region 团组操作权限验证 76 酒店预定模块
  20668. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20669. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20670. #endregion
  20671. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20672. #region 页面操作权限验证
  20673. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20674. if (_dto.Id == 0) // Add
  20675. {
  20676. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20677. }
  20678. else if (_dto.Id > 1) // Edit
  20679. {
  20680. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20681. }
  20682. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  20683. #endregion
  20684. #endregion
  20685. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  20686. if (_view.Code != 200)
  20687. {
  20688. return Ok(_view);
  20689. }
  20690. #region 成本无酒店价格数据进入超支
  20691. _sqlSugar.BeginTran();
  20692. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  20693. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  20694. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  20695. for (int i = 0; i < groupCost.Count; i++)
  20696. {
  20697. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  20698. {
  20699. groupCost[i].Date = groupCost[i - 1].Date;
  20700. }
  20701. }
  20702. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  20703. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  20704. List<Fin_GroupExtraCostDto_OP>();
  20705. if (start_Bool && end_Bool)
  20706. {
  20707. while (start_Time < end_Time)
  20708. {
  20709. foreach (var item in groupCost_Grp)
  20710. {
  20711. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  20712. {
  20713. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  20714. {
  20715. extraCostList.Add(new
  20716. Fin_GroupExtraCostDto_OP
  20717. {
  20718. Area = _dto.AreaId,
  20719. coefficient = 1.5M,
  20720. createUser = _dto.UserId,
  20721. currency = _dto.CardPriceCurrency,
  20722. diId = _dto.DiId,
  20723. ManagerConfirm = 0,
  20724. SupervisorConfirm = 0,
  20725. SYsupervisorConfirm = 0,
  20726. editType = 1,
  20727. PortType = 1,
  20728. price = _dto.CardPrice,
  20729. PriceCount = 1,
  20730. priceType = 1027,
  20731. priceDetailType = 1044,
  20732. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  20733. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  20734. });
  20735. }
  20736. }
  20737. }
  20738. start_Time = start_Time.AddDays(1);
  20739. }
  20740. }
  20741. if (extraCostList.Any())
  20742. {
  20743. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  20744. }
  20745. _sqlSugar.CommitTran();
  20746. #endregion
  20747. #region 应用推送
  20748. try
  20749. {
  20750. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  20751. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  20752. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  20753. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  20754. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  20755. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  20756. var diId = _dto.DiId;
  20757. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20758. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20759. #region 操作记录
  20760. var opInfo = new Crm_TableOperationRecord()
  20761. {
  20762. TableName = "Grp_HotelReservations",
  20763. PortType = _dto.PortType,
  20764. DataId = hotelId,
  20765. CreateUserId = _dto.UserId
  20766. };
  20767. //var opStatus = OperationEnum.NoOperation;
  20768. if (_dto.Id < 1) //添加操作
  20769. {
  20770. opInfo.OperationItem = OperationEnum.Add;
  20771. }
  20772. else if (_dto.Id > 0)
  20773. {
  20774. opInfo.OperationItem = OperationEnum.Edit;
  20775. }
  20776. string opRemark = string.Empty;
  20777. if (ccpInfo != null)
  20778. {
  20779. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  20780. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  20781. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  20782. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  20783. }
  20784. opInfo.Remark = opRemark;
  20785. await _tableorRep.AddAsync(opInfo);
  20786. #endregion
  20787. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  20788. //2024-10-21 新增LZ UID
  20789. var userIds = new List<int>() { 21 };
  20790. string title = $"费用审核";
  20791. string content = "";
  20792. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20793. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20794. try
  20795. {
  20796. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  20797. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  20798. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  20799. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  20800. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  20801. }
  20802. catch (Exception ex)
  20803. {
  20804. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  20805. }
  20806. }
  20807. catch (Exception ex)
  20808. {
  20809. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  20810. }
  20811. try
  20812. {
  20813. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  20814. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  20815. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  20816. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  20817. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  20818. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  20819. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  20820. //自动审核
  20821. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  20822. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  20823. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  20824. //2024-10-21 新增LZ UID
  20825. var userIds = new List<int>() { 21 };
  20826. string title = $"系统通知";
  20827. var diId = _dto.DiId;
  20828. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20829. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20830. string content = "";
  20831. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20832. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20833. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  20834. }
  20835. catch (Exception ex)
  20836. {
  20837. }
  20838. #endregion
  20839. return Ok(_view);
  20840. }
  20841. /// <summary>
  20842. /// 酒店自动审核测试
  20843. /// Add Or Edit
  20844. /// </summary>
  20845. /// <param name="diid"></param>
  20846. /// <param name="dataId"></param>
  20847. /// <returns></returns>
  20848. [HttpPost]
  20849. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20850. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  20851. {
  20852. #region 应用推送
  20853. try
  20854. {
  20855. //自动审核
  20856. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  20857. }
  20858. catch (Exception ex)
  20859. {
  20860. return Ok(JsonView(false, ex.Message));
  20861. }
  20862. #endregion
  20863. return Ok(JsonView(false, "操作成功"));
  20864. }
  20865. /// <summary>
  20866. /// 酒店预订
  20867. /// Del
  20868. /// </summary>
  20869. /// <param name="_dto"></param>
  20870. /// <returns></returns>
  20871. [HttpPost]
  20872. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20873. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  20874. {
  20875. #region 参数验证
  20876. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20877. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20878. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20879. #region 团组操作权限验证 76 酒店预定模块
  20880. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20881. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20882. #endregion
  20883. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20884. #region 页面操作权限验证
  20885. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20886. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20887. #endregion
  20888. #endregion
  20889. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  20890. #region 操作记录
  20891. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  20892. {
  20893. TableName = "Grp_HotelReservations",
  20894. PortType = _dto.PortType,
  20895. OperationItem = OperationEnum.Del,
  20896. DataId = _dto.Id,
  20897. CreateUserId = _dto.UserId
  20898. });
  20899. #endregion
  20900. return Ok(data);
  20901. }
  20902. /// <summary>
  20903. /// 酒店预订
  20904. /// 生成VOUCHER
  20905. /// 2024.05.06 之前版本
  20906. /// </summary>
  20907. /// <param name="_dto"></param>
  20908. /// <returns></returns>
  20909. [HttpPost]
  20910. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20911. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  20912. {
  20913. try
  20914. {
  20915. #region 参数验证
  20916. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20917. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20918. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20919. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  20920. #region 团组操作权限验证 76 酒店预定模块
  20921. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20922. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20923. #endregion
  20924. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20925. #region 页面操作权限验证
  20926. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20927. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20928. #endregion
  20929. #endregion
  20930. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  20931. //判断数据是否完整
  20932. if (hr != null)
  20933. {
  20934. if (!string.IsNullOrEmpty(hr.DetermineNo))
  20935. {
  20936. string strFileName = "HotelStatement/";
  20937. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  20938. if (dele != null)
  20939. strFileName += dele.TourCode;
  20940. //载入模板
  20941. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  20942. Document doc = new Document(sss);
  20943. DocumentBuilder builder = new DocumentBuilder(doc);
  20944. #region 替换Word模板书签内容
  20945. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  20946. //入住卷预定号码
  20947. if (doc.Range.Bookmarks["VNO"] != null)
  20948. {
  20949. Bookmark mark = doc.Range.Bookmarks["VNO"];
  20950. mark.Text = hr.CheckNumber;
  20951. }
  20952. //酒店时间
  20953. if (doc.Range.Bookmarks["Date"] != null)
  20954. {
  20955. Bookmark mark = doc.Range.Bookmarks["Date"];
  20956. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  20957. }
  20958. //团号
  20959. if (doc.Range.Bookmarks["TNo"] != null)
  20960. {
  20961. Bookmark mark = doc.Range.Bookmarks["TNo"];
  20962. mark.Text = dele.TourCode;
  20963. }
  20964. //预定号码
  20965. if (doc.Range.Bookmarks["BookingId"] != null)
  20966. {
  20967. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  20968. mark.Text = hr.ReservationsNo;
  20969. }
  20970. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  20971. {
  20972. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  20973. mark.Text = hr.DetermineNo;
  20974. }
  20975. //酒店城市
  20976. if (doc.Range.Bookmarks["City"] != null)
  20977. {
  20978. Bookmark mark = doc.Range.Bookmarks["City"];
  20979. mark.Text = hr.City;
  20980. }
  20981. //酒店名称
  20982. if (doc.Range.Bookmarks["HName"] != null)
  20983. {
  20984. Bookmark mark = doc.Range.Bookmarks["HName"];
  20985. mark.Text = hr.HotelName;
  20986. }
  20987. //酒店地址
  20988. if (doc.Range.Bookmarks["Address"] != null)
  20989. {
  20990. Bookmark mark = doc.Range.Bookmarks["Address"];
  20991. mark.Text = hr.HotelAddress;
  20992. }
  20993. //酒店电话
  20994. if (doc.Range.Bookmarks["Tel"] != null)
  20995. {
  20996. Bookmark mark = doc.Range.Bookmarks["Tel"];
  20997. mark.Text = hr.HotelTel;
  20998. }
  20999. //酒店传真
  21000. if (doc.Range.Bookmarks["Fax"] != null)
  21001. {
  21002. Bookmark mark = doc.Range.Bookmarks["Fax"];
  21003. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  21004. {
  21005. mark.Text = hr.HotelFax;
  21006. }
  21007. }
  21008. //入住时间
  21009. if (doc.Range.Bookmarks["CIn"] != null)
  21010. {
  21011. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  21012. Bookmark mark = doc.Range.Bookmarks["CIn"];
  21013. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  21014. }
  21015. //退房时间
  21016. if (doc.Range.Bookmarks["COut"] != null)
  21017. {
  21018. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  21019. Bookmark mark = doc.Range.Bookmarks["COut"];
  21020. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  21021. }
  21022. //客户名称
  21023. if (doc.Range.Bookmarks["GName"] != null)
  21024. {
  21025. string guestName = "";
  21026. string[] clients = Array.Empty<string>();
  21027. if (hr.GuestName.Contains(","))
  21028. {
  21029. clients = hr.GuestName.Split(",");
  21030. }
  21031. else
  21032. {
  21033. clients = new string[] { hr.GuestName };
  21034. }
  21035. List<int> clientIds_int = new List<int>();
  21036. if (clients.Length > 0)
  21037. {
  21038. foreach (var item in clients)
  21039. {
  21040. if (item.IsNumeric())
  21041. {
  21042. clientIds_int.Add(int.Parse(item));
  21043. }
  21044. }
  21045. }
  21046. if (clientIds_int.Count > 0)
  21047. {
  21048. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  21049. foreach (var client in _clientDatas)
  21050. {
  21051. //男
  21052. if (client.Sex == 0) guestName += $"Mr.";
  21053. //女
  21054. else if (client.Sex == 1) guestName += $"Ms.";
  21055. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  21056. {
  21057. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  21058. }
  21059. //guestName += $"{client.Pinyin},";
  21060. }
  21061. if (guestName.Length > 0)
  21062. {
  21063. guestName = guestName.Substring(0, guestName.Length - 1);
  21064. }
  21065. }
  21066. else
  21067. {
  21068. guestName = hr.GuestName;
  21069. }
  21070. Bookmark mark = doc.Range.Bookmarks["GName"];
  21071. mark.Text = guestName;
  21072. }
  21073. //房间介绍
  21074. if (doc.Range.Bookmarks["ROOM"] != null)
  21075. {
  21076. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  21077. mark.Text = hr.RoomExplanation;
  21078. }
  21079. //报价描述
  21080. if (doc.Range.Bookmarks["NOTE"] != null)
  21081. {
  21082. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  21083. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  21084. if (ss != null)
  21085. mark.Text = ss.Name;
  21086. }
  21087. //入住时间
  21088. if (doc.Range.Bookmarks["CheckIn"] != null)
  21089. {
  21090. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  21091. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  21092. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  21093. }
  21094. //退房时间
  21095. if (doc.Range.Bookmarks["CheckOut"] != null)
  21096. {
  21097. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  21098. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  21099. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  21100. }
  21101. //日期
  21102. if (doc.Range.Bookmarks["DT"] != null)
  21103. {
  21104. Bookmark mark = doc.Range.Bookmarks["DT"];
  21105. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  21106. }
  21107. //名称
  21108. if (doc.Range.Bookmarks["VName"] != null)
  21109. {
  21110. Bookmark mark = doc.Range.Bookmarks["VName"];
  21111. mark.Text = hr.HotelName;
  21112. }
  21113. //号码
  21114. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  21115. {
  21116. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  21117. mark.Text = hr.CheckNumber;
  21118. }
  21119. #endregion
  21120. strFileName += "VOUCHER.doc";
  21121. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  21122. doc.Save(fileDir);
  21123. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  21124. return Ok(JsonView(true, "操作成功!", Url));
  21125. }
  21126. else
  21127. {
  21128. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  21129. }
  21130. }
  21131. else
  21132. {
  21133. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  21134. }
  21135. }
  21136. catch (Exception ex)
  21137. {
  21138. return Ok(JsonView(false, ex.Message));
  21139. }
  21140. }
  21141. /// <summary>
  21142. /// 酒店预订
  21143. /// 生成VOUCHER
  21144. /// 2024.05.06 之后版本
  21145. /// </summary>
  21146. /// <param name="_dto"></param>
  21147. /// <returns></returns>
  21148. [HttpPost]
  21149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21150. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  21151. {
  21152. #region 参数验证
  21153. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  21154. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  21155. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  21156. #region 团组操作权限验证 76 酒店预定模块
  21157. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  21158. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  21159. #endregion
  21160. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21161. #region 页面操作权限验证
  21162. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21163. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21164. #endregion
  21165. #endregion
  21166. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  21167. //判断数据是否完整
  21168. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  21169. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  21170. string strFileName = "HotelStatement/";
  21171. string guestNames = ""; //格式Mr.xxx Ms.xxx
  21172. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  21173. #region 数据处理
  21174. List<int> guestIds = new List<int>();
  21175. //int index = 0;
  21176. foreach (var item in hrDtas)
  21177. {
  21178. if (item.GuestName.Contains(","))
  21179. {
  21180. string[] guestIdArr = item.GuestName.Split(',');
  21181. foreach (var guestIdStr in guestIdArr)
  21182. {
  21183. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  21184. if (guestBool)
  21185. {
  21186. guestIds.Add(guestId);
  21187. }
  21188. }
  21189. }
  21190. else guestNames += item.GuestName;
  21191. var voucherInfo = new HotelVoucherInfoView()
  21192. {
  21193. HotelName = item.HotelName,
  21194. CheckInDate = item.CheckInDate,
  21195. CheckOutDate = item.CheckOutDate,
  21196. ConfirmationNumber = item.DetermineNo.Trim(),
  21197. RoomType = item.RoomExplanation
  21198. };
  21199. vouchers.Add(voucherInfo);
  21200. }
  21201. if (guestIds.Count > 0)
  21202. {
  21203. guestIds = guestIds.Distinct().ToList();
  21204. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  21205. if (guestDatas.Count > 0)
  21206. {
  21207. guestNames = "";
  21208. foreach (var guest in guestDatas)
  21209. {
  21210. string guestName = "";
  21211. if (guest.Sex == 0) guestName += @"MR.";
  21212. else if (guest.Sex == 1) guestName += @"MS.";
  21213. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  21214. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  21215. guestNames += @$"{guestName.Trim()}、";
  21216. }
  21217. if (guestNames.Length > 0)
  21218. {
  21219. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  21220. }
  21221. }
  21222. }
  21223. #endregion
  21224. //载入模板
  21225. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  21226. Document doc = new Document(sss);
  21227. DocumentBuilder builder = new DocumentBuilder(doc);
  21228. if (doc.Range.Bookmarks["GuestName"] != null)
  21229. {
  21230. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  21231. mark.Text = guestNames;
  21232. }
  21233. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21234. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  21235. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  21236. for (int i = 1; i <= vouchers.Count; i++)
  21237. {
  21238. HotelVoucherInfoView hviv = vouchers[i - 1];
  21239. builder.MoveToCell(0, i, 0, 0);
  21240. builder.Write(hviv.HotelName);
  21241. builder.MoveToCell(0, i, 1, 0);
  21242. builder.Write(hviv.CheckInDate);
  21243. builder.MoveToCell(0, i, 2, 0);
  21244. builder.Write(hviv.CheckOutDate);
  21245. builder.MoveToCell(0, i, 3, 0);
  21246. builder.Write(hviv.RoomType);
  21247. builder.MoveToCell(0, i, 4, 0);
  21248. builder.Write(hviv.ConfirmationNumber);
  21249. }
  21250. //删除多余行
  21251. int currRowIndex = vouchers.Count + 1;
  21252. int delRows = 21 - currRowIndex;
  21253. if (delRows > 0)
  21254. {
  21255. for (int i = 0; i < delRows; i++)
  21256. {
  21257. table.Rows.RemoveAt(currRowIndex);
  21258. //cultivateRowIndex++;
  21259. }
  21260. }
  21261. strFileName += "VOUCHER.docx";
  21262. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  21263. doc.Save(fileDir);
  21264. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  21265. return Ok(JsonView(true, "操作成功!", Url));
  21266. }
  21267. /// <summary>
  21268. /// 酒店预订
  21269. /// 生成VOUCHER 批量生成
  21270. /// New
  21271. /// </summary>
  21272. /// <param name="_dto"></param>
  21273. /// <returns></returns>
  21274. [HttpPost]
  21275. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21276. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  21277. {
  21278. #region 参数验证
  21279. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  21280. if (_dto.PageId < 1) _dto.PageId = 28;
  21281. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  21282. #region 团组操作权限验证 76 酒店预定模块
  21283. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  21284. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  21285. #endregion
  21286. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21287. #region 页面操作权限验证
  21288. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21289. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21290. #endregion
  21291. #endregion
  21292. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  21293. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  21294. .OrderBy(x => x.CheckInDate)
  21295. .ToListAsync();
  21296. //判断数据是否完整
  21297. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  21298. string strFileName = "HotelStatement/";
  21299. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  21300. if (dele != null)
  21301. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  21302. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  21303. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  21304. .Where(it => it.IsDel == 0)
  21305. .ToListAsync();
  21306. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  21307. for (int i = 0; i < hrDtas.Count; i++)
  21308. {
  21309. string guestNames = string.Empty;
  21310. List<int> guestIds = new List<int>();
  21311. var item = hrDtas[i];
  21312. //处理客户姓名
  21313. if (item.GuestName.Contains(","))
  21314. {
  21315. string[] guestIdArr = item.GuestName.Split(',');
  21316. foreach (var guestIdStr in guestIdArr)
  21317. if (int.TryParse(guestIdStr, out int guestId))
  21318. guestIds.Add(guestId);
  21319. }
  21320. else
  21321. {
  21322. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  21323. if (guestIdBool)
  21324. {
  21325. guestIds.Add(guestId);
  21326. }
  21327. //NaN
  21328. if (item.GuestName.Contains("NaN"))
  21329. {
  21330. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  21331. }
  21332. }
  21333. if (guestIds.Count > 0)
  21334. {
  21335. guestIds = guestIds.Distinct().ToList();
  21336. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  21337. if (guestDatas1.Count > 0)
  21338. {
  21339. guestNames = "";
  21340. foreach (var guest in guestDatas1)
  21341. {
  21342. string guestName = "";
  21343. if (guest.Sex == 0) guestName += @"MR.";
  21344. else if (guest.Sex == 1) guestName += @"MS.";
  21345. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  21346. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  21347. guestNames += @$"{guestName.Trim()}、";
  21348. }
  21349. if (guestNames.Length > 0)
  21350. {
  21351. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  21352. }
  21353. }
  21354. }
  21355. //if (!string.IsNullOrEmpty(guestNames))
  21356. //{
  21357. hrDtas[i].GuestName = guestNames;
  21358. //}
  21359. }
  21360. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  21361. Document doc = new Document();
  21362. DocumentBuilder builder = new DocumentBuilder(doc);
  21363. try
  21364. {
  21365. builder.MoveToDocumentStart();
  21366. foreach (var item in hrDtas)
  21367. {
  21368. //标题
  21369. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  21370. builder.ParagraphFormat.LineSpacing = 1;
  21371. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21372. builder.ParagraphFormat.Style.Font.Size = 9;
  21373. builder.ParagraphFormat.Style.Font.Bold = true;
  21374. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21375. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  21376. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  21377. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21378. builder.ParagraphFormat.LineSpacing = 1;
  21379. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21380. builder.ParagraphFormat.Style.Font.Size = 9;
  21381. builder.ParagraphFormat.Style.Font.Bold = true;
  21382. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  21383. builder.StartTable();
  21384. // 设置边框颜色
  21385. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  21386. //设置边框样式
  21387. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  21388. //表格
  21389. #region 第一行
  21390. builder.InsertCell();
  21391. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21392. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21393. //builder.CellFormat.AllowAutoFit = false;
  21394. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21395. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21396. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21397. builder.CellFormat.WrapText = true; //自动换行
  21398. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21399. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  21400. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21401. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21402. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21403. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21404. builder.Write("TOUR NO:");
  21405. builder.InsertCell();
  21406. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21407. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21408. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21409. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21410. builder.ParagraphFormat.Style.Font.Bold = false;
  21411. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21412. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21413. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21414. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21415. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21416. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21417. builder.Write($"{dele?.TourCode ?? "-"}");
  21418. builder.InsertCell();
  21419. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21420. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21421. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21422. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21423. builder.ParagraphFormat.Style.Font.Bold = false;
  21424. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21425. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21426. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21427. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21428. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21429. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21430. builder.Write($"CITY:");
  21431. builder.InsertCell();
  21432. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21433. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21434. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21435. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21436. builder.ParagraphFormat.Style.Font.Bold = false;
  21437. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21438. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21439. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21440. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21441. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21442. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21443. builder.Write($"{item.City}");
  21444. builder.EndRow();
  21445. #endregion
  21446. #region 第二行
  21447. builder.InsertCell();
  21448. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21449. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21450. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21451. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21452. builder.ParagraphFormat.Style.Font.Bold = false;
  21453. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21454. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21455. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21456. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21457. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21458. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21459. builder.Write("CONFIRMATION NO:");
  21460. builder.InsertCell();
  21461. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21462. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21463. builder.ParagraphFormat.Style.Font.Size = 8;
  21464. builder.ParagraphFormat.Style.Font.Bold = false;
  21465. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21466. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21467. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21468. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21469. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21470. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21471. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21472. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21473. builder.Write($"{item.DetermineNo}");
  21474. builder.InsertCell();
  21475. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21476. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21477. builder.InsertCell();
  21478. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21479. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21480. builder.EndRow();
  21481. #endregion
  21482. #region 第三行
  21483. builder.InsertCell();
  21484. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21485. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21486. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21487. builder.ParagraphFormat.Style.Font.Bold = false;
  21488. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21489. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21490. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21491. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21492. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21493. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21494. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21495. builder.Write($"HOTEL NAME:");
  21496. builder.InsertCell();
  21497. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21498. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21499. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21500. builder.ParagraphFormat.Style.Font.Bold = false;
  21501. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21502. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21503. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21504. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21505. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21506. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21507. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21508. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21509. builder.Write($"{item.HotelName}");
  21510. builder.InsertCell();
  21511. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21512. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21513. builder.InsertCell();
  21514. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21515. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21516. builder.EndRow();
  21517. #endregion
  21518. #region 第四行
  21519. builder.InsertCell();
  21520. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21521. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21522. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21523. builder.ParagraphFormat.Style.Font.Bold = false;
  21524. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21525. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21526. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21527. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21528. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21529. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21530. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21531. builder.Write($"HOTEL ADDRESS:");
  21532. builder.InsertCell();
  21533. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21534. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21535. builder.ParagraphFormat.Style.Font.Size = 8;
  21536. builder.ParagraphFormat.Style.Font.Bold = false;
  21537. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21538. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21539. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21540. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21541. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21542. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21543. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21544. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21545. builder.Write($"{item.HotelAddress}");
  21546. builder.InsertCell();
  21547. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21548. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21549. builder.InsertCell();
  21550. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21551. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21552. builder.EndRow();
  21553. #endregion
  21554. #region 第五行
  21555. builder.InsertCell();
  21556. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21557. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21558. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21559. builder.ParagraphFormat.Style.Font.Bold = false;
  21560. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21561. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21562. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21563. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21564. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21565. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21566. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21567. builder.Write("TEL:");
  21568. builder.InsertCell();
  21569. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21570. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21571. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21572. builder.ParagraphFormat.Style.Font.Bold = false;
  21573. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21574. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21575. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21576. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21577. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21578. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21579. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21580. builder.Write($"{item.HotelTel}");
  21581. builder.InsertCell();
  21582. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21583. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21584. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21585. builder.ParagraphFormat.Style.Font.Bold = false;
  21586. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21587. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21588. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21589. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21590. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21591. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21592. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21593. builder.Write($"FAX:");
  21594. builder.InsertCell();
  21595. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21596. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21597. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21598. builder.ParagraphFormat.Style.Font.Bold = false;
  21599. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21600. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21601. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21602. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21603. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21604. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21605. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21606. builder.Write($"{item.HotelFax}");
  21607. builder.EndRow();
  21608. #endregion
  21609. #region 第六行
  21610. builder.InsertCell();
  21611. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21612. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21613. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21614. builder.ParagraphFormat.Style.Font.Bold = false;
  21615. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21616. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21617. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21618. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21619. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21620. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21621. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21622. builder.Write("CHECK IN:");
  21623. builder.InsertCell();
  21624. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21625. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21626. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21627. builder.ParagraphFormat.Style.Font.Bold = false;
  21628. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21629. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21630. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21631. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21632. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21633. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21634. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21635. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  21636. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  21637. builder.Write($"{checkInStr}");
  21638. builder.InsertCell();
  21639. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21640. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21641. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21642. builder.ParagraphFormat.Style.Font.Bold = false;
  21643. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21644. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21645. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21646. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21647. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21648. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21649. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21650. builder.Write($"CHECK OUT:");
  21651. builder.InsertCell();
  21652. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21653. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21654. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21655. builder.ParagraphFormat.Style.Font.Bold = false;
  21656. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21657. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21658. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21659. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21660. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21661. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21662. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21663. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  21664. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  21665. builder.Write($"{checkOutStr}");
  21666. builder.EndRow();
  21667. #endregion
  21668. #region 第七行
  21669. builder.InsertCell();
  21670. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21671. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21672. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21673. builder.ParagraphFormat.Style.Font.Bold = false;
  21674. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21675. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21676. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21677. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21678. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21679. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21680. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21681. builder.Write($"GUEST NAME:");
  21682. builder.InsertCell();
  21683. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21684. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21685. builder.ParagraphFormat.Style.Font.Size = 8;
  21686. builder.ParagraphFormat.Style.Font.Bold = false;
  21687. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21688. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21689. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21690. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21691. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21692. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21693. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21694. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21695. builder.Write($"{item.GuestName.Trim()}");
  21696. builder.InsertCell();
  21697. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21698. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21699. builder.InsertCell();
  21700. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21701. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21702. builder.EndRow();
  21703. #endregion
  21704. #region 第八行
  21705. builder.InsertCell();
  21706. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21707. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21708. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21709. builder.ParagraphFormat.Style.Font.Bold = false;
  21710. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21711. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21712. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21713. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21714. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21715. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21716. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21717. builder.Write($"ROOM TYPE:");
  21718. builder.InsertCell();
  21719. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21720. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21721. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21722. builder.ParagraphFormat.Style.Font.Bold = false;
  21723. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21724. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21725. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21726. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21727. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21728. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21729. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21730. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21731. builder.Write($"{item.RoomExplanation}");
  21732. builder.InsertCell();
  21733. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21734. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21735. builder.InsertCell();
  21736. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21737. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21738. builder.EndRow();
  21739. #endregion
  21740. #region 第九行
  21741. builder.InsertCell();
  21742. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21743. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21744. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21745. builder.ParagraphFormat.Style.Font.Bold = false;
  21746. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21747. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21748. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21749. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21750. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21751. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21752. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21753. builder.Write($"NOTE:");
  21754. builder.InsertCell();
  21755. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21756. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21757. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21758. builder.ParagraphFormat.Style.Font.Bold = false;
  21759. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21760. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21761. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21762. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21763. 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.");
  21764. builder.InsertCell();
  21765. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21766. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21767. builder.InsertCell();
  21768. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21769. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21770. builder.EndRow();
  21771. #endregion
  21772. builder.EndTable();
  21773. //换行
  21774. builder.Writeln("");
  21775. builder.Writeln("");
  21776. }
  21777. #region 获取文档中的所有表格 设置文字自适应
  21778. // 获取文档中的所有表格。
  21779. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  21780. {
  21781. // 遍历表格中的所有行。
  21782. foreach (Aspose.Words.Tables.Row row in table.Rows)
  21783. {
  21784. foreach (Cell cell in row.Cells)
  21785. {
  21786. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  21787. cellFormat.Width = 0;
  21788. }
  21789. }
  21790. }
  21791. #endregion
  21792. #region 设置页眉
  21793. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  21794. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  21795. if (System.IO.File.Exists(voucherHeaderPath))
  21796. {
  21797. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  21798. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  21799. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  21800. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  21801. // 调整图片位置
  21802. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  21803. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  21804. shape.Top = 50; // 将图片距离页眉上边缘的距离
  21805. shape.Left = 0; // 将图片距离页面左边缘的距离
  21806. shape.Width = 81; // 设置图片宽度
  21807. shape.Height = 36; // 设置图片高度
  21808. }
  21809. //靠右
  21810. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  21811. //// 设置页脚上下边距
  21812. //builder.PageSetup.HeaderDistance = 42;
  21813. // 添加页眉线
  21814. Aspose.Words.Border borderHeader = null;
  21815. try
  21816. {
  21817. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  21818. }
  21819. catch (Exception e)
  21820. {
  21821. // TODO Auto-generated catch block
  21822. //e.printStackTrace();
  21823. }
  21824. borderHeader.Shadow = true;
  21825. borderHeader.DistanceFromText = 2;
  21826. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  21827. #endregion
  21828. }
  21829. catch (Exception ex)
  21830. {
  21831. }
  21832. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  21833. doc.Save(fileDir);
  21834. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  21835. return Ok(JsonView(true, "操作成功!", Url));
  21836. }
  21837. /// <summary>
  21838. /// 酒店预订
  21839. /// 生成 预定成本 Excel
  21840. /// </summary>
  21841. /// <param name="_dto"></param>
  21842. /// <returns></returns>
  21843. [HttpPost]
  21844. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21845. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  21846. {
  21847. #region 参数验证
  21848. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  21849. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  21850. if (!vadalitorRes.IsValid)
  21851. {
  21852. var errors = new StringBuilder();
  21853. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  21854. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  21855. }
  21856. #region 团组操作权限验证 76 酒店预定模块
  21857. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  21858. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  21859. #endregion
  21860. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21861. #region 页面操作权限验证
  21862. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21863. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21864. #endregion
  21865. #endregion
  21866. decimal _rate = 1.00M;
  21867. string _currency = string.Empty;
  21868. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  21869. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  21870. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  21871. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  21872. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  21873. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  21874. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  21875. if (_GroupCostParameter == null)
  21876. {
  21877. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  21878. bool isIntType = int.TryParse(_currency, out int currId);
  21879. if (isIntType)
  21880. {
  21881. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  21882. }
  21883. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  21884. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  21885. if (currInfo == null)
  21886. {
  21887. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  21888. }
  21889. else _rate = currInfo.Rate;
  21890. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  21891. {
  21892. _rate = _GroupCostParameter.Rate;
  21893. }
  21894. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  21895. //string strFileName = "HotelStatement/";
  21896. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  21897. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  21898. var rateDatas = new List<dynamic>();
  21899. #region 数据处理
  21900. foreach (var item in hrDtas)
  21901. {
  21902. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  21903. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  21904. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  21905. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  21906. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  21907. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  21908. {
  21909. continue;
  21910. }
  21911. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  21912. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  21913. string singleRoomFeeStr = string.Empty,
  21914. doubleRoomFeeStr = string.Empty,
  21915. suiteRoomFeeStr = string.Empty,
  21916. otherRoomFeeStr = string.Empty,
  21917. payMoneyStr = string.Empty,
  21918. cardPriceStr = string.Empty;
  21919. if (roomCurr.Equals("CNY"))
  21920. {
  21921. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  21922. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  21923. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  21924. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  21925. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  21926. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  21927. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  21928. }
  21929. else
  21930. {
  21931. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  21932. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  21933. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  21934. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  21935. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  21936. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  21937. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  21938. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  21939. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  21940. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  21941. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  21942. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  21943. if (ccpPaymentCurrency.Equals("CNY"))
  21944. {
  21945. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  21946. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  21947. }
  21948. else
  21949. {
  21950. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  21951. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  21952. }
  21953. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  21954. if (hotelcardPriceCurrency.Equals("CNY"))
  21955. {
  21956. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  21957. }
  21958. else
  21959. {
  21960. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  21961. }
  21962. }
  21963. string breakfastPriceStr = string.Empty,
  21964. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  21965. governmentRentStr = string.Empty,
  21966. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  21967. cityTaxStr = string.Empty,
  21968. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  21969. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  21970. if (!string.IsNullOrEmpty(breakfastCurrency1))
  21971. {
  21972. if (breakfastCurrency1.Equals("CNY"))
  21973. {
  21974. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  21975. }
  21976. else
  21977. {
  21978. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  21979. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  21980. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  21981. }
  21982. }
  21983. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  21984. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  21985. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  21986. {
  21987. if (governmentRentCurrency.Equals("CNY"))
  21988. {
  21989. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  21990. }
  21991. else
  21992. {
  21993. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  21994. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  21995. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  21996. }
  21997. }
  21998. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  21999. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  22000. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  22001. {
  22002. if (cityTaxStrCurrency1.Equals("CNY"))
  22003. {
  22004. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  22005. }
  22006. else
  22007. {
  22008. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  22009. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  22010. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  22011. }
  22012. }
  22013. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  22014. int payDId = roomInfo?.PayDId ?? 0;
  22015. pcfds.Add(new HotelReservations_PCFD_View()
  22016. {
  22017. City = item.City,
  22018. HotelName = item.HotelName,
  22019. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  22020. // SingleRoomCount = item.SingleRoomCount,
  22021. SingleRoomPrice = singleRoomFeeStr,
  22022. // DoubleRoomCount = item.DoubleRoomCount,
  22023. DoubleRoomPrice = doubleRoomFeeStr,
  22024. //SuiteRoomCount = item.SuiteRoomCount,
  22025. SuiteRoomPrice = suiteRoomFeeStr,
  22026. OtherRoomPrice = otherRoomFeeStr,
  22027. //OtherRoomCount = item.OtherRoomCount,
  22028. BreakfastPrice = breakfastPriceStr,
  22029. GovernmentRent = governmentRentStr,
  22030. CityTax = cityTaxStr,
  22031. RoomExplanation = item.RoomExplanation,
  22032. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  22033. PayTime = roomInfo?.ConsumptionDate,
  22034. BankNo = roomInfo?.BankNo,
  22035. PayMoney = payMoneyStr,
  22036. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  22037. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  22038. CardPrice = cardPriceStr,
  22039. Remark = ccpInfo.Remark
  22040. });
  22041. }
  22042. #endregion
  22043. //载入模板
  22044. WorkbookDesigner designer = new WorkbookDesigner();
  22045. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  22046. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  22047. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  22048. designer.SetDataSource("TourNo", groupInfo.TourCode);
  22049. var rateDatas1 = rateDatas.Distinct();
  22050. var rateStr = string.Empty;
  22051. foreach (var item in rateDatas1)
  22052. {
  22053. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  22054. }
  22055. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  22056. designer.SetDataSource("Opertor", userInfo.CnName);
  22057. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  22058. dt.TableName = "ViewMyHotelReservations";
  22059. designer.SetDataSource(dt);
  22060. designer.Process();
  22061. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  22062. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  22063. designer.Workbook.Save(serverPath);
  22064. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  22065. #region 删除指定行
  22066. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  22067. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  22068. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  22069. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  22070. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  22071. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  22072. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  22073. cssIndex = dt.Columns["CityTax"].Ordinal,
  22074. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  22075. remarkIndex = dt.Columns["Remark"].Ordinal;
  22076. //删除指定列
  22077. foreach (DataRow item in dt.Rows)
  22078. {
  22079. string singleStr = item["SingleRoomPrice"].ToString();
  22080. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  22081. if (containsDigitButNotZero1) singleDel = false;
  22082. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  22083. string doubleStr = item["DoubleRoomPrice"].ToString();
  22084. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22085. if (containsDigitButNotZero2) doubleDel = false;
  22086. string suiteStr = item["SuiteRoomPrice"].ToString();
  22087. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22088. if (containsDigitButNotZero3) suiteDel = false;
  22089. string otherStr = item["OtherRoomPrice"].ToString();
  22090. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  22091. if (containsDigitButNotZero4) otherDel = false;
  22092. string zcStr = item["BreakfastPrice"].ToString();
  22093. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  22094. if (containsDigitButNotZero5) zcDel = false;
  22095. string dsStr = item["GovernmentRent"].ToString();
  22096. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  22097. if (containsDigitButNotZero6) dsDel = false;
  22098. string cssStr = item["CityTax"].ToString();
  22099. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  22100. if (containsDigitButNotZero7) cssDel = false;
  22101. string cpStr = item["ConsumptionPatterns"].ToString();
  22102. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  22103. string remarkStr = item["Remark"].ToString();
  22104. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  22105. }
  22106. DeleteColumn(serverPath, remarkIndex, remarkDel);
  22107. DeleteColumn(serverPath, cpIndex, cpDel);
  22108. DeleteColumn(serverPath, dsIndex, dsDel);
  22109. DeleteColumn(serverPath, cssIndex, cssDel);
  22110. DeleteColumn(serverPath, zcIndex, zcDel);
  22111. DeleteColumn(serverPath, otherIndex, otherDel);
  22112. DeleteColumn(serverPath, suiteIndex, suiteDel);
  22113. DeleteColumn(serverPath, doubleIndex, doubleDel);
  22114. DeleteColumn(serverPath, singleIndex, singleDel);
  22115. #endregion
  22116. //只保留第一个表格
  22117. DeleteSheet(serverPath);
  22118. return Ok(JsonView(true, "操作成功", url = rst));
  22119. }
  22120. else
  22121. {
  22122. _currency = _GroupCostParameter.Currency;
  22123. bool isIntType = int.TryParse(_currency, out int currId);
  22124. if (isIntType)
  22125. {
  22126. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  22127. }
  22128. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  22129. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  22130. if (currInfo == null)
  22131. {
  22132. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  22133. }
  22134. if (!_currency.ToUpper().Equals("CNY"))
  22135. {
  22136. _rate = _GroupCostParameter.Rate;
  22137. }
  22138. _rate = currInfo.Rate;
  22139. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  22140. //string strFileName = "HotelStatement/";
  22141. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  22142. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  22143. #region 数据处理
  22144. foreach (var item in hrDtas)
  22145. {
  22146. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  22147. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  22148. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  22149. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  22150. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  22151. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  22152. string singleRoomFeeStr = string.Empty,
  22153. doubleRoomFeeStr = string.Empty,
  22154. suiteRoomFeeStr = string.Empty,
  22155. otherRoomFeeStr = string.Empty,
  22156. payMoneyStr = string.Empty,
  22157. cardPriceStr = string.Empty;
  22158. if (roomCurr.Equals(_currency))
  22159. {
  22160. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  22161. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  22162. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  22163. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  22164. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  22165. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  22166. }
  22167. else
  22168. {
  22169. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  22170. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  22171. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  22172. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  22173. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  22174. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  22175. }
  22176. string breakfastPriceStr = string.Empty,
  22177. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  22178. governmentRentStr = string.Empty,
  22179. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  22180. cityTaxStrStr = string.Empty,
  22181. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  22182. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  22183. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  22184. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  22185. int payDId = roomInfo?.PayDId ?? 0;
  22186. pcfds.Add(new HotelReservations_PCFD_View()
  22187. {
  22188. City = item.City,
  22189. HotelName = item.HotelName,
  22190. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  22191. // SingleRoomCount = item.SingleRoomCount,
  22192. SingleRoomPrice = singleRoomFeeStr,
  22193. // DoubleRoomCount = item.DoubleRoomCount,
  22194. DoubleRoomPrice = doubleRoomFeeStr,
  22195. //SuiteRoomCount = item.SuiteRoomCount,
  22196. SuiteRoomPrice = suiteRoomFeeStr,
  22197. OtherRoomPrice = otherRoomFeeStr,
  22198. //OtherRoomCount = item.OtherRoomCount,
  22199. BreakfastPrice = breakfastPriceStr,
  22200. GovernmentRent = governmentRentStr,
  22201. CityTax = cityTaxStrStr,
  22202. RoomExplanation = item.RoomExplanation,
  22203. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  22204. PayTime = roomInfo?.ConsumptionDate,
  22205. BankNo = roomInfo?.BankNo,
  22206. PayMoney = payMoneyStr,
  22207. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  22208. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  22209. CardPrice = cardPriceStr,
  22210. Remark = ccpInfo.Remark
  22211. });
  22212. }
  22213. #endregion
  22214. //载入模板
  22215. WorkbookDesigner designer = new WorkbookDesigner();
  22216. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  22217. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  22218. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  22219. designer.SetDataSource("TourNo", groupInfo.TourCode);
  22220. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  22221. designer.SetDataSource("Opertor", userInfo.CnName);
  22222. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  22223. dt.TableName = "ViewMyHotelReservations";
  22224. designer.SetDataSource(dt);
  22225. designer.Process();
  22226. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  22227. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  22228. designer.Workbook.Save(serverPath);
  22229. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  22230. #region 删除指定行
  22231. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  22232. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  22233. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  22234. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  22235. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  22236. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  22237. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  22238. cssIndex = dt.Columns["CityTax"].Ordinal,
  22239. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  22240. remarkIndex = dt.Columns["Remark"].Ordinal;
  22241. //删除指定列
  22242. foreach (DataRow item in dt.Rows)
  22243. {
  22244. string singleStr = item["SingleRoomPrice"].ToString();
  22245. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  22246. if (containsDigitButNotZero1) singleDel = false;
  22247. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  22248. string doubleStr = item["DoubleRoomPrice"].ToString();
  22249. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22250. if (containsDigitButNotZero2) doubleDel = false;
  22251. string suiteStr = item["SuiteRoomPrice"].ToString();
  22252. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22253. if (containsDigitButNotZero3) suiteDel = false;
  22254. string otherStr = item["OtherRoomPrice"].ToString();
  22255. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  22256. if (containsDigitButNotZero4) otherDel = false;
  22257. string zcStr = item["BreakfastPrice"].ToString();
  22258. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  22259. if (containsDigitButNotZero5) zcDel = false;
  22260. string dsStr = item["GovernmentRent"].ToString();
  22261. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  22262. if (containsDigitButNotZero6) dsDel = false;
  22263. string cssStr = item["CityTax"].ToString();
  22264. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  22265. if (containsDigitButNotZero7) cssDel = false;
  22266. string cpStr = item["ConsumptionPatterns"].ToString();
  22267. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  22268. string remarkStr = item["Remark"].ToString();
  22269. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  22270. }
  22271. DeleteColumn(serverPath, remarkIndex, remarkDel);
  22272. DeleteColumn(serverPath, cpIndex, cpDel);
  22273. DeleteColumn(serverPath, dsIndex, dsDel);
  22274. DeleteColumn(serverPath, cssIndex, cssDel);
  22275. DeleteColumn(serverPath, zcIndex, zcDel);
  22276. DeleteColumn(serverPath, otherIndex, otherDel);
  22277. DeleteColumn(serverPath, suiteIndex, suiteDel);
  22278. DeleteColumn(serverPath, doubleIndex, doubleDel);
  22279. DeleteColumn(serverPath, singleIndex, singleDel);
  22280. #endregion
  22281. //只保留第一个表格
  22282. DeleteSheet(serverPath);
  22283. return Ok(JsonView(true, "操作成功", url = rst));
  22284. }
  22285. //return Ok(JsonView(false));
  22286. }
  22287. /// <summary>
  22288. /// 删除指定列
  22289. /// </summary>
  22290. /// <param name="file"></param>
  22291. /// <param name="columnIndex"></param>
  22292. /// <param name="isDel"></param>
  22293. private void DeleteColumn(string file, int columnIndex, bool isDel)
  22294. {
  22295. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  22296. //wb.Save(file);
  22297. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  22298. if (sheet1 != null)
  22299. {
  22300. if (isDel)
  22301. {
  22302. Cells cells = sheet1.Cells;
  22303. cells.DeleteColumn(columnIndex);
  22304. }
  22305. }
  22306. wb.Save(file);
  22307. }
  22308. /// <summary>
  22309. /// 删除sheet
  22310. /// </summary>
  22311. /// <param name="file"></param>
  22312. private void DeleteSheet(string file)
  22313. {
  22314. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  22315. //wb.Save(file);
  22316. List<string> sheets = new List<string>();
  22317. foreach (var item in wb.Worksheets)
  22318. {
  22319. sheets.Add(item.Name);
  22320. }
  22321. if (sheets.Count > 0)
  22322. {
  22323. sheets.RemoveAt(0);//不删除第一个sheet
  22324. foreach (var item in sheets)
  22325. {
  22326. wb.Worksheets.RemoveAt(item);
  22327. }
  22328. }
  22329. wb.Save(file);
  22330. }
  22331. /// <summary>
  22332. /// 酒店预订
  22333. /// 确认单
  22334. /// </summary>
  22335. /// <param name="_dto"></param>
  22336. /// <returns></returns>
  22337. [HttpPost]
  22338. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22339. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  22340. {
  22341. try
  22342. {
  22343. #region 参数验证
  22344. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  22345. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  22346. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  22347. #region 团组操作权限验证 76 酒店预定模块
  22348. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  22349. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  22350. #endregion
  22351. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22352. #region 页面操作权限验证
  22353. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22354. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  22355. #endregion
  22356. #endregion
  22357. //团组信息
  22358. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  22359. //酒店数据
  22360. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  22361. if (listhoteldata.Count < 0)
  22362. {
  22363. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  22364. }
  22365. //利datatable存储
  22366. DataTable dt = new DataTable();
  22367. dt.Columns.Add("CheckInDate", typeof(string));
  22368. dt.Columns.Add("City", typeof(string));
  22369. dt.Columns.Add("Hotel", typeof(string));
  22370. dt.Columns.Add("Room", typeof(string));
  22371. for (int i = 0; i < listhoteldata.Count; i++)
  22372. {
  22373. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  22374. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  22375. while (dayStart < dayEnd)
  22376. {
  22377. string temp = "";
  22378. DataRow row = dt.NewRow();
  22379. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  22380. row["City"] = listhoteldata[i].City;
  22381. row["Hotel"] = listhoteldata[i].HotelName;
  22382. if (listhoteldata[i].SingleRoomCount > 0)
  22383. {
  22384. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  22385. }
  22386. if (listhoteldata[i].DoubleRoomCount > 0)
  22387. {
  22388. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  22389. }
  22390. if (listhoteldata[i].SuiteRoomCount > 0)
  22391. {
  22392. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  22393. }
  22394. if (listhoteldata[i].OtherRoomCount > 0)
  22395. {
  22396. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  22397. }
  22398. row["Room"] = temp;
  22399. dt.Rows.Add(row);
  22400. dayStart = dayStart.AddDays(1);
  22401. }
  22402. }
  22403. Dictionary<string, string> dic = new Dictionary<string, string>();
  22404. dic.Add("Dele", di.TeamName);
  22405. dic.Add("City", di.VisitCountry);
  22406. //模板路径
  22407. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  22408. //载入模板
  22409. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  22410. DocumentBuilder builder = new DocumentBuilder(doc);
  22411. foreach (var key in dic.Keys)
  22412. {
  22413. builder.MoveToBookmark(key);
  22414. builder.Write(dic[key]);
  22415. }
  22416. //获取word里所有表格
  22417. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22418. //获取所填表格的序数
  22419. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22420. var rowStart = tableOne.Rows[0]; //获取第1行
  22421. //循环赋值
  22422. for (int i = 0; i < dt.Rows.Count; i++)
  22423. {
  22424. builder.MoveToCell(0, i + 1, 0, 0);
  22425. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  22426. builder.MoveToCell(0, i + 1, 1, 0);
  22427. builder.Write(dt.Rows[i]["City"].ToString());
  22428. builder.MoveToCell(0, i + 1, 2, 0);
  22429. builder.Write(dt.Rows[i]["Hotel"].ToString());
  22430. builder.MoveToCell(0, i + 1, 3, 0);
  22431. builder.Write(dt.Rows[i]["Room"].ToString());
  22432. }
  22433. //删除多余行
  22434. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  22435. {
  22436. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  22437. }
  22438. string strFileName = di.TeamName + "酒店确认单.doc";
  22439. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  22440. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  22441. return Ok(JsonView(true, "成功", url));
  22442. }
  22443. catch (Exception ex)
  22444. {
  22445. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  22446. }
  22447. }
  22448. #endregion
  22449. #region 团组状态
  22450. /// <summary>
  22451. /// 团组状态列表 Page
  22452. /// </summary>
  22453. /// <param name="dto">团组列表请求dto</param>
  22454. /// <returns></returns>
  22455. [HttpPost]
  22456. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22457. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  22458. {
  22459. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  22460. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  22461. {
  22462. string sqlWhere = string.Empty;
  22463. if (dto.IsSure == 0) //未完成
  22464. {
  22465. sqlWhere += string.Format(@" And IsSure = 0");
  22466. }
  22467. else if (dto.IsSure == 1) //已完成
  22468. {
  22469. sqlWhere += string.Format(@" And IsSure = 1");
  22470. }
  22471. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  22472. {
  22473. string tj = dto.SearchCriteria;
  22474. 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}%')",
  22475. tj, tj, tj, tj, tj);
  22476. }
  22477. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  22478. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  22479. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  22480. From (
  22481. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  22482. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  22483. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  22484. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  22485. From Grp_DelegationInfo gdi
  22486. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  22487. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  22488. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  22489. Where gdi.IsDel = 0 {0}
  22490. ) temp ", sqlWhere);
  22491. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  22492. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  22493. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  22494. }
  22495. else
  22496. {
  22497. return Ok(JsonView(false, "查询失败"));
  22498. }
  22499. }
  22500. /// <summary>
  22501. /// 团组状态
  22502. /// 设置操作完成
  22503. /// </summary>
  22504. /// <param name="dto">团组列表请求dto</param>
  22505. /// <returns></returns>
  22506. [HttpPost]
  22507. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22508. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  22509. {
  22510. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  22511. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  22512. {
  22513. Id = dto.Id,
  22514. IsSure = 1
  22515. };
  22516. var result = await _sqlSugar.Updateable(_DelegationInfo)
  22517. .UpdateColumns(it => new { it.IsSure })
  22518. .WhereColumns(it => new { it.Id })
  22519. .ExecuteCommandAsync();
  22520. if (result > 0)
  22521. {
  22522. return Ok(JsonView(true, "操作完成!"));
  22523. }
  22524. return Ok(JsonView(false, "操作失败!"));
  22525. }
  22526. #endregion
  22527. #region 保险费用录入
  22528. /// <summary>
  22529. /// 根据团组Id查询保险费用列表
  22530. /// </summary>
  22531. /// <param name="dto"></param>
  22532. /// <returns></returns>
  22533. [HttpPost]
  22534. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22535. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  22536. {
  22537. Result groupData = await _customersRep.CustomersByDiId(dto);
  22538. if (groupData.Code != 0)
  22539. {
  22540. return Ok(JsonView(false, groupData.Msg));
  22541. }
  22542. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22543. }
  22544. /// <summary>
  22545. /// 根据保险费用Id查询保险费用详细
  22546. /// </summary>
  22547. /// <param name="dto"></param>
  22548. /// <returns></returns>
  22549. [HttpPost]
  22550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22551. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  22552. {
  22553. try
  22554. {
  22555. Result groupData = await _customersRep.CustomersById(dto);
  22556. if (groupData.Code != 0)
  22557. {
  22558. return Ok(JsonView(false, groupData.Msg));
  22559. }
  22560. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22561. }
  22562. catch (Exception ex)
  22563. {
  22564. return Ok(JsonView(false, ex.Message));
  22565. }
  22566. }
  22567. /// <summary>
  22568. /// 保险费用录入页面初始化绑定
  22569. /// </summary>
  22570. /// <param name="dto"></param>
  22571. /// <returns></returns>
  22572. [HttpPost]
  22573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22574. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  22575. {
  22576. try
  22577. {
  22578. Result groupData = await _customersRep.CustomersInitialize(dto);
  22579. if (groupData.Code != 0)
  22580. {
  22581. return Ok(JsonView(false, groupData.Msg));
  22582. }
  22583. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22584. }
  22585. catch (Exception ex)
  22586. {
  22587. return Ok(JsonView(false, ex.Message));
  22588. }
  22589. }
  22590. /// <summary>
  22591. /// 保险费用操作(Status:1.新增,2.修改)
  22592. /// </summary>
  22593. /// <param name="dto"></param>
  22594. /// <returns></returns>
  22595. [HttpPost]
  22596. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22597. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  22598. {
  22599. Result groupData = await _customersRep.OpCustomers(dto);
  22600. if (groupData.Code != 0)
  22601. {
  22602. return Ok(JsonView(false, groupData.Msg));
  22603. }
  22604. #region 应用推送
  22605. try
  22606. {
  22607. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  22608. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  22609. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  22610. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  22611. //自动审核
  22612. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  22613. //2024-10-21 新增LZ UID
  22614. var userIds = new List<int>() { 21 };
  22615. string title = $"系统通知";
  22616. var diId = dto.DiId;
  22617. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  22618. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  22619. string content = "";
  22620. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  22621. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  22622. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  22623. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  22624. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  22625. }
  22626. catch (Exception ex)
  22627. {
  22628. }
  22629. #endregion
  22630. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22631. }
  22632. /// <summary>
  22633. /// 保险文件上传
  22634. /// </summary>
  22635. /// <param name="file"></param>
  22636. /// <returns></returns>
  22637. [HttpPost]
  22638. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22639. public async Task<IActionResult> UploadCus(IFormFile file)
  22640. {
  22641. try
  22642. {
  22643. if (file != null)
  22644. {
  22645. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  22646. //文件名称
  22647. string projectFileName = file.FileName;
  22648. //上传的文件的路径
  22649. string filePath = "";
  22650. if (!Directory.Exists(fileDir))
  22651. {
  22652. Directory.CreateDirectory(fileDir);
  22653. }
  22654. //上传的文件的路径
  22655. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  22656. using (FileStream fs = System.IO.File.Create(filePath))
  22657. {
  22658. file.CopyTo(fs);
  22659. fs.Flush();
  22660. }
  22661. return Ok(JsonView(true, "上传成功!", projectFileName));
  22662. }
  22663. else
  22664. {
  22665. return Ok(JsonView(false, "上传失败!"));
  22666. }
  22667. }
  22668. catch (Exception ex)
  22669. {
  22670. return Ok(JsonView(false, ex.Message));
  22671. }
  22672. }
  22673. /// <summary>
  22674. /// 保险删除指定文件
  22675. /// </summary>
  22676. /// <param name="dto"></param>
  22677. /// <returns></returns>
  22678. [HttpPost]
  22679. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22680. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  22681. {
  22682. try
  22683. {
  22684. string filePath = "";
  22685. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  22686. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  22687. //int id = 0;
  22688. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  22689. // 删除该文件
  22690. try
  22691. {
  22692. System.IO.File.Delete(filePath);
  22693. 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()
  22694. {
  22695. Attachment = "",
  22696. }).ExecuteCommandAsync();
  22697. if (result != 0)
  22698. {
  22699. return Ok(JsonView(true, "成功!"));
  22700. }
  22701. else
  22702. {
  22703. return Ok(JsonView(false, "失败!"));
  22704. }
  22705. }
  22706. catch (Exception)
  22707. {
  22708. 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()
  22709. {
  22710. Attachment = "",
  22711. }).ExecuteCommandAsync();
  22712. if (result != 0)
  22713. {
  22714. return Ok(JsonView(true, "成功!"));
  22715. }
  22716. else
  22717. {
  22718. return Ok(JsonView(false, "失败!"));
  22719. }
  22720. }
  22721. }
  22722. catch (Exception ex)
  22723. {
  22724. return Ok(JsonView(false, "程序错误!"));
  22725. throw;
  22726. }
  22727. }
  22728. /// <summary>
  22729. /// 保险费用操作(删除)
  22730. /// </summary>
  22731. /// <param name="dto"></param>
  22732. /// <returns></returns>
  22733. [HttpPost]
  22734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22735. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  22736. {
  22737. try
  22738. {
  22739. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  22740. if (!res)
  22741. {
  22742. return Ok(JsonView(false, "删除失败"));
  22743. }
  22744. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  22745. {
  22746. IsDel = 1,
  22747. DeleteUserId = dto.DeleteUserId,
  22748. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  22749. }).ExecuteCommandAsync();
  22750. return Ok(JsonView(true, "删除成功!"));
  22751. }
  22752. catch (Exception ex)
  22753. {
  22754. return Ok(JsonView(false, "程序错误!"));
  22755. throw;
  22756. }
  22757. }
  22758. #endregion
  22759. #region 接团客户名单 PageId 104
  22760. /// <summary>
  22761. /// 接团客户名单
  22762. /// 迁移数据(慎用!)
  22763. /// </summary>
  22764. /// <returns></returns>
  22765. [HttpPost]
  22766. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22767. public async Task<IActionResult> PostTourClientListChange()
  22768. {
  22769. try
  22770. {
  22771. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  22772. //var groupClinetData1
  22773. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  22774. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  22775. int updateCount = 0;
  22776. if (oldOAClientList.Count > 0)
  22777. {
  22778. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  22779. _sqlSugar.BeginTran();
  22780. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  22781. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  22782. foreach (var item in oldOAClientList)
  22783. {
  22784. int comId = 0;
  22785. string format = "yyyy-MM-dd HH:mm:ss";
  22786. string data11 = "1990-01-01 00:00";
  22787. var data1 = IsValidDate(item.OPdate, format);
  22788. if (data1) data11 = item.OPdate;
  22789. //客户公司验证
  22790. if (!string.IsNullOrEmpty(item.Company))
  22791. {
  22792. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  22793. if (clientComInfo == null) // add
  22794. {
  22795. var addInfo = new Crm_CustomerCompany()
  22796. {
  22797. CompanyAbbreviation = "",
  22798. CompanyFullName = item.Company,
  22799. Address = "",
  22800. PostCodes = "",
  22801. LastedOpUserId = item.OPer,
  22802. LastedOpDt = Convert.ToDateTime(data11),
  22803. CreateUserId = item.OPer,
  22804. CreateTime = Convert.ToDateTime(data11),
  22805. IsDel = 0
  22806. };
  22807. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  22808. if (comId1 > 0) comId = comId1;
  22809. }
  22810. else comId = clientComInfo.Id;
  22811. }
  22812. //客户人员验证
  22813. int clientId = 0;
  22814. string name = item.LastName + item.Name;
  22815. if (!string.IsNullOrEmpty(name))
  22816. {
  22817. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  22818. if (clientInfo == null)
  22819. {
  22820. DateTime? dateTime = null;
  22821. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  22822. if (isDt) dateTime = birthDayDt;
  22823. var addInfo1 = new Crm_DeleClient()
  22824. {
  22825. CrmCompanyId = comId,
  22826. DiId = -1,
  22827. LastName = item.LastName,
  22828. FirstName = item.Name,
  22829. OldName = "",
  22830. Pinyin = item.Pinyin,
  22831. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  22832. Marriage = 0,
  22833. Phone = item.Phone,
  22834. Job = item.Job,
  22835. BirthDay = dateTime
  22836. };
  22837. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  22838. if (clientId1 > 0) clientId = clientId1;
  22839. }
  22840. else clientId = clientInfo.Id;
  22841. }
  22842. if (clientId < 1)
  22843. {
  22844. continue;
  22845. }
  22846. int airType = 0;
  22847. if (item.AirType == "超经舱") airType = 459;
  22848. else if (item.AirType == "公务舱") airType = 458;
  22849. else if (item.AirType == "经济舱") airType = 460;
  22850. else if (item.AirType == "其他") airType = 565;
  22851. else if (item.AirType == "头等舱") airType = 457;
  22852. var _TourClientListEntity = new Grp_TourClientList()
  22853. {
  22854. DiId = item.Diid,
  22855. ClientId = clientId,
  22856. CreateUserId = item.OPer,
  22857. CreateTime = Convert.ToDateTime(data11),
  22858. Remark = item.Remark,
  22859. IsDel = item.Isdel,
  22860. ShippingSpaceTypeId = airType,
  22861. ShippingSpaceSpecialNeeds = item.AirRemark,
  22862. HotelSpecialNeeds = item.RoomType
  22863. };
  22864. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  22865. if (_TourClientList > 0)
  22866. {
  22867. updateCount++;
  22868. }
  22869. }
  22870. _sqlSugar.CommitTran();
  22871. }
  22872. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  22873. }
  22874. catch (Exception ex)
  22875. {
  22876. _sqlSugar.RollbackTran();
  22877. return Ok(JsonView(false, ex.Message));
  22878. }
  22879. //return Ok(JsonView(true));
  22880. }
  22881. private bool IsValidDate(string dateString, string format)
  22882. {
  22883. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  22884. }
  22885. /// <summary>
  22886. /// 接团客户名单
  22887. /// 根据团组Id查询List
  22888. /// </summary>
  22889. /// <param name="_dto"></param>
  22890. /// <returns></returns>
  22891. [HttpPost]
  22892. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22893. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  22894. {
  22895. #region 参数验证
  22896. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  22897. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  22898. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  22899. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22900. #region 页面操作权限验证
  22901. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22902. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  22903. #endregion
  22904. #endregion
  22905. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  22906. if (viewData.Code != 0)
  22907. {
  22908. return Ok(JsonView(false, viewData.Msg));
  22909. }
  22910. return Ok(JsonView(viewData.Data));
  22911. }
  22912. /// <summary>
  22913. /// 接团客户名单
  22914. /// 基础数据 Init
  22915. /// </summary>
  22916. /// <param name="_dto"></param>
  22917. /// <returns></returns>
  22918. [HttpPost]
  22919. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22920. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  22921. {
  22922. #region 参数验证
  22923. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  22924. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  22925. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22926. #region 页面操作权限验证
  22927. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22928. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  22929. #endregion
  22930. #endregion
  22931. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  22932. }
  22933. /// <summary>
  22934. /// 接团客户名单
  22935. /// 根据 Id查询 Details
  22936. /// </summary>
  22937. /// <param name="_dto"></param>
  22938. /// <returns></returns>
  22939. [HttpPost]
  22940. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22941. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  22942. {
  22943. #region 参数验证
  22944. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  22945. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  22946. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  22947. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22948. #region 页面操作权限验证
  22949. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22950. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  22951. #endregion
  22952. #endregion
  22953. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  22954. if (viewData.Code != 0)
  22955. {
  22956. return Ok(JsonView(false, viewData.Msg));
  22957. }
  22958. return Ok(JsonView(viewData.Data));
  22959. }
  22960. /// <summary>
  22961. /// 接团客户名单
  22962. /// Add Or Edit
  22963. /// </summary>
  22964. /// <param name="_dto"></param>
  22965. /// <returns></returns>
  22966. [HttpPost]
  22967. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22968. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  22969. {
  22970. #region 参数验证
  22971. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  22972. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  22973. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  22974. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22975. #region 页面操作权限验证
  22976. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22977. if (_dto.Id == 0) //添加
  22978. {
  22979. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  22980. }
  22981. else if (_dto.Id >= 0) //修改
  22982. {
  22983. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  22984. }
  22985. #endregion
  22986. #endregion
  22987. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  22988. if (viewData.Code != 0)
  22989. {
  22990. return Ok(JsonView(false, viewData.Msg));
  22991. }
  22992. return Ok(JsonView(true));
  22993. }
  22994. /// <summary>
  22995. /// 接团客户名单
  22996. /// json字符串 AddMultiple(添加多个)
  22997. /// </summary>
  22998. /// <param name="_dto"></param>
  22999. /// <returns></returns>
  23000. [HttpPost]
  23001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23002. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  23003. {
  23004. #region 参数验证
  23005. string jsonLabel = _dto.JsonLabel;
  23006. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23007. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23008. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23009. #region 页面操作权限验证
  23010. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23011. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  23012. #endregion
  23013. #endregion
  23014. var request = new TourClientListAddMultipleDto();
  23015. request.DiId = _dto.DiId;
  23016. request.UserId = _dto.UserId;
  23017. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  23018. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  23019. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  23020. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  23021. var infos = new List<TourClientListInfo>();
  23022. foreach (var data in datas)
  23023. {
  23024. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  23025. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  23026. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  23027. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  23028. {
  23029. continue;
  23030. }
  23031. infos.Add(new TourClientListInfo()
  23032. {
  23033. IsAccompany = 1,
  23034. LastName = lastName,
  23035. FirstName = firstName,
  23036. Pinyin = lastNameEn + @"/" + firstNameEn,
  23037. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  23038. CompanyFullName = data.CompanyFullName,
  23039. Job = data.Job
  23040. });
  23041. }
  23042. if (infos.Any())
  23043. {
  23044. var viewData = await _tourClientListRep._AddMultiple(request);
  23045. if (viewData.Code != 0)
  23046. {
  23047. return Ok(JsonView(false, viewData.Msg));
  23048. }
  23049. return Ok(JsonView(true));
  23050. }
  23051. return Ok(JsonView(false));
  23052. }
  23053. /// <summary>
  23054. /// 接团客户名单
  23055. /// AddMultiple(添加多个)
  23056. /// </summary>
  23057. /// <param name="_dto"></param>
  23058. /// <returns></returns>
  23059. [HttpPost]
  23060. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23061. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  23062. {
  23063. #region 参数验证
  23064. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23065. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23066. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23067. #region 页面操作权限验证
  23068. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23069. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  23070. #endregion
  23071. #endregion
  23072. var viewData = await _tourClientListRep._AddMultiple(_dto);
  23073. if (viewData.Code != 0)
  23074. {
  23075. return Ok(JsonView(false, viewData.Msg));
  23076. }
  23077. return Ok(JsonView(true));
  23078. }
  23079. /// <summary>
  23080. /// 接团客户名单
  23081. /// Del
  23082. /// </summary>
  23083. /// <param name="_dto"></param>
  23084. /// <returns></returns>
  23085. [HttpPost]
  23086. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23087. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  23088. {
  23089. #region 参数验证
  23090. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23091. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23092. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23093. #region 页面操作权限验证
  23094. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23095. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  23096. #endregion
  23097. #endregion
  23098. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  23099. if (viewData.Code != 0)
  23100. {
  23101. return Ok(JsonView(false, viewData.Msg));
  23102. }
  23103. return Ok(JsonView(true));
  23104. }
  23105. /// <summary>
  23106. /// 接团客户名单
  23107. /// 文件下载 客户名单
  23108. /// </summary>
  23109. /// <param name="_dto"></param>
  23110. /// <returns></returns>
  23111. [HttpPost]
  23112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23113. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  23114. {
  23115. #region 参数验证
  23116. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23117. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23118. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  23119. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23120. #region 页面操作权限验证
  23121. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23122. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  23123. #endregion
  23124. #endregion
  23125. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  23126. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  23127. From Grp_TourClientList tcl
  23128. Left Join
  23129. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  23130. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  23131. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  23132. From Crm_DeleClient dc
  23133. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  23134. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  23135. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  23136. Where dc.IsDel = 0) temp
  23137. On temp.DcId =tcl.ClientId
  23138. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  23139. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  23140. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  23141. //载入模板
  23142. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  23143. if (_dto.Language == 1)
  23144. {
  23145. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  23146. }
  23147. //载入模板
  23148. var doc = new Document(tempPath);
  23149. DocumentBuilder builder = new DocumentBuilder(doc);
  23150. //获取word里所有表格
  23151. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  23152. //获取所填表格的序数
  23153. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  23154. var rowStart = tableOne.Rows[0]; //获取第1行
  23155. if (_dto.Language == 0)
  23156. {
  23157. //循环赋值
  23158. for (int i = 0; i < DcList.Count; i++)
  23159. {
  23160. EncryptionProcessor.DecryptProperties(DcList[i]);
  23161. builder.MoveToCell(0, i + 1, 0, 0);
  23162. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  23163. builder.MoveToCell(0, i + 1, 1, 0);
  23164. int sex = DcList[i].Sex;
  23165. string sexStr = string.Empty;
  23166. if (sex == 0) sexStr = "男";
  23167. else if (sex == 1) sexStr = "女";
  23168. else sexStr = "未设置";
  23169. builder.Write(sexStr);
  23170. builder.MoveToCell(0, i + 1, 2, 0);
  23171. string birthDay = DcList[i].BirthDay;
  23172. string birthDayStr = string.Empty;
  23173. if (!string.IsNullOrEmpty(birthDay))
  23174. {
  23175. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  23176. }
  23177. builder.Write(birthDayStr);
  23178. builder.MoveToCell(0, i + 1, 3, 0);
  23179. string company = "";
  23180. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  23181. {
  23182. company = DcList[i].CompanyFullName.ToString();
  23183. }
  23184. builder.Write(company);
  23185. builder.MoveToCell(0, i + 1, 4, 0);
  23186. builder.Write(DcList[i].Job);
  23187. }
  23188. }
  23189. else if (_dto.Language == 1)
  23190. {
  23191. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  23192. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  23193. List<string> transArrayStr = new List<string>();
  23194. string transStrRes1 = "";
  23195. var clientEnglishs = new List<ClientEnglishView>();
  23196. for (int i = 0; i < DcList.Count; i++)
  23197. {
  23198. var dc = DcList[i];
  23199. EncryptionProcessor.DecryptProperties(dc);
  23200. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  23201. if (dc.Job.Equals("暂无")) dc.Job = "-";
  23202. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  23203. if (DcList.Count - 1 == i) transStrRes1 += str1;
  23204. else transStrRes1 += $"{str1}|";
  23205. clientEnglishs.Add(new()
  23206. {
  23207. Id = dc.Id,
  23208. LastName = dc.LastName,
  23209. FirstName = dc.FirstName,
  23210. Pinyin = dc.Pinyin,
  23211. Sex = dc.Sex,
  23212. CompanyFullName = dc.CompanyFullName,
  23213. Job = dc.Job,
  23214. IDCardNo = dc.IDCardNo,
  23215. BirthDay = dc.BirthDay,
  23216. });
  23217. }
  23218. #region AI转英文
  23219. string jsonValue = JsonConvert.SerializeObject(clientEnglishs);
  23220. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  23221. List<SeedMessages> messages = new List<SeedMessages>()
  23222. {
  23223. new SeedMessages
  23224. {
  23225. Role = KimiRole.user,
  23226. Content = jsonValue + text
  23227. }
  23228. };
  23229. KiMiApiClient client = new KiMiApiClient();
  23230. var kimiApiResult = await client.SeedMessage(messages);
  23231. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  23232. string clients = kimiApiResult_JObject["content"].ToString();
  23233. string startStr = "```json", endStr = "```";
  23234. // 判断并清除开头部分
  23235. if (clients.StartsWith(startStr))
  23236. {
  23237. clients = clients.Remove(0, startStr.Length);
  23238. }
  23239. // 判断并清除结尾部分
  23240. if (clients.EndsWith(endStr))
  23241. {
  23242. clients = clients.Remove(clients.Length - endStr.Length);
  23243. }
  23244. var en_Json = JsonConvert.DeserializeObject<List<ClientEnglishView>>(clients);
  23245. //循环赋值
  23246. for (int i = 0; i < en_Json.Count; i++)
  23247. {
  23248. var dc = en_Json[i];
  23249. var dc1 = DcList.Find(x => x.Id == dc.Id);
  23250. string PYName = dc.FirstName + " " + dc.LastName;
  23251. builder.MoveToCell(0, i + 1, 0, 0);
  23252. builder.Write(PYName);
  23253. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  23254. builder.MoveToCell(0, i + 1, 1, 0);
  23255. builder.Write(sex);
  23256. DateTime birthDt;
  23257. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  23258. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  23259. builder.MoveToCell(0, i + 1, 2, 0);
  23260. builder.Write(birthday);
  23261. string company = string.Empty, job = string.Empty;
  23262. company = dc.CompanyFullName;
  23263. job = dc.Job;
  23264. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  23265. {
  23266. //查询对照表
  23267. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  23268. if (tempCec != null)
  23269. {
  23270. company = tempCec.enName;
  23271. }
  23272. }
  23273. builder.MoveToCell(0, i + 1, 3, 0);
  23274. builder.Write(company);
  23275. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  23276. {
  23277. //查询对照表
  23278. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  23279. if (tempPec != null)
  23280. {
  23281. job = tempPec.enName;
  23282. }
  23283. }
  23284. builder.MoveToCell(0, i + 1, 4, 0);
  23285. builder.Write(job);
  23286. }
  23287. #endregion
  23288. #region 旧翻译英文处理
  23289. ////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";
  23290. //string transStrRes = "";
  23291. //if (transStrRes1.Length > 0)
  23292. //{
  23293. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  23294. //}
  23295. ////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
  23296. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  23297. ////List<string> transArray = new List<string> { };
  23298. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  23299. //if (transStrRes.Contains("|"))
  23300. //{
  23301. // string[] transArray1 = transStrRes.Split('|');
  23302. // if (transArray1.Length > 0)
  23303. // {
  23304. // foreach (var item in transArray1)
  23305. // {
  23306. // if (item.Contains("&"))
  23307. // {
  23308. // string[] transArray2 = item.Split('&');
  23309. // int index = 0;
  23310. // string companyName = "", job = "";
  23311. // if (transArray2.Length > 0)
  23312. // {
  23313. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  23314. // if (1 < transArray2.Length) companyName = transArray2[1];
  23315. // if (2 < transArray2.Length) job = transArray2[2];
  23316. // }
  23317. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  23318. // }
  23319. // }
  23320. // }
  23321. //}
  23322. ////循环赋值
  23323. //for (int i = 0; i < DcList.Count; i++)
  23324. //{
  23325. // string PYName = "";
  23326. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  23327. // {
  23328. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  23329. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  23330. // PYName = PY_First + " " + PY_Last;
  23331. // }
  23332. // else
  23333. // {
  23334. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  23335. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  23336. // PYName = PY_First + " " + PY_Last;
  23337. // }
  23338. // builder.MoveToCell(0, i + 1, 0, 0);
  23339. // builder.Write(PYName);
  23340. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  23341. // builder.MoveToCell(0, i + 1, 1, 0);
  23342. // builder.Write(sex);
  23343. // DateTime birthDt;
  23344. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  23345. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  23346. // builder.MoveToCell(0, i + 1, 2, 0);
  23347. // builder.Write(birthday);
  23348. // string company = string.Empty, job = string.Empty;
  23349. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  23350. // if (dcTransInfo != null)
  23351. // {
  23352. // company = dcTransInfo.CompanyName;
  23353. // job = dcTransInfo.Job;
  23354. // }
  23355. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  23356. // {
  23357. // //查询对照表
  23358. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  23359. // if (tempCec != null)
  23360. // {
  23361. // company = tempCec.enName;
  23362. // }
  23363. // //翻译
  23364. // else
  23365. // {
  23366. // }
  23367. // }
  23368. // builder.MoveToCell(0, i + 1, 3, 0);
  23369. // builder.Write(company);
  23370. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  23371. // {
  23372. // //查询对照表
  23373. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  23374. // if (tempPec != null)
  23375. // {
  23376. // job = tempPec.enName;
  23377. // }
  23378. // //翻译
  23379. // else
  23380. // {
  23381. // }
  23382. // }
  23383. // builder.MoveToCell(0, i + 1, 4, 0);
  23384. // builder.Write(job);
  23385. //}
  23386. #endregion
  23387. }
  23388. //删除多余行
  23389. while (tableOne.Rows.Count > DcList.Count + 1)
  23390. {
  23391. tableOne.Rows.RemoveAt(DcList.Count + 1);
  23392. }
  23393. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  23394. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  23395. doc.Save(fileDir);
  23396. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  23397. return Ok(JsonView(true, "操作成功!", Url));
  23398. }
  23399. private class TranslateInfo
  23400. {
  23401. public int Index { get; set; }
  23402. public string CompanyName { get; set; }
  23403. public string Job { get; set; }
  23404. }
  23405. [HttpPost]
  23406. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  23407. {
  23408. if (files.Count == 0)
  23409. {
  23410. return Ok(JsonView(false, "文件为空"));
  23411. }
  23412. KiMiApiClient KiMiApi = new KiMiApiClient();
  23413. var seedConter = await KiMiApi.UploadFilesAsync(files);
  23414. if (seedConter.Count == 0)
  23415. {
  23416. return Ok(JsonView(false, "上传结果为空!"));
  23417. }
  23418. var messages = new List<SeedMessages>
  23419. {
  23420. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  23421. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  23422. };
  23423. messages.InsertRange(1, seedConter);
  23424. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  23425. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  23426. string clients = kimiApiResult_JObject["content"].ToString();
  23427. string startStr = "```json", endStr = "```";
  23428. // 判断并清除开头部分
  23429. if (clients.StartsWith(startStr))
  23430. {
  23431. clients = clients.Remove(0, startStr.Length);
  23432. }
  23433. // 判断并清除结尾部分
  23434. if (clients.EndsWith(endStr))
  23435. {
  23436. clients = clients.Remove(clients.Length - endStr.Length);
  23437. }
  23438. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  23439. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  23440. {
  23441. {"姓", "LastName" },
  23442. {"名", "FirstName" },
  23443. {"姓名拼音", "Pinyin" },
  23444. {"性别", "Sex" },
  23445. {"单位", "CompanyFullName" },
  23446. {"职务", "Job" },
  23447. {"出生日期", "Birthday" },
  23448. };
  23449. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  23450. foreach (var item in clients_JObject)
  23451. {
  23452. BaiduClientOCRView cdc = new BaiduClientOCRView();
  23453. foreach (var field in clientFieldMap.Keys)
  23454. {
  23455. if (item.TryGetValue(field, out JToken value))
  23456. {
  23457. var getValue = value.ToString();
  23458. System.Type type = cdc.GetType();
  23459. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  23460. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  23461. propertyInfo.SetValue(cdc, propertyValue);
  23462. }
  23463. }
  23464. crmClients.Add(cdc);
  23465. }
  23466. return Ok(JsonView(new
  23467. {
  23468. fileCount = files.Count,
  23469. UploadCount = seedConter.Count,
  23470. ApiResult = clients,
  23471. CrmClients = crmClients
  23472. }));
  23473. }
  23474. #endregion
  23475. #region 团组倒推表
  23476. /// <summary>
  23477. /// 倒推表基础数据
  23478. /// Init
  23479. /// </summary>
  23480. /// <returns></returns>
  23481. [HttpPost]
  23482. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23483. public async Task<IActionResult> PostInvertedListInit()
  23484. {
  23485. var viewData = await _invertedListRep._Init();
  23486. if (viewData.Code != 0)
  23487. {
  23488. return Ok(JsonView(false, viewData.Msg));
  23489. }
  23490. return Ok(JsonView(viewData.Data));
  23491. }
  23492. /// <summary>
  23493. /// 倒推表
  23494. /// Info
  23495. /// </summary>
  23496. /// <param name="dto"></param>
  23497. /// <returns></returns>
  23498. [HttpPost]
  23499. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23500. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  23501. {
  23502. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  23503. if (viewData.Code != 0)
  23504. {
  23505. return Ok(JsonView(false, viewData.Msg));
  23506. }
  23507. return Ok(JsonView(viewData.Data));
  23508. }
  23509. /// <summary>
  23510. /// 倒推表
  23511. /// Create
  23512. /// </summary>
  23513. /// <param name="dto"></param>
  23514. /// <returns></returns>
  23515. [HttpPost]
  23516. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23517. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  23518. {
  23519. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  23520. if (viewData.Code != 0)
  23521. {
  23522. return Ok(JsonView(false, viewData.Msg));
  23523. }
  23524. return Ok(JsonView(viewData.Data));
  23525. }
  23526. /// <summary>
  23527. /// 倒推表
  23528. /// Update
  23529. /// </summary>
  23530. /// <param name="dto"></param>
  23531. /// <returns></returns>
  23532. [HttpPost]
  23533. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23534. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  23535. {
  23536. var viewData = await _invertedListRep._Update(dto);
  23537. if (viewData.Code != 0)
  23538. {
  23539. return Ok(JsonView(false, viewData.Msg));
  23540. }
  23541. return Ok(JsonView(viewData.Data));
  23542. }
  23543. /// <summary>
  23544. /// 倒推表
  23545. /// File Download
  23546. /// </summary>
  23547. /// <param name="dto"></param>
  23548. /// <returns></returns>
  23549. [HttpPost]
  23550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23551. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  23552. {
  23553. var info2 = await _invertedListRep._Info(1, dto.DiId);
  23554. if (info2.Code != 0)
  23555. {
  23556. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  23557. }
  23558. var info1 = info2.Data as InvertedListInfoView;
  23559. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  23560. string teamName = "";
  23561. if (info != null) teamName = info.TeamName;
  23562. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  23563. var doc = new Document();
  23564. var builder = new DocumentBuilder(doc);
  23565. #region old insert
  23566. ////载入模板
  23567. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  23568. //Document doc = new Document(tempPath);
  23569. //DocumentBuilder builder = new DocumentBuilder(doc);
  23570. //利用键值对存放数据
  23571. //Dictionary<string, string> dic = new Dictionary<string, string>();
  23572. //dic.Add("TeamName", teamName);
  23573. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  23574. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  23575. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  23576. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  23577. //dic.Add("SQRemark", info1.ApprovalRemark);
  23578. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  23579. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  23580. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  23581. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  23582. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  23583. //dic.Add("QZRemark", info1.VisaInformationRemark);
  23584. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  23585. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  23586. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  23587. //dic.Add("CQRemark", info1.IssueVisaRemark);
  23588. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  23589. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  23590. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  23591. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  23592. //#region 填充word模板书签内容
  23593. //foreach (var key in dic.Keys)
  23594. //{
  23595. // builder.MoveToBookmark(key);
  23596. // builder.Write(dic[key]);
  23597. //}
  23598. //#endregion
  23599. #endregion
  23600. #region New Insert
  23601. string titleFont = $"仿宋",
  23602. contentFont = $"仿宋";
  23603. var fontColor = Color.FromArgb(64, 64, 64);
  23604. //设置标题 团组名称
  23605. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  23606. builder.Font.Name = titleFont;
  23607. builder.Font.Color = fontColor;
  23608. builder.Font.Size = 12;
  23609. builder.Font.Bold = true;
  23610. builder.Writeln(teamName);
  23611. //设置副标题 团组出访时间
  23612. builder.Font.Size = 12;
  23613. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  23614. builder.Writeln();
  23615. var backgroundColor = Color.FromArgb(199, 199, 199);
  23616. var table = builder.StartTable();
  23617. builder.InsertCell();
  23618. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  23619. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  23620. builder.CellFormat.Borders.LineWidth = 1;
  23621. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  23622. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  23623. builder.RowFormat.Height = 40;
  23624. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  23625. builder.Font.Name = contentFont;
  23626. builder.Font.Size = 12;
  23627. builder.Font.Bold = true;
  23628. builder.Font.Color = fontColor;
  23629. builder.Write("时间");
  23630. builder.InsertCell();
  23631. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  23632. builder.Write("流程");
  23633. builder.InsertCell();
  23634. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  23635. builder.Write("说明");
  23636. builder.EndRow();
  23637. //报批资料准备
  23638. if (info1.IsSelectedAirportd)
  23639. {
  23640. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  23641. }
  23642. //报批/提供送签资料
  23643. if (info1.IsSelectedApprovalData)
  23644. {
  23645. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  23646. }
  23647. //出批件护照办理
  23648. if (info1.IsSelectedIssueApproval)
  23649. {
  23650. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  23651. }
  23652. //签证资料准备
  23653. if (info1.IsSelectedVisaInfo)
  23654. {
  23655. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  23656. }
  23657. //送签
  23658. if (info1.IsSelectedSendVisa)
  23659. {
  23660. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  23661. }
  23662. //出签
  23663. if (info1.IsSelectedIssueVisa)
  23664. {
  23665. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  23666. }
  23667. //机票
  23668. if (info1.IsSelectedAirTicket)
  23669. {
  23670. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  23671. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  23672. }
  23673. //酒店
  23674. if (info1.IsSelectedHotel)
  23675. {
  23676. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  23677. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  23678. }
  23679. //开行前会
  23680. if (info1.IsSelectedPreTripMeeting)
  23681. {
  23682. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  23683. }
  23684. //送机
  23685. if (info1.IsSelectedAirportdDropOff)
  23686. {
  23687. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  23688. }
  23689. builder.EndTable();
  23690. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  23691. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  23692. for (int i = 0; i < table.Rows.Count; i++)
  23693. {
  23694. var row = table.Rows[i];
  23695. //设置宽度
  23696. row.Cells[0].CellFormat.Width = 20.00;
  23697. row.Cells[1].CellFormat.Width = 30.00;
  23698. row.Cells[2].CellFormat.Width = 50.00;
  23699. if (i != 0)
  23700. {
  23701. //边框设置
  23702. InvertedListFileDownloadSetBorders(row.Cells, 0);
  23703. InvertedListFileDownloadSetBorders(row.Cells, 1);
  23704. InvertedListFileDownloadSetBorders(row.Cells, 2);
  23705. }
  23706. }
  23707. #region 页脚插入图片
  23708. // 创建页脚
  23709. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  23710. doc.FirstSection.HeadersFooters.Add(footer);
  23711. Paragraph para = new Paragraph(doc);
  23712. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  23713. footer.AppendChild(para);
  23714. builder.MoveTo(para);
  23715. string imagePath = "./Images/FMGJ_Log.png";
  23716. builder.InsertImage(imagePath);
  23717. #endregion
  23718. #endregion
  23719. var fileDir = AppSettingsHelper.Get("WordBasePath");
  23720. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  23721. string filePath = fileDir + $@"InvertedList/{fileName}";
  23722. doc.Save(filePath);
  23723. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  23724. return Ok(JsonView(true, "操作成功!", Url));
  23725. }
  23726. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  23727. {
  23728. var fontColor = Color.FromArgb(64, 64, 64);
  23729. builder.InsertCell();
  23730. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  23731. builder.RowFormat.Height = 40;
  23732. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  23733. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  23734. builder.Font.Name = fontName;
  23735. builder.Font.Size = 8;
  23736. builder.Font.Bold = true;
  23737. builder.Font.Color = fontColor;
  23738. builder.Write(dateTime);
  23739. builder.InsertCell();
  23740. builder.Font.Size = 9;
  23741. builder.Font.Bold = true;
  23742. builder.Font.Color = fontColor;
  23743. builder.Write(content);
  23744. builder.InsertCell();
  23745. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  23746. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  23747. builder.Font.Size = 9;
  23748. builder.Font.Bold = false;
  23749. builder.Font.Color = fontColor;
  23750. builder.Write(reamrk);
  23751. builder.EndRow();
  23752. }
  23753. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  23754. {
  23755. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  23756. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  23757. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  23758. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  23759. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  23760. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  23761. }
  23762. #endregion
  23763. #region 会务倒推表
  23764. /// <summary>
  23765. /// 会务倒推表
  23766. /// Init
  23767. /// </summary>
  23768. /// <returns></returns>
  23769. [HttpPost]
  23770. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23771. public async Task<IActionResult> InforRetrogressTableInit()
  23772. {
  23773. var groupData = await _groupRepository.PostShareGroupInfos(1);
  23774. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  23775. return Ok(JsonView(false, groupData.Msg));
  23776. }
  23777. /// <summary>
  23778. /// 会务倒推表
  23779. /// ExcelDownload
  23780. /// </summary>
  23781. /// <param name="dto"></param>
  23782. /// <returns></returns>
  23783. [HttpPost]
  23784. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  23785. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23786. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  23787. {
  23788. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  23789. var validatorRes = await validator.ValidateAsync(dto);
  23790. if (!validatorRes.IsValid)
  23791. {
  23792. StringBuilder sb = new StringBuilder();
  23793. foreach (var item in validatorRes.Errors)
  23794. {
  23795. sb.AppendLine(item.ErrorMessage);
  23796. }
  23797. return Ok(JsonView(false, sb.ToString()));
  23798. }
  23799. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  23800. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  23801. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  23802. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  23803. #region Excel
  23804. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  23805. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  23806. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  23807. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  23808. var fileNamePrefix = string.Empty;
  23809. if (days >= 30)
  23810. {
  23811. tempPath += $"会务工作倒推进度表(30天).xlsx";
  23812. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  23813. }
  23814. else if (days < 30 && days > 7)
  23815. {
  23816. tempPath += $"会务工作倒推进度表(15天).xlsx";
  23817. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  23818. }
  23819. else if (days <= 7)
  23820. {
  23821. tempPath += $"会务工作倒推进度表(7天).xlsx";
  23822. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  23823. }
  23824. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  23825. fileName = CommonFun.ValidFileName(fileName);
  23826. //载入模板
  23827. WorkbookDesigner designer = new WorkbookDesigner();
  23828. designer.Workbook = new Workbook(tempPath);
  23829. designer.Process();
  23830. if (!Directory.Exists(savePath))
  23831. {
  23832. Directory.CreateDirectory(savePath);
  23833. }
  23834. string serverPath = $"{savePath}{fileName}";
  23835. designer.Workbook.Save(serverPath);
  23836. string rst = $"{servicePath}{ftpPath}{fileName}";
  23837. #endregion
  23838. return Ok(JsonView(new { url = rst }));
  23839. }
  23840. #endregion
  23841. #region 三公签证费用(签证费、代办费)
  23842. /// <summary>
  23843. /// 三公签证费用(签证费、代办费)
  23844. /// List
  23845. /// </summary>
  23846. /// <returns></returns>
  23847. [HttpPost]
  23848. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23849. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  23850. {
  23851. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  23852. }
  23853. /// <summary>
  23854. /// 三公签证费用(签证费、代办费)
  23855. /// Add Or Update
  23856. /// </summary>
  23857. /// <returns></returns>
  23858. [HttpPost]
  23859. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23860. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  23861. {
  23862. var _view = await _visaFeeInfoRep.Update(_dto);
  23863. if (_view.Code != 0)
  23864. {
  23865. return Ok(JsonView(false, _view.Msg));
  23866. }
  23867. return Ok(JsonView(true, _view.Msg));
  23868. }
  23869. #endregion
  23870. #region 酒店询价
  23871. /// <summary>
  23872. /// 酒店询价
  23873. /// Init
  23874. /// </summary>
  23875. /// <returns></returns>
  23876. [HttpPost]
  23877. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23878. public async Task<IActionResult> PostHotelInquiryInit()
  23879. {
  23880. var res = await _hotelInquiryRep._Init();
  23881. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23882. return Ok(JsonView(true, res.Msg, res.Data));
  23883. }
  23884. /// <summary>
  23885. /// 酒店询价
  23886. /// page Item
  23887. /// </summary>
  23888. /// <param name="_dto"></param>
  23889. /// <returns></returns>
  23890. [HttpPost]
  23891. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23892. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  23893. {
  23894. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  23895. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23896. var view = res.Data as PageDataViewBase;
  23897. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  23898. }
  23899. /// <summary>
  23900. /// 酒店询价
  23901. /// info
  23902. /// </summary>
  23903. /// <param name="_dto"></param>
  23904. /// <returns></returns>
  23905. [HttpPost]
  23906. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23907. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  23908. {
  23909. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  23910. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23911. return Ok(JsonView(true, res.Msg, res.Data));
  23912. }
  23913. /// <summary>
  23914. /// 酒店询价
  23915. /// Add Or Edit
  23916. /// </summary>
  23917. /// <param name="_dto"></param>
  23918. /// <returns></returns>
  23919. [HttpPost]
  23920. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23921. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  23922. {
  23923. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  23924. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23925. return Ok(JsonView(true, res.Msg, res.Data));
  23926. }
  23927. /// <summary>
  23928. /// 酒店询价
  23929. /// Del
  23930. /// </summary>
  23931. /// <param name="_dto"></param>
  23932. /// <returns></returns>
  23933. [HttpPost]
  23934. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23935. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  23936. {
  23937. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  23938. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23939. return Ok(JsonView(true, res.Msg, res.Data));
  23940. }
  23941. #endregion
  23942. #region 下载匹配op行程单
  23943. /// <summary>
  23944. /// 匹配op行程单
  23945. /// Init
  23946. /// </summary>
  23947. /// <param name="dto">团组列表请求dto</param>
  23948. /// <returns></returns>
  23949. [HttpPost]
  23950. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23951. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  23952. {
  23953. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  23954. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  23955. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  23956. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  23957. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  23958. .Where(it => it.IsDel == 0)
  23959. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  23960. .OrderByDescending(it => it.VisitStartDate)
  23961. .ToList();
  23962. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  23963. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  23964. var diids = groupInfos.Select(it => it.Id).ToList();
  23965. List<string> countrys = new List<string>();
  23966. foreach (var item in country)
  23967. {
  23968. var data = _groupRepository.FormartTeamName(item);
  23969. var dataArray = _groupRepository.GroupSplitCountry(data);
  23970. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  23971. }
  23972. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  23973. List<string> areaArray = new List<string>(); //GetGroupCityLine
  23974. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  23975. foreach (var item in areaItem)
  23976. {
  23977. string areaStr = item.Value;
  23978. if (!string.IsNullOrEmpty(areaStr))
  23979. {
  23980. string[] str1 = areaStr.Split("-");
  23981. if (str1.Length > 0)
  23982. {
  23983. areaArray.AddRange(str1);
  23984. }
  23985. }
  23986. }
  23987. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  23988. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  23989. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  23990. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  23991. .ToList();
  23992. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  23993. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  23994. .Where(it => countriesIds.Contains(it.Id))
  23995. .Select(it => new { it.Id, Name = it.Name_CN })
  23996. .ToList();
  23997. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  23998. .Select(it => it.TeamName).ToList();
  23999. stopwatch.Stop();
  24000. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  24001. }
  24002. ///// <summary>
  24003. ///// 匹配op行程单
  24004. ///// Init 查询区域数据
  24005. ///// </summary>
  24006. ///// <param name="dto">团组列表请求dto</param>
  24007. ///// <returns></returns>
  24008. //[HttpPost]
  24009. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24010. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  24011. //{
  24012. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  24013. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  24014. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  24015. // if (string.IsNullOrEmpty(countriesDataStr))
  24016. // {
  24017. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  24018. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  24019. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  24020. // }
  24021. // else
  24022. // {
  24023. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  24024. // }
  24025. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  24026. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  24027. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  24028. // List<dynamic> childList = new List<dynamic>();
  24029. // int parentId = dto.CountriesId;
  24030. // if (provinceData.Count > 1)
  24031. // {
  24032. // foreach (var item1 in provinceData)
  24033. // {
  24034. // List<dynamic> childList1 = new List<dynamic>();
  24035. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  24036. // foreach (var item2 in citiesData1)
  24037. // {
  24038. // List<dynamic> childList2 = new List<dynamic>();
  24039. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  24040. // foreach (var item3 in countiesData1)
  24041. // {
  24042. // childList2.Add(new
  24043. // {
  24044. // id = item3.Id,
  24045. // parentId = item2.Id,
  24046. // level = "district",
  24047. // name = item3.Name_CN,
  24048. // });
  24049. // }
  24050. // childList1.Add(new
  24051. // {
  24052. // id = item2.Id,
  24053. // parentId = item1.Id,
  24054. // level = "city",
  24055. // name = item2.Name_CN,
  24056. // childList = childList2
  24057. // });
  24058. // }
  24059. // childList.Add(new
  24060. // {
  24061. // id = item1.Id,
  24062. // parentId = parentId,
  24063. // level = "province",
  24064. // name = item1.Name_CN,
  24065. // childList = childList1
  24066. // });
  24067. // }
  24068. // //城市
  24069. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  24070. // foreach (var item2 in citiesData2)
  24071. // {
  24072. // List<dynamic> childList22 = new List<dynamic>();
  24073. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  24074. // foreach (var item3 in countiesData1)
  24075. // {
  24076. // childList22.Add(new
  24077. // {
  24078. // id = item3.Id,
  24079. // parentId = item2.Id,
  24080. // level = "district",
  24081. // name = item3.Name_CN,
  24082. // });
  24083. // }
  24084. // childList.Add(new
  24085. // {
  24086. // id = item2.Id,
  24087. // parentId = parentId,
  24088. // level = "city",
  24089. // name = item2.Name_CN,
  24090. // childList = childList22
  24091. // });
  24092. // }
  24093. // }
  24094. // else
  24095. // {
  24096. // foreach (var item2 in citiesData)
  24097. // {
  24098. // string cname = item2.Name_CN;
  24099. // List<dynamic> childList1 = new List<dynamic>();
  24100. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  24101. // foreach (var item3 in countiesData1)
  24102. // {
  24103. // childList1.Add(new
  24104. // {
  24105. // Id = item3.Id,
  24106. // parentId = item2.Id,
  24107. // level = "district",
  24108. // name = item3.Name_CN
  24109. // });
  24110. // }
  24111. // childList.Add(new
  24112. // {
  24113. // id = item2.Id,
  24114. // parentId = parentId,
  24115. // level = "city",
  24116. // name = item2.Name_CN,
  24117. // childList = childList1
  24118. // });
  24119. // }
  24120. // }
  24121. // stopwatch.Stop();
  24122. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  24123. //}
  24124. /// <summary>
  24125. /// 匹配op行程单
  24126. /// 接团信息列表 Page
  24127. /// </summary>
  24128. /// <param name="dto">团组列表请求dto</param>
  24129. /// <returns></returns>
  24130. [HttpPost]
  24131. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24132. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  24133. {
  24134. var swatch = new Stopwatch();
  24135. swatch.Start();
  24136. #region 参数验证
  24137. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  24138. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  24139. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  24140. #region 页面操作权限验证
  24141. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  24142. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  24143. #endregion
  24144. #endregion
  24145. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  24146. {
  24147. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  24148. //string sqlWhere = "";
  24149. if (!string.IsNullOrEmpty(dto.Country))
  24150. {
  24151. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  24152. }
  24153. if (!string.IsNullOrEmpty(dto.Area))
  24154. {
  24155. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  24156. }
  24157. if (!string.IsNullOrEmpty(dto.TeamName))
  24158. {
  24159. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  24160. }
  24161. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  24162. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  24163. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  24164. swatch.Stop();
  24165. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  24166. }
  24167. else
  24168. {
  24169. return Ok(JsonView(false, "查询失败"));
  24170. }
  24171. }
  24172. /// <summary>
  24173. /// 匹配op行程单
  24174. /// 行程单下载
  24175. /// </summary>
  24176. /// <param name="dto">团组列表请求dto</param>
  24177. /// <returns></returns>
  24178. [HttpPost]
  24179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24180. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  24181. {
  24182. #region 参数验证
  24183. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  24184. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  24185. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  24186. #region 页面操作权限验证
  24187. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  24188. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  24189. #endregion
  24190. #endregion
  24191. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  24192. {
  24193. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  24194. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  24195. }
  24196. else
  24197. {
  24198. return Ok(JsonView(false, "下载失败!"));
  24199. }
  24200. }
  24201. #endregion
  24202. #region 国家信息 数据 注释
  24203. //[HttpPost]
  24204. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  24205. //{
  24206. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  24207. // foreach (var item in dto)
  24208. // {
  24209. // infos.Add(new Grp_GroupsTaskAssignment()
  24210. // {
  24211. // DIId = item,
  24212. // CTId = 82,
  24213. // UId = 248,
  24214. // IsEnable = 1,
  24215. // CreateUserId = 233,
  24216. // CreateTime = DateTime.Now,
  24217. // IsDel = 0
  24218. // });
  24219. // infos.Add(new Grp_GroupsTaskAssignment()
  24220. // {
  24221. // DIId = item,
  24222. // CTId = 82,
  24223. // UId = 286,
  24224. // IsEnable = 1,
  24225. // CreateUserId = 233,
  24226. // CreateTime = DateTime.Now,
  24227. // IsDel = 0
  24228. // });
  24229. // }
  24230. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  24231. // return Ok("操作成功");
  24232. //}
  24233. //public class paramJsonDto
  24234. //{
  24235. // public List<CountriesInfo> str { get; set; }
  24236. //}
  24237. //[HttpPost]
  24238. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  24239. //{
  24240. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  24241. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  24242. // List<Sys_Cities> cities = new List<Sys_Cities>();
  24243. // List<Sys_Cities> districts = new List<Sys_Cities>();
  24244. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  24245. // _sqlSugar.BeginTran();
  24246. // int countitiesIndex = 0;
  24247. // foreach (var item in dto.str)
  24248. // {
  24249. // dynamic data = item.c;
  24250. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  24251. // if (data != null)
  24252. // {
  24253. // countitiesIndex++;
  24254. // foreach (var item1 in data)
  24255. // {
  24256. // string cnname = item1.cn;
  24257. // string enname = item1.en;
  24258. // Sys_Cities provinceInfo = new Sys_Cities()
  24259. // {
  24260. // CountriesId = countriesId,
  24261. // Name_CN = cnname,
  24262. // Name_EN = enname,
  24263. // ParentId = 0,
  24264. // IsCapital = 1,
  24265. // CreateUserId = 208,
  24266. // CreateTime = DateTime.Now,
  24267. // IsDel = 0
  24268. // };
  24269. // if (item1.lv == "province") //省份
  24270. // {
  24271. // provinceInfo.Level = 1;
  24272. // int provinceId = 0;
  24273. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  24274. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  24275. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  24276. // var data1 = item1.c;
  24277. // foreach (var item2 in data1)
  24278. // {
  24279. // if (item2.lv == "city")
  24280. // {
  24281. // string citycnname = item2.cn;
  24282. // string cityenname = item2.en;
  24283. // Sys_Cities cityInfo = new Sys_Cities()
  24284. // {
  24285. // CountriesId = countriesId,
  24286. // ParentId = provinceId,
  24287. // Level = 2,
  24288. // Name_CN = citycnname,
  24289. // Name_EN = cityenname,
  24290. // IsCapital = 1,
  24291. // CreateUserId = 208,
  24292. // CreateTime = DateTime.Now,
  24293. // IsDel = 0
  24294. // };
  24295. // if (item2.c != null)
  24296. // {
  24297. // int cityId = 0;
  24298. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  24299. // if (citiesInfo != null) cityId = citiesInfo.Id;
  24300. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  24301. // foreach (var item3 in item2.c)
  24302. // {
  24303. // if (item3.lv == "district")
  24304. // {
  24305. // var districtInfo = new Sys_Cities()
  24306. // {
  24307. // CountriesId = countriesId,
  24308. // Name_CN = item3.cn,
  24309. // Name_EN = item3.en,
  24310. // Level = 3,
  24311. // ParentId = cityId,
  24312. // IsCapital = 1,
  24313. // CreateUserId = 208,
  24314. // CreateTime = DateTime.Now,
  24315. // IsDel = 0
  24316. // };
  24317. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  24318. // //{
  24319. // districts.Add(districtInfo);
  24320. // //}
  24321. // }
  24322. // }
  24323. // }
  24324. // else
  24325. // {
  24326. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  24327. // //{
  24328. // cities.Add(cityInfo);
  24329. // //}
  24330. // }
  24331. // }
  24332. // }
  24333. // }
  24334. // else if (item1.lv == "city")//城市
  24335. // {
  24336. // provinceInfo.Level = 2;
  24337. // if (item1.c != null)
  24338. // {
  24339. // int cityId = 0;
  24340. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  24341. // if (citiesInfo != null) cityId = citiesInfo.Id;
  24342. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  24343. // foreach (var item3 in item1.c)
  24344. // {
  24345. // if (item3.lv == "district")
  24346. // {
  24347. // var districtInfo = new Sys_Cities()
  24348. // {
  24349. // CountriesId = countriesId,
  24350. // Name_CN = item3.cn,
  24351. // Name_EN = item3.en,
  24352. // Level = 3,
  24353. // ParentId = cityId,
  24354. // IsCapital = 1,
  24355. // CreateUserId = 208,
  24356. // CreateTime = DateTime.Now,
  24357. // IsDel = 0
  24358. // };
  24359. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  24360. // //{
  24361. // districts.Add(districtInfo);
  24362. // //}
  24363. // }
  24364. // }
  24365. // }
  24366. // else
  24367. // {
  24368. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  24369. // //{
  24370. // cities.Add(provinceInfo);
  24371. // //}
  24372. // }
  24373. // }
  24374. // }
  24375. // }
  24376. // }
  24377. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  24378. // cities = cities.Distinct().ToList();
  24379. // districts = districts.Distinct().ToList();
  24380. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  24381. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  24382. // cities.AddRange(districts);
  24383. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  24384. // //_sqlSugar.RollbackTran();
  24385. // _sqlSugar.CommitTran();
  24386. // return Ok(JsonView(false, "操作成功!"));
  24387. //}
  24388. //[HttpPost]
  24389. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  24390. //{
  24391. // List<CountitiesInfo> infos = dto.MyProperty;
  24392. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  24393. // _sqlSugar.BeginTran();
  24394. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  24395. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  24396. // foreach (var item in infos)
  24397. // {
  24398. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  24399. // if (countryInfo != null)
  24400. // {
  24401. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  24402. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  24403. // if (cityInfo1 != null)
  24404. // {
  24405. // cityInfo1.IsCapital = 0;
  24406. // cityInfos.Add(cityInfo1);
  24407. // }
  24408. // }
  24409. // }
  24410. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  24411. // .UpdateColumns(it => it.IsCapital)
  24412. // .WhereColumns(it => it.Id)
  24413. // .ExecuteCommand();
  24414. // //_sqlSugar.RollbackTran();
  24415. // _sqlSugar.CommitTran();
  24416. // return Ok(JsonView(false, "操作成功!"));
  24417. //}
  24418. //public class CounrtiesDto
  24419. //{
  24420. // public List<CountitiesInfo> MyProperty { get; set; }
  24421. //}
  24422. //public class CountitiesInfo
  24423. //{
  24424. // /// <summary>
  24425. // /// 圣约翰
  24426. // /// </summary>
  24427. // public string capital_name_chinese { get; set; }
  24428. // /// <summary>
  24429. // ///
  24430. // /// </summary>
  24431. // public string capital_name { get; set; }
  24432. // /// <summary>
  24433. // ///
  24434. // /// </summary>
  24435. // public string country_type { get; set; }
  24436. // /// <summary>
  24437. // /// 安提瓜和巴布达
  24438. // /// </summary>
  24439. // public string country_name_chinese { get; set; }
  24440. // /// <summary>
  24441. // /// 安提瓜和巴布达
  24442. // /// </summary>
  24443. // public string country_name_chinese_short { get; set; }
  24444. // /// <summary>
  24445. // /// 安提瓜和巴布达
  24446. // /// </summary>
  24447. // public string country_name_chinese_UN { get; set; }
  24448. // /// <summary>
  24449. // ///
  24450. // /// </summary>
  24451. // public string country_name_english_abbreviation { get; set; }
  24452. // /// <summary>
  24453. // ///
  24454. // /// </summary>
  24455. // public string country_name_english_formal { get; set; }
  24456. // /// <summary>
  24457. // ///
  24458. // /// </summary>
  24459. // public string country_name_english_UN { get; set; }
  24460. // /// <summary>
  24461. // ///
  24462. // /// </summary>
  24463. // public string continent_name { get; set; }
  24464. // /// <summary>
  24465. // ///
  24466. // /// </summary>
  24467. // public string subregion_name { get; set; }
  24468. // /// <summary>
  24469. // ///
  24470. // /// </summary>
  24471. // public string country_code2 { get; set; }
  24472. // /// <summary>
  24473. // ///
  24474. // /// </summary>
  24475. // public string country_code3 { get; set; }
  24476. // /// <summary>
  24477. // ///
  24478. // /// </summary>
  24479. // public string phone_code { get; set; }
  24480. //}
  24481. //public class CountriesInfo : BasicInfo
  24482. //{
  24483. // public List<CitiesInfo> c { get; set; }
  24484. //}
  24485. //public class CitiesInfo : BasicInfo
  24486. //{
  24487. // public List<AreaInfo> c { get; set; }
  24488. //}
  24489. //public class AreaInfo : BasicInfo
  24490. //{
  24491. // public List<AreaInfo> c { get; set; }
  24492. //}
  24493. //public class BasicInfo
  24494. //{
  24495. // public string code { get; set; }
  24496. // public string cn { get; set; }
  24497. // public string lv { get; set; }
  24498. // public string en { get; set; }
  24499. //}
  24500. #endregion
  24501. #region 查看邀请方
  24502. /// <summary>
  24503. /// 查看邀请方
  24504. /// 邀请方信息 Init
  24505. /// </summary>
  24506. /// <param name="dto"></param>
  24507. /// <returns></returns>
  24508. [HttpPost]
  24509. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24510. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  24511. {
  24512. string sqlWhere = string.Empty;
  24513. if (!string.IsNullOrEmpty(dto.Search))
  24514. {
  24515. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  24516. }
  24517. string sql = string.Format($@"Select
  24518. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  24519. Id,
  24520. UnitName
  24521. From Res_InvitationOfficialActivityData
  24522. Where IsDel = 0
  24523. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  24524. RefAsync<int> total = 0;
  24525. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24526. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  24527. }
  24528. /// <summary>
  24529. /// 查看邀请方
  24530. /// 国家信息 Init
  24531. /// </summary>
  24532. /// <param name="dto"></param>
  24533. /// <returns></returns>
  24534. [HttpPost]
  24535. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24536. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  24537. {
  24538. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  24539. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  24540. var diids = groupInfos.Select(it => it.Id).ToList();
  24541. List<string> countrys = new List<string>();
  24542. foreach (var item in country)
  24543. {
  24544. var data = _groupRepository.FormartTeamName(item);
  24545. var dataArray = _groupRepository.GroupSplitCountry(data);
  24546. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  24547. }
  24548. countrys = countrys.Distinct().ToList();
  24549. for (int i = 0; i < countrys.Count; i++)
  24550. {
  24551. string item = countrys[i];
  24552. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  24553. {
  24554. countrys.Remove(item);
  24555. i--;
  24556. }
  24557. }
  24558. RefAsync<int> total = 0;
  24559. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  24560. .Where(it => countrys.Contains(it.Name_CN))
  24561. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  24562. .Select(it => new { id = it.Id, name = it.Name_CN })
  24563. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24564. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  24565. }
  24566. /// <summary>
  24567. /// 查看邀请方
  24568. /// 城市信息 Init
  24569. /// </summary>
  24570. /// <param name="dto"></param>
  24571. /// <returns></returns>
  24572. [HttpPost]
  24573. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24574. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  24575. {
  24576. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  24577. RefAsync<int> total = 0;
  24578. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  24579. .Where(it => it.CountriesId == dto.CountiesId)
  24580. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  24581. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  24582. .Select(it => new { id = it.Id, name = it.Name_CN })
  24583. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24584. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  24585. }
  24586. /// <summary>
  24587. /// 查看邀请方
  24588. /// 团组名称 Init
  24589. /// </summary>
  24590. /// <param name="dto"></param>
  24591. /// <returns></returns>
  24592. [HttpPost]
  24593. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24594. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  24595. {
  24596. var watch = new Stopwatch();
  24597. watch.Start();
  24598. RefAsync<int> total = 0;
  24599. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  24600. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  24601. .Where((oa, di) => oa.IsDel == 0)
  24602. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  24603. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  24604. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  24605. .Distinct()
  24606. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24607. watch.Stop();
  24608. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  24609. }
  24610. /// <summary>
  24611. /// 查看邀请方
  24612. /// 团组 & 邀请方信息
  24613. /// </summary>
  24614. /// <param name="dto"></param>
  24615. /// <returns></returns>
  24616. [HttpPost]
  24617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24618. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  24619. {
  24620. var watch = new Stopwatch();
  24621. watch.Start();
  24622. RefAsync<int> total = 0;
  24623. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  24624. .AS("Grp_DelegationInfo")
  24625. .Includes(x => x.InvitingInfos)
  24626. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  24627. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  24628. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  24629. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  24630. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  24631. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  24632. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24633. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  24634. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  24635. infos.ForEach(x =>
  24636. {
  24637. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  24638. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  24639. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  24640. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  24641. });
  24642. watch.Stop();
  24643. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  24644. }
  24645. #endregion
  24646. #region 报批行程
  24647. /// <summary>
  24648. /// 报批行程初始化
  24649. /// </summary>
  24650. /// <param name="dto"></param>
  24651. /// <returns></returns>
  24652. [HttpPost]
  24653. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  24654. {
  24655. const int chiNumber = 5;
  24656. var jw = JsonView(false);
  24657. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  24658. var group = groupList.First();
  24659. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  24660. group = groupList.First(x => x.Id == diid);
  24661. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  24662. .Where(x => x.DiId == diid && x.IsDel == 0)
  24663. .ToArray();
  24664. var count = 1;
  24665. foreach (var item in blackCodeList)
  24666. {
  24667. if (string.IsNullOrWhiteSpace(item.Title))
  24668. {
  24669. item.Title = "未设置名称数据" + count;
  24670. }
  24671. count++;
  24672. }
  24673. ;
  24674. if (group == null)
  24675. {
  24676. jw.Msg = "暂无团组!";
  24677. return Ok(jw);
  24678. }
  24679. var data = new
  24680. {
  24681. groupList = groupList.Select(x => new
  24682. {
  24683. x.TeamName,
  24684. x.Id
  24685. }),
  24686. content = new ArrayList(),
  24687. groupInfo = new
  24688. {
  24689. group.VisitDays,
  24690. group.TourCode,
  24691. group.VisitPNumber,
  24692. group.TeamName,
  24693. group.Id,
  24694. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  24695. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  24696. group.ClientUnit
  24697. },
  24698. blackCodeList = blackCodeList.Select(x => new
  24699. {
  24700. x.Title,
  24701. x.Id
  24702. }),
  24703. FileTempList = new ArrayList()
  24704. {
  24705. new { Index = 1,FileName = "旧模板" },
  24706. new { Index = 2,FileName = "省外办" },
  24707. new { Index = 3,FileName = "市外办" },
  24708. }
  24709. };
  24710. var resultArr = new ArrayList();
  24711. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  24712. #region 默认不生成行程
  24713. //if (content.Count == 0)
  24714. //{
  24715. // var stay = "-";
  24716. // var cityPath = "-";
  24717. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  24718. // .Where(x => x.DiId == diid && x.IsDel == 0)
  24719. // .ToList();
  24720. // //添加城市路径以及住宿地
  24721. // //黑屏代码数据
  24722. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  24723. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  24724. // {
  24725. // jw = JsonView(true, "黑屏代码有误!", data);
  24726. // return Ok(jw);
  24727. // }
  24728. // data = data with
  24729. // {
  24730. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  24731. // {
  24732. // x.Title,
  24733. // x.Id,
  24734. // }).ToArray())
  24735. // };
  24736. // foreach (DataRow row in dtBlack.Rows)
  24737. // {
  24738. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  24739. // {
  24740. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  24741. // return Ok(jw);
  24742. // }
  24743. // }
  24744. // //黑屏代码获取时间区间
  24745. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  24746. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  24747. // _sqlSugar.BeginTran();
  24748. // for (int i = 0; i < timeArr.Count; i++)
  24749. // {
  24750. // stay = "-";
  24751. // cityPath = "-";
  24752. // DateTime NewData = DateTime.Parse(timeArr[i]);
  24753. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  24754. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  24755. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  24756. // if (tbSelect.Length > 0)
  24757. // {
  24758. // List<string> threeCodeStr = new List<string>();
  24759. // foreach (var item in tbSelect)
  24760. // {
  24761. // var threeCode = item["Three"].ToString() ?? "";
  24762. // if (threeCode.Length == 6)
  24763. // {
  24764. // var start = threeCode.Substring(0, 3);
  24765. // var end = threeCode.Substring(3, 3);
  24766. // if (threeCodeStr.Count == 0)
  24767. // {
  24768. // threeCodeStr.Add(start);
  24769. // threeCodeStr.Add(end);
  24770. // }
  24771. // else
  24772. // {
  24773. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  24774. // {
  24775. // threeCodeStr.Add(end);
  24776. // }
  24777. // else
  24778. // {
  24779. // threeCodeStr.Add(start);
  24780. // threeCodeStr.Add(end);
  24781. // }
  24782. // }
  24783. // }
  24784. // }
  24785. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  24786. // var last = threeCodeStr.Last();
  24787. // foreach (var item in threeCodeStr)
  24788. // {
  24789. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  24790. // if (item.Equals(last))
  24791. // {
  24792. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  24793. // }
  24794. // }
  24795. // cityPath = cityPath.Trim('-');
  24796. // }
  24797. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  24798. // appro.Diid = diid ?? -1;
  24799. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  24800. // appro.Id = thisId;
  24801. // appro.CreateUserId = dto.UserId;
  24802. // appro.CreateTime = DateTime.Now;
  24803. // content.Add(appro);
  24804. // }
  24805. // _sqlSugar.CommitTran();
  24806. //}
  24807. #endregion
  24808. foreach (var x in content)
  24809. {
  24810. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  24811. if (chiList.Count < chiNumber)
  24812. {
  24813. for (int i = chiList.Count; i < chiNumber; i++)
  24814. {
  24815. chiList.Add(new Grp_ApprovalTravelDetails());
  24816. }
  24817. }
  24818. resultArr.Add(new
  24819. {
  24820. x.Id,
  24821. x.Date,
  24822. x.Diid,
  24823. chiList = chiList.Select(x1 => new
  24824. {
  24825. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  24826. x1.Details,
  24827. x1.ParentId,
  24828. x1.Id
  24829. })
  24830. });
  24831. }
  24832. data = data with
  24833. {
  24834. content = resultArr,
  24835. };
  24836. jw = JsonView(true, "获取成功!", data);
  24837. return Ok(jw);
  24838. }
  24839. /// <summary>
  24840. /// 报批行程删除
  24841. /// </summary>
  24842. /// <param name="dto"></param>
  24843. /// <returns></returns>
  24844. [HttpPost]
  24845. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  24846. {
  24847. var jw = JsonView(false);
  24848. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  24849. if (group == null)
  24850. {
  24851. jw.Msg = "团组参数有误!";
  24852. return Ok(jw);
  24853. }
  24854. try
  24855. {
  24856. _sqlSugar.BeginTran();
  24857. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  24858. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  24859. {
  24860. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  24861. DeleteUserId = dto.uesrId,
  24862. IsDel = 1
  24863. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  24864. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  24865. {
  24866. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  24867. DeleteUserId = dto.uesrId,
  24868. IsDel = 1
  24869. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  24870. _sqlSugar.CommitTran();
  24871. jw = JsonView(true, "删除成功");
  24872. }
  24873. catch (Exception ex)
  24874. {
  24875. jw = JsonView(false, ex.Message);
  24876. }
  24877. return Ok(jw);
  24878. }
  24879. /// <summary>
  24880. /// 报批行程保存
  24881. /// </summary>
  24882. /// <param name="dto"></param>
  24883. /// <returns></returns>
  24884. [HttpPost]
  24885. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  24886. {
  24887. var jw = JsonView(false);
  24888. var Find = dto.Arr.Find(x => x.id == 0);
  24889. if (Find != null)
  24890. {
  24891. jw.Msg = "生成的ID为0!";
  24892. return Ok(jw);
  24893. }
  24894. foreach (var item in dto.Arr)
  24895. {
  24896. foreach (var chi in item.chiList)
  24897. {
  24898. if (chi.parentId == 0)
  24899. {
  24900. chi.parentId = item.id;
  24901. }
  24902. }
  24903. }
  24904. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  24905. _sqlSugar.BeginTran();
  24906. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  24907. {
  24908. var parentIds = dto.Arr.Select(x => x.id).ToList();
  24909. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  24910. {
  24911. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  24912. DeleteUserId = dto.UserId,
  24913. IsDel = 1
  24914. }).ExecuteCommand();
  24915. }
  24916. try
  24917. {
  24918. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  24919. {
  24920. CreateTime = DateTime.Now,
  24921. CreateUserId = dto.UserId,
  24922. Details = x.details,
  24923. ParentId = x.parentId,
  24924. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  24925. Remark = "",
  24926. IsDel = 0
  24927. }).ToList()).ExecuteCommand();
  24928. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  24929. {
  24930. Id = x.id,
  24931. Details = x.details,
  24932. ParentId = x.parentId,
  24933. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  24934. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  24935. {
  24936. Details = x.Details,
  24937. ParentId = x.ParentId,
  24938. Time = x.Time
  24939. }).ExecuteCommand();
  24940. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  24941. {
  24942. Id = x.id,
  24943. Date = x.date,
  24944. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  24945. {
  24946. Date = x.Date
  24947. }).ExecuteCommand();
  24948. _sqlSugar.CommitTran();
  24949. jw = JsonView(true, "保存成功!");
  24950. }
  24951. catch (Exception ex)
  24952. {
  24953. _sqlSugar.RollbackTran();
  24954. jw = JsonView(false, "保存失败!" + ex.Message);
  24955. }
  24956. return Ok(jw);
  24957. }
  24958. /// <summary>
  24959. /// 报批行程生成
  24960. /// </summary>
  24961. /// <param name="dto"></param>
  24962. /// <returns></returns>
  24963. [HttpPost]
  24964. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  24965. {
  24966. var jw = JsonView(false);
  24967. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  24968. if (group == null)
  24969. {
  24970. jw.Msg = "暂无该团组!";
  24971. return Ok(jw);
  24972. }
  24973. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  24974. //黑屏代码数据
  24975. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  24976. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  24977. {
  24978. jw.Msg = "黑屏代码有误!";
  24979. return Ok(jw);
  24980. }
  24981. foreach (DataRow row in dtBlack.Rows)
  24982. {
  24983. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  24984. {
  24985. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  24986. return Ok(jw);
  24987. }
  24988. }
  24989. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  24990. var resultArr = new ArrayList();
  24991. //if (officialActivitiesArr.Count == 0)
  24992. //{
  24993. // jw.Msg = "暂无公务出访信息!";
  24994. // return Ok(jw);
  24995. //}
  24996. try
  24997. {
  24998. _sqlSugar.BeginTran();
  24999. DeleteApprovalJourney(new
  25000. Domain.Dtos.Groups.DeleteApprovalJourney
  25001. {
  25002. Diid = dto.Diid,
  25003. uesrId = dto.Userid
  25004. });
  25005. var stay = "-";
  25006. var cityPath = "-";
  25007. var arriveCountry = string.Empty;
  25008. //添加城市路径以及住宿地
  25009. //黑屏代码获取时间区间
  25010. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  25011. var empty = "【未收入该三字码!请机票同事录入】";
  25012. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  25013. #region 配置公务活动时间
  25014. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  25015. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  25016. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  25017. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  25018. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  25019. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  25020. {
  25021. 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" }),
  25022. 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"}),
  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,13,30,0), new List<string>{"16:30-17:30"}),
  25025. };
  25026. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  25027. {
  25028. 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" }),
  25029. 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"}),
  25030. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  25031. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  25032. };
  25033. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  25034. {
  25035. 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" }),
  25036. 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"}),
  25037. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  25038. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  25039. };
  25040. #endregion
  25041. var nextDayNum = 0;
  25042. for (int i = 0; i < timeArr.Count; i++)
  25043. {
  25044. stay = "-";
  25045. cityPath = "-";
  25046. var chiarr = new List<Grp_ApprovalTravelDetails>();
  25047. DateTime NewData = DateTime.Parse(timeArr[i]);
  25048. //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();
  25049. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  25050. if (nextDayNum > 0)
  25051. {
  25052. nextDayNum--;
  25053. }
  25054. if (tbSelect.Length > 0)
  25055. {
  25056. List<string> threeCodeStr = new List<string>();
  25057. bool isTrade = false;
  25058. string trip = string.Empty;
  25059. foreach (var item in tbSelect)
  25060. {
  25061. if (nextDayNum == 0)
  25062. {
  25063. nextDayNum = Convert.ToInt32(item["Sign"]);
  25064. }
  25065. var airStartTime = item["StartTime"].ToString() ?? "0000";
  25066. var airEndTime = item["EndTime"].ToString() ?? "0000";
  25067. var takeOffTime = DateTime.Parse(timeArr[i]);
  25068. var fallToTime = DateTime.Parse(timeArr[i]);
  25069. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  25070. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  25071. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  25072. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  25073. if (nextDayNum > 0)
  25074. {
  25075. fallToTime = fallToTime.AddDays(nextDayNum);
  25076. }
  25077. trip = string.Empty;
  25078. var start = string.Empty;
  25079. var end = string.Empty;
  25080. var threeCode = item["Three"].ToString() ?? "";
  25081. if (threeCode.Length == 6)
  25082. {
  25083. start = threeCode.Substring(0, 3);
  25084. end = threeCode.Substring(3, 3);
  25085. if (threeCodeStr.Count == 0)
  25086. {
  25087. threeCodeStr.Add(start);
  25088. threeCodeStr.Add(end);
  25089. }
  25090. else
  25091. {
  25092. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  25093. {
  25094. threeCodeStr.Add(end);
  25095. }
  25096. else
  25097. {
  25098. threeCodeStr.Add(start);
  25099. threeCodeStr.Add(end);
  25100. }
  25101. }
  25102. }
  25103. //处理机票信息
  25104. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  25105. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  25106. if (start_Object == null)
  25107. {
  25108. start_Object = new Res_ThreeCode()
  25109. {
  25110. AirPort = empty,
  25111. AirPort_En = empty,
  25112. City = empty,
  25113. Country = empty,
  25114. Four = empty,
  25115. Three = empty,
  25116. };
  25117. }
  25118. if (end_Object == null)
  25119. {
  25120. end_Object = new Res_ThreeCode()
  25121. {
  25122. AirPort = empty,
  25123. AirPort_En = empty,
  25124. City = empty,
  25125. Country = empty,
  25126. Four = empty,
  25127. Three = empty,
  25128. };
  25129. }
  25130. //机型判断
  25131. string airModel = item["AirModel"].ToString();
  25132. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  25133. string flightTime = item["FlightTime"].ToString();
  25134. flightTime = ParseBlackTime(flightTime);
  25135. //航班号
  25136. string flightcode = item["Fliagtcode"].ToString();
  25137. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  25138. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  25139. if (aircompany == null)
  25140. {
  25141. aircompany = new Res_AirCompany
  25142. {
  25143. CnName = hsEmpty,
  25144. EnName = hsEmpty,
  25145. ShortCode = hsEmpty,
  25146. };
  25147. }
  25148. //航班前公务安排
  25149. if (tbSelect.First().Equals(item) && i != 0)
  25150. {
  25151. foreach (var takeoff in takeoffTimes)
  25152. {
  25153. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  25154. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  25155. {
  25156. foreach (var addTime in takeoff.Item2)
  25157. {
  25158. chiarr.Add(new Grp_ApprovalTravelDetails
  25159. {
  25160. Time = addTime,
  25161. CreateTime = DateTime.Now,
  25162. CreateUserId = dto.Userid,
  25163. ParentId = 0,
  25164. Details = "公务活动"
  25165. });
  25166. }
  25167. break;
  25168. }
  25169. }
  25170. }
  25171. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  25172. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  25173. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  25174. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  25175. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  25176. if (isTrade)
  25177. {
  25178. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  25179. trip += "(转机不出机场)。";
  25180. }
  25181. //else
  25182. //{
  25183. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  25184. //}
  25185. chiarr.Add(new Grp_ApprovalTravelDetails
  25186. {
  25187. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  25188. CreateTime = DateTime.Now,
  25189. CreateUserId = dto.Userid,
  25190. ParentId = 0,
  25191. Details = trip
  25192. });
  25193. //最后一条到达的时间安排公务
  25194. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  25195. {
  25196. bool isCheckCountry = false;
  25197. if (end_Object.Country != arriveCountry)
  25198. {
  25199. arriveCountry = end_Object.Country;
  25200. isCheckCountry = true;
  25201. }
  25202. if (nextDayNum == 0)
  25203. {
  25204. //需要入境的情况
  25205. if (isCheckCountry)
  25206. {
  25207. foreach (var fallTime in fallTimesCheckCountry)
  25208. {
  25209. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  25210. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  25211. {
  25212. foreach (var addTime in fallTime.Item2)
  25213. {
  25214. chiarr.Add(new Grp_ApprovalTravelDetails
  25215. {
  25216. Time = addTime,
  25217. CreateTime = DateTime.Now,
  25218. CreateUserId = dto.Userid,
  25219. ParentId = 0,
  25220. Details = "公务活动"
  25221. });
  25222. }
  25223. break;
  25224. }
  25225. }
  25226. }
  25227. else
  25228. {
  25229. foreach (var fallTime in fallTimesNotCheckCountry)
  25230. {
  25231. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  25232. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  25233. {
  25234. foreach (var addTime in fallTime.Item2)
  25235. {
  25236. chiarr.Add(new Grp_ApprovalTravelDetails
  25237. {
  25238. Time = addTime,
  25239. CreateTime = DateTime.Now,
  25240. CreateUserId = dto.Userid,
  25241. ParentId = 0,
  25242. Details = "公务活动"
  25243. });
  25244. }
  25245. break;
  25246. }
  25247. }
  25248. }
  25249. }
  25250. }
  25251. }
  25252. //添加乘车语句
  25253. //chiarr.Add(new Grp_ApprovalTravelDetails
  25254. //{
  25255. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  25256. // CreateTime = DateTime.Now,
  25257. // CreateUserId = dto.Userid,
  25258. // ParentId = 0,
  25259. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  25260. //});
  25261. //if (i != timeArr.Count - 1)
  25262. //{
  25263. // fallToTime = fallToTime.AddHours(2.5);
  25264. // foreach (var item in Times)
  25265. // {
  25266. // //排列公务时间
  25267. // if (fallToTime.Hour < item.Item1)
  25268. // {
  25269. // chiarr.Add(new Grp_ApprovalTravelDetails
  25270. // {
  25271. // Time = $"{item.Item2} - {item.Item3}",
  25272. // CreateTime = DateTime.Now,
  25273. // CreateUserId = dto.Userid,
  25274. // ParentId = 0,
  25275. // Details = "公务活动"
  25276. // });
  25277. // }
  25278. // }
  25279. //}
  25280. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  25281. var last = threeCodeStr.Last();
  25282. foreach (var item in threeCodeStr)
  25283. {
  25284. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  25285. if (item.Equals(last))
  25286. {
  25287. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  25288. }
  25289. }
  25290. cityPath = cityPath.Trim('-');
  25291. }
  25292. else
  25293. {
  25294. foreach (var item in Times)
  25295. {
  25296. chiarr.Add(new Grp_ApprovalTravelDetails
  25297. {
  25298. Time = $"{item.Item2} - {item.Item3}",
  25299. CreateTime = DateTime.Now,
  25300. CreateUserId = dto.Userid,
  25301. ParentId = 0,
  25302. Details = "公务活动"
  25303. });
  25304. }
  25305. }
  25306. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  25307. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  25308. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  25309. appro.Diid = dto.Diid;
  25310. appro.CreateUserId = dto.Userid;
  25311. appro.CreateTime = DateTime.Now;
  25312. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  25313. appro.Id = thisId;
  25314. //foreach (var item in gwinfo)
  25315. //{
  25316. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  25317. // chi.Details = "拜访" + item.Client;
  25318. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  25319. // {
  25320. // chi.Details += "," + item.ReqSample;
  25321. // }
  25322. // chi.ParentId = thisId;
  25323. // chi.Time = item.Time;
  25324. // chiarr.Add(chi);
  25325. //}
  25326. if (chiarr.Count < 6)
  25327. {
  25328. for (int j = chiarr.Count; j < 6; j++)
  25329. {
  25330. chiarr.Add(new
  25331. Grp_ApprovalTravelDetails());
  25332. }
  25333. }
  25334. resultArr.Add(new
  25335. {
  25336. appro.Id,
  25337. appro.Date,
  25338. appro.Diid,
  25339. chiList = chiarr.Select(x1 => new
  25340. {
  25341. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  25342. x1.Details,
  25343. x1.ParentId,
  25344. x1.Id
  25345. })
  25346. });
  25347. }
  25348. _sqlSugar.CommitTran();
  25349. jw = JsonView(true, "生成成功!", resultArr);
  25350. }
  25351. catch (Exception ex)
  25352. {
  25353. jw.Code = 400;
  25354. jw.Msg = "生成失败!" + ex.Message;
  25355. }
  25356. return Ok(jw);
  25357. }
  25358. /// <summary>
  25359. /// 报批行程word导出
  25360. /// </summary>
  25361. /// <param name="dto"></param>
  25362. /// <returns></returns>
  25363. [HttpPost]
  25364. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  25365. {
  25366. var jw = JsonView(false);
  25367. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  25368. if (group == null)
  25369. {
  25370. jw.Msg = "暂无该团组!";
  25371. return Ok(jw);
  25372. }
  25373. //模板路径
  25374. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  25375. var fileName = string.Empty;
  25376. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  25377. bool bold = false;
  25378. if (dto.FileIndex == 1)
  25379. {
  25380. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  25381. }
  25382. else if (dto.FileIndex == 2)
  25383. {
  25384. fileName = "省外办-报批.docx";
  25385. bold = false;
  25386. titleFont = "方正黑体简体";
  25387. timeFont = "Times New Roman";
  25388. contentFont = "方正仿宋_GBK";
  25389. }
  25390. else if (dto.FileIndex == 3)
  25391. {
  25392. fileName = "市外办-报批.docx";
  25393. titleFont = "方正黑体简体";
  25394. timeFont = "Times New Roman";
  25395. contentFont = "方正仿宋简体";
  25396. }
  25397. tempPath = tempPath + fileName;
  25398. //载入模板
  25399. Document doc = new Document(tempPath);
  25400. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  25401. //获取所填表格的序数
  25402. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  25403. Aspose.Words.Tables.Row titleRowClone = null;
  25404. Aspose.Words.Tables.Row CenterRowClone = null;
  25405. int index = 0;
  25406. int indexChi = 0;
  25407. int SetIndex = 0;
  25408. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  25409. //获取数据,放到datatable
  25410. foreach (var item in ApprovalTravelArr)
  25411. {
  25412. if (index > 0)
  25413. {
  25414. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  25415. tableOne.AppendChild(titleRowClone);
  25416. }
  25417. var textTime = item.Date;
  25418. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  25419. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  25420. SetIndex++;
  25421. if (ChiRep.Count > 0)
  25422. {
  25423. foreach (var itemChi in ChiRep)
  25424. {
  25425. var txtTime = itemChi.Time;
  25426. var txtDetail = itemChi.Details;
  25427. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  25428. {
  25429. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  25430. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  25431. //indexChi++;
  25432. //SetIndex++;
  25433. break;
  25434. }
  25435. if (indexChi > 0)
  25436. {
  25437. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  25438. tableOne.AppendChild(CenterRowClone);
  25439. }
  25440. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  25441. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  25442. indexChi++;
  25443. SetIndex++;
  25444. }
  25445. }
  25446. //else
  25447. //{
  25448. // if (indexChi > 0)
  25449. // {
  25450. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  25451. // tableOne.AppendChild(CenterRowClone);
  25452. // }
  25453. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  25454. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  25455. // indexChi++;
  25456. // SetIndex++;
  25457. //}
  25458. index++;
  25459. }
  25460. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  25461. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  25462. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  25463. jw.Code = 200;
  25464. jw.Msg = "";
  25465. return Ok(jw);
  25466. }
  25467. private string ParseBlackTime(string time)
  25468. {
  25469. // 匹配可能只有分钟的情况
  25470. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  25471. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  25472. if (match.Success)
  25473. {
  25474. string hours = match.Groups[1].Value;
  25475. string minutes = match.Groups[2].Value;
  25476. // 如果小时部分为空,则只显示分钟
  25477. if (string.IsNullOrEmpty(hours))
  25478. {
  25479. return $"{minutes}分钟";
  25480. }
  25481. // 如果分钟部分为空,则只显示小时
  25482. else if (string.IsNullOrEmpty(minutes))
  25483. {
  25484. return $"{hours}小时";
  25485. }
  25486. // 否则显示完整格式
  25487. else
  25488. {
  25489. return $"{hours}小时{minutes}分钟";
  25490. }
  25491. }
  25492. else
  25493. {
  25494. return "未知时长";
  25495. }
  25496. }
  25497. private string intToString(int numberVal)
  25498. {
  25499. string numberval = numberVal.ToString();
  25500. Dictionary<char, string> Number = new Dictionary<char, string>();
  25501. Number.Add('1', "一");
  25502. Number.Add('2', "二");
  25503. Number.Add('3', "三");
  25504. Number.Add('4', "四");
  25505. Number.Add('5', "五");
  25506. Number.Add('6', "六");
  25507. Number.Add('7', "七");
  25508. Number.Add('8', "八");
  25509. Number.Add('9', "九");
  25510. string stringNumberVal = string.Empty;
  25511. for (int i = 0; i < numberval.Length; i++)
  25512. {
  25513. if (i == 0)
  25514. {
  25515. stringNumberVal += Number[numberval[i]];
  25516. }
  25517. else if (i >= 1)
  25518. {
  25519. if (numberval[i] == '0')
  25520. {
  25521. stringNumberVal = "十";
  25522. }
  25523. else
  25524. {
  25525. stringNumberVal += "十" + Number[numberval[i]];
  25526. }
  25527. }
  25528. }
  25529. return stringNumberVal;
  25530. }
  25531. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  25532. {
  25533. //获取table中的某个单元格,从0开始
  25534. Cell lshCell = table.Rows[rows].Cells[cells];
  25535. //将单元格中段落移除
  25536. foreach (Paragraph item in lshCell.Paragraphs)
  25537. {
  25538. lshCell.Paragraphs.Remove(item);
  25539. }
  25540. if (val.Contains("\r\n"))
  25541. {
  25542. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  25543. foreach (var item in spArr)
  25544. {
  25545. //新建一个段落
  25546. Paragraph p = new Paragraph(doc);
  25547. var r = new Run(doc, item);
  25548. //设置字体
  25549. if (!string.IsNullOrEmpty(font))
  25550. {
  25551. r.Font.Name = font;
  25552. }
  25553. r.Font.Bold = bold;
  25554. //把设置的值赋给之前新建的段落
  25555. p.AppendChild(r);
  25556. //将此段落加到单元格内
  25557. lshCell.AppendChild(p);
  25558. }
  25559. }
  25560. else
  25561. {
  25562. //新建一个段落
  25563. Paragraph p = new Paragraph(doc);
  25564. var r = new Run(doc, val);
  25565. //设置字体
  25566. if (!string.IsNullOrEmpty(font))
  25567. {
  25568. r.Font.Name = font;
  25569. }
  25570. r.Font.Bold = bold;
  25571. //把设置的值赋给之前新建的段落
  25572. p.AppendChild(r);
  25573. //将此段落加到单元格内
  25574. lshCell.AppendChild(p);
  25575. }
  25576. }
  25577. /// <summary>
  25578. /// 报批行程AI续写
  25579. /// </summary>
  25580. /// <returns></returns>
  25581. [HttpPost]
  25582. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  25583. {
  25584. var jw = JsonView(false);
  25585. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  25586. {
  25587. jw.Msg = "参数有误!";
  25588. return Ok(jw);
  25589. }
  25590. KiMiApiClient kiMi = new KiMiApiClient();
  25591. List<SeedMessages> messages = new List<SeedMessages>() {
  25592. new SeedMessages
  25593. {
  25594. Role = KimiRole.system,
  25595. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  25596. },
  25597. new SeedMessages
  25598. {
  25599. Role = KimiRole.user,
  25600. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  25601. }
  25602. };
  25603. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  25604. string data = kimi_result.Choices[0]?.Message.Content;
  25605. if (string.IsNullOrWhiteSpace(data))
  25606. {
  25607. jw.Data = "Ai续写失败!";
  25608. }
  25609. else
  25610. {
  25611. jw = JsonView(true, "success!", data);
  25612. }
  25613. return Ok(jw);
  25614. }
  25615. #endregion
  25616. #region 团组接待意见调查
  25617. /// <summary>
  25618. /// 团组接待意见调查 - 信息管理
  25619. /// 基础数据(团组)
  25620. /// </summary>
  25621. /// <returns></returns>
  25622. [HttpGet]
  25623. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25624. public async Task<IActionResult> OpinionaireInit()
  25625. {
  25626. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  25627. .Select(x => new
  25628. {
  25629. x.Id,
  25630. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  25631. })
  25632. .OrderByDescending(x => x.Id)
  25633. .ToListAsync();
  25634. return Ok(JsonView(groupData, groupData.Count));
  25635. }
  25636. /// <summary>
  25637. /// 团组接待意见调查 - 信息管理
  25638. /// 列表
  25639. /// </summary>
  25640. /// <param name="groupId"></param>
  25641. /// <returns></returns>
  25642. [HttpGet("{groupId}")]
  25643. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25644. public async Task<IActionResult> OpinionaireManageList(int groupId)
  25645. {
  25646. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  25647. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  25648. .Select(x => new
  25649. {
  25650. x.Id,
  25651. x.TourGuideName,
  25652. x.CityName,
  25653. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  25654. x.CreateTime
  25655. })
  25656. .OrderBy(x => x.Id)
  25657. .ToListAsync();
  25658. return Ok(JsonView(data));
  25659. }
  25660. /// <summary>
  25661. /// 团组接待意见调查 - 信息管理
  25662. /// 保存
  25663. /// </summary>
  25664. /// <param name="dto"></param>
  25665. /// <returns></returns>
  25666. [HttpPost]
  25667. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25668. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  25669. {
  25670. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  25671. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  25672. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  25673. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  25674. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  25675. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  25676. _opinionaireRep.BeginTran();
  25677. if (addData != null && addData.Count > 0)
  25678. {
  25679. foreach (var item in addData)
  25680. {
  25681. item.CreateUserId = currUserInfo.UserId;
  25682. item.DiId = dto.DiId;
  25683. }
  25684. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  25685. }
  25686. if (updData != null && updData.Count > 0)
  25687. {
  25688. var upd = await _opinionaireRep._sqlSugar
  25689. .Updateable(updData)
  25690. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  25691. .WhereColumns(x => new { x.Id })
  25692. .ExecuteCommandAsync();
  25693. }
  25694. _opinionaireRep.CommitTran();
  25695. return Ok(JsonView("操作成功!"));
  25696. }
  25697. /// <summary>
  25698. /// 团组接待意见调查 - 信息管理
  25699. /// 删除
  25700. /// </summary>
  25701. /// <param name="id"></param>
  25702. /// <returns></returns>
  25703. [HttpDelete("{id}")]
  25704. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25705. public async Task<IActionResult> OpinionaireManageDel(int id)
  25706. {
  25707. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  25708. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  25709. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  25710. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  25711. if (!del) return Ok(JsonView("操作失败!"));
  25712. return Ok(JsonView("操作成功!"));
  25713. }
  25714. /// <summary>
  25715. /// 团组接待意见调查 - 用户
  25716. /// 列表
  25717. /// </summary>
  25718. /// <param name="diId"></param>
  25719. /// <returns></returns>
  25720. [HttpGet("{diId}")]
  25721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25722. public async Task<IActionResult> OpinionaireUserList(int diId)
  25723. {
  25724. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  25725. var sql = string.Format(@"
  25726. SELECT
  25727. o.Id,
  25728. o.DiId,
  25729. di.TeamName AS 'GroupName',
  25730. di.VisitPNumber AS 'PeopleNumber',
  25731. di.ClientName AS 'LeadGroup',
  25732. di.VisitCountry AS 'Travel',
  25733. di.VisitDays AS 'Days',
  25734. o.CityName,
  25735. o.TourGuideName,
  25736. o.Catering,
  25737. o.CateringReason,
  25738. o.Stay,
  25739. o.StayReason,
  25740. o.[Route],
  25741. o.RouteReason,
  25742. o.OfficialActivity,
  25743. o.OfficialActivityReason,
  25744. o.TourGuide,
  25745. o.TourGuideReason,
  25746. o.[Translate],
  25747. o.TranslateReason,
  25748. o.Trip,
  25749. o.TripReason,
  25750. o.ESFileName,
  25751. o.SignatureDate,
  25752. o.Remark
  25753. FROM
  25754. Grp_Opinionaire o
  25755. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  25756. WHERE
  25757. o.IsDel = 0
  25758. AND o.DiId = {0}
  25759. ORDER BY
  25760. o.Id ASC", diId);
  25761. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  25762. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  25763. return Ok(JsonView(data));
  25764. }
  25765. /// <summary>
  25766. /// 团组接待意见调查 - 用户
  25767. /// 保存
  25768. /// </summary>
  25769. /// <param name="dto"></param>
  25770. /// <returns></returns>
  25771. [HttpPost]
  25772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25773. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  25774. {
  25775. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  25776. foreach (var item in dto)
  25777. {
  25778. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  25779. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  25780. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  25781. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  25782. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  25783. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  25784. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  25785. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  25786. }
  25787. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  25788. if (!Directory.Exists(filePathBase))
  25789. {
  25790. Directory.CreateDirectory(filePathBase);
  25791. }
  25792. #region 上传文件
  25793. var filePaths = new List<string>();
  25794. foreach (var item in dto)
  25795. {
  25796. var file = item.File;
  25797. // 将文件保存到指定位置
  25798. var filePath = Path.Combine(filePathBase, file.FileName);
  25799. using (var stream = new FileStream(filePath, FileMode.Create))
  25800. {
  25801. await file.CopyToAsync(stream);
  25802. }
  25803. //验证文件是否上传成功
  25804. if (!System.IO.File.Exists(filePath))
  25805. {
  25806. foreach (var filePathStr in filePaths)
  25807. {
  25808. System.IO.File.Delete(filePathStr);
  25809. }
  25810. return Ok(JsonView(false, "文件上传失败!"));
  25811. }
  25812. item.ESFileName = file.FileName;
  25813. }
  25814. #endregion
  25815. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  25816. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  25817. .UpdateColumns(x => new
  25818. {
  25819. x.Catering,
  25820. x.CateringReason,
  25821. x.Stay,
  25822. x.StayReason,
  25823. x.Route,
  25824. x.RouteReason,
  25825. x.OfficialActivity,
  25826. x.OfficialActivityReason,
  25827. x.TourGuide,
  25828. x.TourGuideReason,
  25829. x.Translate,
  25830. x.TranslateReason,
  25831. x.Trip,
  25832. x.TripReason,
  25833. x.ESFileName,
  25834. x.SignatureDate,
  25835. x.Remark
  25836. })
  25837. .WhereColumns(x => new { x.Id })
  25838. .ExecuteCommandAsync();
  25839. if (upd < 1)
  25840. {
  25841. foreach (var filePathStr in filePaths)
  25842. {
  25843. System.IO.File.Delete(filePathStr);
  25844. }
  25845. return Ok(JsonView(false));
  25846. }
  25847. return Ok(JsonView(true));
  25848. }
  25849. #endregion
  25850. #region 团组餐厅相关信息
  25851. /// <summary>
  25852. /// 团组相关餐厅信息
  25853. /// 基础数据(团组)
  25854. /// </summary>
  25855. /// <returns></returns>
  25856. [HttpGet]
  25857. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25858. public async Task<IActionResult> RestaurantInit()
  25859. {
  25860. return Ok(await _restaurantRep.InitAsync());
  25861. }
  25862. /// <summary>
  25863. /// 团组相关餐厅信息
  25864. /// Item
  25865. /// </summary>
  25866. /// <param name="dto"></param>
  25867. /// <returns></returns>
  25868. [HttpPost]
  25869. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25870. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  25871. {
  25872. int portType = dto.PortType,
  25873. groupId = dto.GroupId;
  25874. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  25875. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  25876. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  25877. }
  25878. /// <summary>
  25879. /// 团组相关餐厅信息
  25880. /// List
  25881. /// </summary>
  25882. /// <param name="dto"></param>
  25883. /// <returns></returns>
  25884. [HttpPost]
  25885. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25886. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  25887. {
  25888. int portType = dto.PortType,
  25889. groupId = dto.GroupId;
  25890. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  25891. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  25892. var sql = string.Format(@" SELECT
  25893. ri.Id,
  25894. ri.GroupId,
  25895. ri.Date,
  25896. ri.StartTime,
  25897. ri.EndTime,
  25898. CASE WHEN ri.Type = 1 THEN '早餐'
  25899. WHEN ri.Type = 2 THEN '午餐'
  25900. WHEN ri.Type = 3 THEN '晚餐'
  25901. ELSE '其他'
  25902. END AS 'Type',
  25903. ri.Name,
  25904. ri.Address,
  25905. ri.Tel,
  25906. ri.Remark,
  25907. ri.CreateTime,
  25908. u.CnName AS CreateUserName
  25909. FROM
  25910. Grp_RestaurantInfo ri
  25911. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  25912. WHERE
  25913. ri.IsDel = 0
  25914. AND ri.GroupId = {0}
  25915. ORDER BY
  25916. ri.Date ASC
  25917. ", groupId);
  25918. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  25919. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  25920. return Ok(JsonView(infos));
  25921. }
  25922. /// <summary>
  25923. /// 团组相关餐厅信息
  25924. /// Info
  25925. /// </summary>
  25926. /// <param name="dto"></param>
  25927. /// <returns></returns>
  25928. [HttpPost]
  25929. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25930. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  25931. {
  25932. int portType = dto.PortType,
  25933. id = dto.Id;
  25934. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  25935. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  25936. return Ok(await _restaurantRep.InfoAsync(portType, id));
  25937. }
  25938. /// <summary>
  25939. /// 团组相关餐厅信息
  25940. /// Op
  25941. /// </summary>
  25942. /// <param name="dto"></param>
  25943. /// <returns></returns>
  25944. [HttpPost]
  25945. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25946. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  25947. {
  25948. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  25949. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  25950. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  25951. return Ok(await _restaurantRep.OpAsync(dto));
  25952. }
  25953. /// <summary>
  25954. /// 团组相关餐厅信息
  25955. /// Del
  25956. /// </summary>
  25957. /// <param name="dto"></param>
  25958. /// <returns></returns>
  25959. [HttpPost]
  25960. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25961. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  25962. {
  25963. int userId = dto.DeleteUserId;
  25964. var id = dto.Id;
  25965. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  25966. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  25967. return Ok(await _restaurantRep.DelAsync(dto));
  25968. }
  25969. #endregion
  25970. #region 团组会务成本
  25971. /// <summary>
  25972. /// 团组会务成本数据初始化
  25973. /// </summary>
  25974. /// <returns></returns>
  25975. [HttpPost]
  25976. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  25977. {
  25978. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  25979. .OrderByDescending(x => x.CreateTime)
  25980. .Where(x => x.IsDel == 0)
  25981. .Select<DelegationEasyView>();
  25982. DelegationEasyView di = Dto.GroupId == 0 ?
  25983. expr.First() :
  25984. expr.First(x => x.Id == Dto.GroupId);
  25985. if (di == null)
  25986. {
  25987. return Ok(JsonView(false, "团组信息不存在!"));
  25988. }
  25989. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  25990. .Where(x => x.IsDel == 0 && x.STid == 21)
  25991. .Select(x => new { x.Id, Text = x.Name })
  25992. .ToListAsync();
  25993. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  25994. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  25995. .Select(x => x.Id)
  25996. .ToList();
  25997. //仅检索会务团组
  25998. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  25999. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  26000. .OrderByDescending(x => x.VisitDate)
  26001. .Select(x => new { x.Id, x.TeamName })
  26002. .ToListAsync();
  26003. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  26004. var userList = await _sqlSugar.Queryable<Sys_Users>()
  26005. .Where(x => x.IsDel == 0)
  26006. .Select(x => new { x.Id, x.CnName })
  26007. .ToListAsync();
  26008. var units = await _sqlSugar.Queryable<Sys_SetData>()
  26009. .Where(x => x.IsDel == 0 && x.STid == 119)
  26010. .Select(x => new { x.Id, Text = x.Name })
  26011. .ToListAsync();
  26012. var FileType = new[]
  26013. {
  26014. new { Id = 0 , Name = "成本下载" },
  26015. new { Id = 1 , Name = "报价下载" },
  26016. new { Id = 2 , Name = "总表下载" },
  26017. };
  26018. var GM = new List<int>();
  26019. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  26020. try
  26021. {
  26022. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  26023. }
  26024. catch (Exception ex)
  26025. {
  26026. GM = new List<int>() { 21 };
  26027. }
  26028. var isReview = Dto.UserId == 21;
  26029. var isGM = GM.Contains(Dto.UserId);
  26030. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  26031. .Where(x => x.IsDel == 0)
  26032. .Select<ConferenceAffairsCostView>()
  26033. .First(x => x.Diid == di.Id);
  26034. if (ConferenceAffairsCost == null)
  26035. {
  26036. ConferenceAffairsCost = new ConferenceAffairsCostView();
  26037. ConferenceAffairsCost.Diid = di.Id;
  26038. }
  26039. #region 权限校验
  26040. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  26041. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  26042. .Select(x => x.UserId)
  26043. .Distinct()
  26044. .ToList();
  26045. if (!ids.Contains(Dto.UserId) && !isGM)
  26046. {
  26047. return Ok(JsonView(201, "暂无权限!", new
  26048. {
  26049. typeData,
  26050. groupList,
  26051. currenyList,
  26052. isGM,
  26053. userList,
  26054. units,
  26055. isReview,
  26056. operatorUser = ids,
  26057. di,
  26058. FileType
  26059. }));
  26060. }
  26061. #endregion
  26062. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  26063. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  26064. .Select<ConferenceAffairsCostChildView>()
  26065. .OrderBy(x => x.Index)
  26066. .ToList();
  26067. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  26068. {
  26069. ConferenceAffairsCostChi[i - 1].Index = i;
  26070. }
  26071. var backData = new
  26072. {
  26073. ConferenceAffairsCost,
  26074. ConferenceAffairsCostChi,
  26075. typeData,
  26076. groupList,
  26077. currenyList,
  26078. isGM,
  26079. userList,
  26080. units,
  26081. isReview,
  26082. operatorUser = ids,
  26083. di,
  26084. FileType
  26085. };
  26086. return Ok(JsonView(true, "SUCCESS", backData));
  26087. }
  26088. /// <summary>
  26089. /// 会务成本保存
  26090. /// </summary>
  26091. /// <returns></returns>
  26092. [HttpPost]
  26093. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  26094. {
  26095. _sqlSugar.BeginTran();
  26096. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  26097. var childResult = new
  26098. {
  26099. success = 0,
  26100. error = 0
  26101. };
  26102. try
  26103. {
  26104. if (data.Id == 0)
  26105. {
  26106. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  26107. .Where(x => x.Diid == Dto.GroupId)
  26108. .SetColumns(x => new Grp_ConferenceAffairsCost
  26109. {
  26110. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26111. DeleteUserId = Dto.UserId
  26112. })
  26113. .ExecuteCommand();
  26114. data.Diid = Dto.GroupId;
  26115. data.CreateTime = DateTime.Now;
  26116. data.CreateUserId = Dto.UserId;
  26117. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  26118. .ExecuteReturnIdentity();
  26119. }
  26120. else
  26121. {
  26122. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  26123. .ExecuteCommand();
  26124. data.Id = data.Id;
  26125. }
  26126. if (Dto.ConferenceAffairsCostChild.Any())
  26127. {
  26128. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  26129. var insertArr = datas.Where(x => x.Id == 0).ToList();
  26130. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  26131. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  26132. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  26133. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  26134. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  26135. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  26136. .ExecuteCommand() : 0;
  26137. childResult = childResult with
  26138. {
  26139. error = notUpdateArr.Count(),
  26140. success = inrsetCount + updateCount
  26141. };
  26142. }
  26143. _sqlSugar.CommitTran();
  26144. }
  26145. catch (Exception ex)
  26146. {
  26147. _sqlSugar.RollbackTran();
  26148. return Ok(JsonView(false, "失败!" + ex.Message));
  26149. }
  26150. return Ok(JsonView(true, "操作成功!", childResult));
  26151. }
  26152. [HttpPost]
  26153. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  26154. {
  26155. var count = 0;
  26156. if (Dto.ConferenceAffairsCostChildids.Any())
  26157. {
  26158. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  26159. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  26160. SetColumns(x => new Grp_ConferenceAffairsCostChild
  26161. {
  26162. ReviewStatus = Dto.ReviewStatus
  26163. }).
  26164. ExecuteCommand();
  26165. }
  26166. return Ok(JsonView(true, "操作成功!", count));
  26167. }
  26168. /// <summary>
  26169. /// 会务成本所有数据清除
  26170. /// </summary>
  26171. /// <param name="Dto"></param>
  26172. /// <returns></returns>
  26173. [HttpPost]
  26174. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  26175. {
  26176. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  26177. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  26178. _sqlSugar.BeginTran();
  26179. try
  26180. {
  26181. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  26182. .Where(x => x.Diid == Dto.GroupId)
  26183. .SetColumns(x => new Grp_ConferenceAffairsCost
  26184. {
  26185. IsDel = 1,
  26186. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26187. DeleteUserId = Dto.UserId
  26188. })
  26189. .ExecuteCommand();
  26190. if (delCount > 0)
  26191. {
  26192. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  26193. .Where(x => x.Diid == Dto.GroupId)
  26194. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  26195. {
  26196. IsDel = 1,
  26197. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26198. DeleteUserId = Dto.UserId
  26199. })
  26200. .ExecuteCommand();
  26201. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  26202. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  26203. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  26204. {
  26205. IsDel = 1,
  26206. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26207. DeleteUserId = Dto.UserId
  26208. })
  26209. .ExecuteCommand();
  26210. }
  26211. _sqlSugar.CommitTran();
  26212. }
  26213. catch (Exception ex)
  26214. {
  26215. _sqlSugar.RollbackTran();
  26216. return Ok(JsonView(false, "操作失败!" + ex.Message));
  26217. }
  26218. return Ok(JsonView(true, "操作成功!"));
  26219. }
  26220. /// <summary>
  26221. /// 子项数据删除
  26222. /// </summary>
  26223. /// <param name="Dto"></param>
  26224. /// <returns></returns>
  26225. [HttpPost]
  26226. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  26227. {
  26228. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  26229. .Any(x => x.ReviewStatus == 1);
  26230. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  26231. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  26232. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  26233. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  26234. {
  26235. IsDel = 1,
  26236. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26237. DeleteUserId = Dto.UserId
  26238. })
  26239. .ExecuteCommand();
  26240. return Ok(JsonView(true, "SUCCESS!", count));
  26241. }
  26242. /// <summary>
  26243. /// 会务成本权限分配
  26244. /// </summary>
  26245. /// <param name="Dto"></param>
  26246. /// <returns></returns>
  26247. [HttpPost]
  26248. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  26249. {
  26250. _sqlSugar.BeginTran();
  26251. var count = 0;
  26252. try
  26253. {
  26254. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  26255. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  26256. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  26257. {
  26258. IsDel = 1,
  26259. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26260. DeleteUserId = Dto.CreateUserId
  26261. })
  26262. .ExecuteCommand();
  26263. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  26264. {
  26265. CreateTime = DateTime.Now,
  26266. CreateUserId = Dto.CreateUserId,
  26267. UserId = x,
  26268. Diid = Dto.GroupId,
  26269. }).ToList()).ExecuteCommand();
  26270. _sqlSugar.CommitTran();
  26271. }
  26272. catch (Exception ex)
  26273. {
  26274. _sqlSugar.RollbackTran();
  26275. return Ok(JsonView(false, "操作失败!" + ex.Message));
  26276. }
  26277. return Ok(JsonView(true, "操作成功!", count));
  26278. }
  26279. /// <summary>
  26280. /// 团组会务成本文件下载
  26281. /// </summary>
  26282. /// <returns></returns>
  26283. [HttpPost]
  26284. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  26285. {
  26286. var FileType = new[]
  26287. {
  26288. new { Id = 0 , Name = "成本下载" },
  26289. new { Id = 1 , Name = "报价下载" },
  26290. new { Id = 2 , Name = "总表下载" },
  26291. };
  26292. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  26293. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  26294. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  26295. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  26296. .Select<DelegationEasyView>()
  26297. .First();
  26298. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  26299. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  26300. if (main == null)
  26301. {
  26302. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  26303. }
  26304. JsonView jw = JsonView(false);
  26305. //总表下载
  26306. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  26307. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  26308. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  26309. var field = string.Empty;
  26310. var fileTypeName = string.Empty;
  26311. field = @$"
  26312. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  26313. b.Name as PriceTypeStr ,
  26314. c.Name as CurrencyStr ,
  26315. d.Name as UnitStr ,
  26316. case a.ReviewStatus
  26317. WHEN 1 THEN '已通过'
  26318. WHEN 0 THEN '未审核'
  26319. WHEN -1 THEN '未通过'
  26320. ELSE '未审核'
  26321. END AS ReviewStatusStr
  26322. ";
  26323. if (Dto.FileTypeId == 0)
  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 == 1)
  26331. {
  26332. fileTypeName = "会务成本报价表";
  26333. loadPath += $"{fileTypeName}.xlsx";
  26334. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26335. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26336. }
  26337. else if (Dto.FileTypeId == 2)
  26338. {
  26339. fileTypeName = "会务成本总表";
  26340. loadPath += $"{fileTypeName}.xlsx";
  26341. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26342. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26343. }
  26344. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  26345. SELECT
  26346. {field}
  26347. FROM Grp_ConferenceAffairsCostChild a
  26348. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  26349. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  26350. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  26351. WHERE a.isdel = 0
  26352. AND a.Diid = {main.Diid}
  26353. AND a.ConferenceAffairsCostId = {main.Id}
  26354. ").ToList();
  26355. var currLists = chiExcelContent.Select(x => new CurrList
  26356. {
  26357. CurrName = x.CurrencyStr,
  26358. CurrRate = x.Rate
  26359. })
  26360. .Distinct()
  26361. .ToList();
  26362. var designer = new WorkbookDesigner
  26363. {
  26364. Workbook = new Workbook(loadPath)
  26365. };
  26366. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  26367. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  26368. designer.SetDataSource("TeamName", di.TeamName);
  26369. designer.SetDataSource("City", main.City);
  26370. designer.SetDataSource("AllCost", main.CostAll);
  26371. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  26372. designer.SetDataSource("Curr", MostCurr.Name);
  26373. designer.SetDataSource("Curr1", MostCurr.Name);
  26374. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  26375. dt.TableName = "TB";
  26376. designer.SetDataSource(dt);
  26377. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  26378. dt1.TableName = "currTb";
  26379. designer.SetDataSource(dt1);
  26380. designer.Process();
  26381. designer.Workbook.Save(outputPath);
  26382. jw = JsonView(true, "操作成功!", new
  26383. {
  26384. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  26385. FilePath = networkPath
  26386. });
  26387. return Ok(jw);
  26388. }
  26389. [HttpPost]
  26390. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  26391. {
  26392. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  26393. .Select(x => x.PriceName).ToList()));
  26394. }
  26395. #endregion
  26396. #region 会务流程
  26397. /// <summary>
  26398. /// 会务流程 - 团组列表
  26399. /// </summary>
  26400. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  26401. [HttpGet]
  26402. public async Task<IActionResult> ConferenceProceduresGroupNames()
  26403. {
  26404. var conferenceTypeIds = new List<int>() {
  26405. 302, // 成都-会务活动
  26406. 691 // 四川-会务活动
  26407. };
  26408. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26409. .Where(x => x.IsDel == 0)
  26410. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  26411. .OrderByDescending(x => x.VisitDate)
  26412. .Select(x => new
  26413. {
  26414. x.Id,
  26415. x.TeamName,
  26416. HasChildData = SqlFunc.Subqueryable<Grp_ConferenceProcedures>()
  26417. .Where(child => child.DiId == x.Id) // 替换关联条件
  26418. .Any() // 判断子表是否存在数据
  26419. })
  26420. .ToListAsync();
  26421. return Ok(JsonView(true, "SUCCESS", groupList));
  26422. }
  26423. /// <summary>
  26424. /// 会务流程 - 数据初始化
  26425. /// </summary>
  26426. /// <param name="dto"></param>
  26427. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  26428. [HttpPost]
  26429. public async Task<IActionResult> ConferenceProceduresInit(ConferenceProceduresInitDto dto)
  26430. {
  26431. try
  26432. {
  26433. var conferenceTypeIds = new List<int>() {
  26434. 302, // 成都-会务活动
  26435. 691 // 四川-会务活动
  26436. };
  26437. Grp_DelegationInfo targetGroup = null;
  26438. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26439. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  26440. .FirstAsync();
  26441. if (targetGroup == null)
  26442. {
  26443. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26444. .Where(x => x.IsDel == 0)
  26445. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  26446. .OrderByDescending(x => x.VisitDate)
  26447. .FirstAsync();
  26448. }
  26449. if (targetGroup == null)
  26450. {
  26451. return Ok(JsonView(false, "未找到任何团组信息"));
  26452. }
  26453. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26454. .Where(x => x.IsDel == 0)
  26455. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  26456. .OrderByDescending(x => x.VisitDate)
  26457. .Select(x => new
  26458. {
  26459. x.Id,
  26460. x.TeamName,
  26461. HasChildData = SqlFunc.Subqueryable<Grp_ConferenceProcedures>()
  26462. .Where(child => child.DiId == x.Id)
  26463. .Any() // 判断子表是否存在数据
  26464. })
  26465. .ToListAsync();
  26466. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  26467. .Where(x => x.DiId == targetGroup.Id && x.IsDel == 0)
  26468. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  26469. .ToListAsync();
  26470. if (!conferenceProceduresList.Any())
  26471. {
  26472. conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  26473. .Where(x => x.DiId == -1 && x.IsDel == 0)
  26474. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  26475. .ToListAsync();
  26476. }
  26477. var conferenceProceduresGroupByTitle = conferenceProceduresList
  26478. .GroupBy(x => x.Title)
  26479. .Select(x => new
  26480. {
  26481. title = x.Key,
  26482. itmes = x.Select(y => new
  26483. {
  26484. y.Id,
  26485. y.DataDetails,
  26486. y.Details,
  26487. y.Remark
  26488. }).ToList()
  26489. })
  26490. .ToList();
  26491. var response = new
  26492. {
  26493. GroupInfo = new
  26494. {
  26495. targetGroup.Id,
  26496. targetGroup.TeamName,
  26497. targetGroup.VisitDate,
  26498. targetGroup.VisitDays,
  26499. targetGroup.VisitPNumber,
  26500. targetGroup.VisitCountry,
  26501. targetGroup.VisitStartDate,
  26502. targetGroup.VisitEndDate,
  26503. targetGroup.ClientName,
  26504. targetGroup.ClientUnit
  26505. },
  26506. GroupList = groupList,
  26507. ConferenceProceduresList = conferenceProceduresList,
  26508. conferenceProceduresGroupByTitle = conferenceProceduresGroupByTitle
  26509. };
  26510. return Ok(JsonView(true, "SUCCESS", response));
  26511. }
  26512. catch (Exception ex)
  26513. {
  26514. _logger.LogError(ex, "数据初始化失败");
  26515. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  26516. }
  26517. }
  26518. /// <summary>
  26519. /// 会务流程 - 保存
  26520. /// </summary>
  26521. /// <param name="dto"></param>
  26522. /// <returns></returns>
  26523. [HttpPost]
  26524. public async Task<IActionResult> ConferenceProceduresSave(ConferenceProceduresSaveDto dto)
  26525. {
  26526. _sqlSugar.BeginTran();
  26527. try
  26528. {
  26529. //删除旧数据
  26530. _sqlSugar.Updateable<Grp_ConferenceProcedures>()
  26531. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  26532. .SetColumns(x => new Grp_ConferenceProcedures
  26533. {
  26534. IsDel = 1,
  26535. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26536. DeleteUserId = dto.UserId
  26537. })
  26538. .ExecuteCommand();
  26539. //添加新数据
  26540. var newData = new List<Grp_ConferenceProcedures>();
  26541. foreach (var item in dto.ConferenceProceduresSaveItem)
  26542. {
  26543. foreach (var item2 in item.itmes)
  26544. {
  26545. newData.Add(new Grp_ConferenceProcedures
  26546. {
  26547. DiId = dto.GroupId,
  26548. Title = item.title,
  26549. DataDetails = item2.DataDetails,
  26550. Details = item2.details,
  26551. Remark = item2.Remark,
  26552. CreateTime = DateTime.Now,
  26553. CreateUserId = dto.UserId
  26554. });
  26555. }
  26556. }
  26557. _sqlSugar.Insertable(newData).ExecuteCommand();
  26558. _sqlSugar.CommitTran();
  26559. }
  26560. catch (Exception ex)
  26561. {
  26562. _sqlSugar.RollbackTran();
  26563. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  26564. }
  26565. return Ok(JsonView(true, "SUCCESS"));
  26566. }
  26567. [HttpPost]
  26568. public async Task<IActionResult> ConferenceProceduresFileDown(ConferenceProceduresFileDownDto dto)
  26569. {
  26570. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26571. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  26572. .FirstAsync();
  26573. if (groupInfo == null)
  26574. {
  26575. return Ok(JsonView(false, "团组信息不存在"));
  26576. }
  26577. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  26578. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  26579. .ToListAsync();
  26580. if (!conferenceProceduresList.Any())
  26581. {
  26582. return Ok(JsonView(false, "会务流程信息不存在"));
  26583. }
  26584. var filePath = $"{AppSettingsHelper.Get("ExcelBasePath")}Template/会务流程.xlsx";
  26585. if (!System.IO.File.Exists(filePath))
  26586. {
  26587. return Ok(JsonView(false, "模板文件不存在"));
  26588. }
  26589. var designer = new WorkbookDesigner();
  26590. designer.Workbook = new Workbook(filePath);
  26591. designer.SetDataSource("TB", conferenceProceduresList);
  26592. designer.Process();
  26593. var sheet = designer.Workbook.Worksheets[0];
  26594. var cells = sheet.Cells;
  26595. int col = 0; // 第一列
  26596. int startRow = 2; // 若第0行为表头,则从第1行开始;无表头请改为0
  26597. int endRow = cells.MaxDataRow;
  26598. if (endRow >= startRow)
  26599. {
  26600. int mergeStart = startRow;
  26601. string prev = cells[mergeStart, col].StringValue?.Trim() ?? string.Empty;
  26602. for (int r = startRow + 1; r <= endRow; r++)
  26603. {
  26604. string cur = cells[r, col].StringValue?.Trim() ?? string.Empty;
  26605. if (!string.Equals(cur, prev, StringComparison.Ordinal))
  26606. {
  26607. int count = r - mergeStart;
  26608. if (count > 1)
  26609. cells.Merge(mergeStart, col, count, 1);
  26610. mergeStart = r;
  26611. prev = cur;
  26612. }
  26613. }
  26614. int tailCount = endRow - mergeStart + 1;
  26615. if (tailCount > 1)
  26616. cells.Merge(mergeStart, col, tailCount, 1);
  26617. }
  26618. // byte[] bytes = null;
  26619. // using (MemoryStream stream = new MemoryStream())
  26620. // {
  26621. // designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  26622. // bytes = stream.ToArray();
  26623. // }
  26624. // return File(bytes, "application/excel", $"{groupInfo.TeamName}_会务流程.xlsx");
  26625. string savePath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceProcedures";
  26626. if (!System.IO.Directory.Exists(savePath))
  26627. {
  26628. System.IO.Directory.CreateDirectory(savePath);
  26629. }
  26630. designer.Workbook.Save($"{savePath}/{groupInfo.TeamName}_会务流程.xlsx");
  26631. string rst = savePath.replace(AppSettingsHelper.Get("ExcelBasePath"),
  26632. AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  26633. return Ok(JsonView(true, "SUCCESS", $"{rst}/{groupInfo.TeamName}_会务流程.xlsx"));
  26634. }
  26635. #endregion
  26636. #region 团组签证流程
  26637. /// <summary>
  26638. /// 团组签证流程 - 团组列表(分页)
  26639. /// </summary>
  26640. /// <returns></returns>
  26641. [HttpPost]
  26642. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  26643. {
  26644. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  26645. string groupName = dto.GroupName.Trim();
  26646. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  26647. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  26648. int portType = dto.PortType;
  26649. RefAsync<int> total = 0;
  26650. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  26651. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  26652. .InnerJoin<Grp_VisaProcessSteps>((x, y, z) => x.DIId == z.GroupId)
  26653. .Where((x, y, z) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId && z.IsDel == 0);
  26654. //构建单字模糊查询
  26655. if (!string.IsNullOrEmpty(groupName))
  26656. {
  26657. var characters = groupName.ToCharArray();
  26658. foreach (var character in characters)
  26659. {
  26660. var charString = character.ToString();
  26661. query = query.Where((x, y) =>
  26662. SqlFunc.Contains(y.TeamName, charString));
  26663. }
  26664. }
  26665. var groups = await query
  26666. .OrderByDescending((x, y) => y.VisitDate)
  26667. .Select((x, y) => new
  26668. {
  26669. y.Id,
  26670. GroupName = y.TeamName,
  26671. y.VisitDate,
  26672. // 加入子查询统计子表条数
  26673. CompletedCount = SqlFunc.Subqueryable<Grp_VisaProcessSteps>()
  26674. .Where(sub => sub.GroupId == y.Id && sub.IsCompleted && sub.IsDel == 0)
  26675. .Count()
  26676. })
  26677. .Distinct()
  26678. .ToPageListAsync(pageIndex, pageSize, total);
  26679. var msg = "SUCCESS";
  26680. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  26681. var groups1 = groups.Select(x => new
  26682. {
  26683. x.Id,
  26684. x.GroupName,
  26685. x.CompletedCount
  26686. }).ToList();
  26687. return Ok(JsonView(true, msg, groups1, total));
  26688. }
  26689. /// <summary>
  26690. /// 团组签证流程 - 详情
  26691. /// </summary>
  26692. /// <returns></returns>
  26693. [HttpPost]
  26694. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  26695. {
  26696. var res = await _visaProcessRep.Info(dto);
  26697. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  26698. return Ok(JsonView(true, res.Msg, res.Data));
  26699. }
  26700. /// <summary>
  26701. /// 团组签证流程 - 流程创建测试
  26702. /// </summary>
  26703. /// <returns></returns>
  26704. [HttpPost]
  26705. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  26706. {
  26707. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  26708. }
  26709. /// <summary>
  26710. /// 团组签证流程 - 流程Top4Init 测试
  26711. /// </summary>
  26712. /// <returns></returns>
  26713. [HttpPost]
  26714. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  26715. {
  26716. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  26717. }
  26718. /// <summary>
  26719. /// 团组签证流程 - 设置状态 完成/未完成
  26720. /// </summary>
  26721. /// <returns></returns>
  26722. [HttpPost]
  26723. public async Task<IActionResult> VisaProcessSetCompleted(VisaProcessSetCompletedDto dto)
  26724. {
  26725. //参数验证
  26726. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).AnyAsync();
  26727. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  26728. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  26729. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26730. var res = await _visaProcessRep.SetCompleted(dto.StepId, dto.CurrUserId, dto.IsCompleted);
  26731. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  26732. return Ok(JsonView(true, res.Msg));
  26733. }
  26734. /// <summary>
  26735. /// 团组签证流程 - 修改各步骤内容
  26736. /// </summary>
  26737. /// <returns></returns>
  26738. [HttpPost]
  26739. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  26740. {
  26741. //参数验证
  26742. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  26743. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  26744. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  26745. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26746. if (dto.StepContents == null && dto.StepContents.Count < 1)
  26747. {
  26748. return Ok(JsonView(false, "步骤内容无效。"));
  26749. }
  26750. //各步骤值处理
  26751. object stepVal;
  26752. if (stepValid.Step == 7) stepVal = dto.StepContents;
  26753. else stepVal = dto.StepContents[0].ToString();
  26754. var stepInfo = new Grp_VisaProcessSteps
  26755. {
  26756. Id = dto.StepId,
  26757. DataType = stepValid.DataType,
  26758. TypedValue = stepVal,
  26759. LastUpdateUserId = dto.CurrUserId
  26760. };
  26761. var res = await _visaProcessRep.Update(stepInfo);
  26762. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  26763. return Ok(JsonView(true, res.Msg));
  26764. }
  26765. /// <summary>
  26766. /// 团组签证流程 - 上传文件
  26767. /// </summary>
  26768. /// <returns></returns>
  26769. [HttpPost]
  26770. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  26771. {
  26772. //参数验证
  26773. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  26774. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  26775. var before = stepValid;
  26776. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  26777. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26778. //验证文件是否存在
  26779. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  26780. //验证该步骤是否可以上传文件
  26781. var uploadSteps = new List<int>() {
  26782. 5, //实际出签时间
  26783. 6, //是否需要开出境证明
  26784. 7, //是否需要办理电子入境卡手续
  26785. };
  26786. if (!uploadSteps.Contains(stepValid.Step))
  26787. {
  26788. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  26789. }
  26790. //验证根目录
  26791. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  26792. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  26793. if (!System.IO.Directory.Exists(rootPath))
  26794. {
  26795. System.IO.Directory.CreateDirectory(rootPath);
  26796. }
  26797. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  26798. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26799. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  26800. .Select(x => $"{x.TeamName}({x.Id})")
  26801. .FirstAsync();
  26802. //创建团组文件夹
  26803. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  26804. if (!System.IO.Directory.Exists(groupPath))
  26805. {
  26806. System.IO.Directory.CreateDirectory(groupPath);
  26807. }
  26808. List<string> filePaths = new List<string>();
  26809. //保存文件
  26810. foreach (var file in dto.Files)
  26811. {
  26812. // 生成存储文件名
  26813. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  26814. var filePath = Path.Combine(groupPath, fileName);
  26815. // 保存文件到磁盘
  26816. using (var stream = new FileStream(filePath, FileMode.Create))
  26817. {
  26818. await file.CopyToAsync(stream);
  26819. }
  26820. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  26821. }
  26822. //数据库存储
  26823. stepValid.TypedFileNameValue = filePaths;
  26824. stepValid.LastUpdateUserId = dto.CurrUserId;
  26825. stepValid.LastUpdateTime = DateTime.Now;
  26826. var res = await _sqlSugar.Updateable(stepValid)
  26827. .UpdateColumns(it => new { it.TypedFileNameValue, it.LastUpdateUserId, it.LastUpdateTime })
  26828. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  26829. .ExecuteCommandAsync();
  26830. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  26831. //记录上传文件
  26832. await _visaProcessRep.LogOperationAsync(before, stepValid, "Upload", dto.CurrUserId);
  26833. return Ok(JsonView(true));
  26834. }
  26835. /// <summary>
  26836. /// 团组签证流程 - step 7 资料下载
  26837. /// </summary>
  26838. /// <returns></returns>
  26839. [HttpGet]
  26840. public async Task<IActionResult> VisaProcessDownload(int groupId, int currUserId)
  26841. {
  26842. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  26843. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26844. //验证根目录
  26845. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  26846. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  26847. if (!System.IO.Directory.Exists(rootPath))
  26848. {
  26849. System.IO.Directory.CreateDirectory(rootPath);
  26850. }
  26851. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  26852. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26853. .Where(x => x.IsDel == 0 && x.Id == groupId)
  26854. .Select(x => $"{x.TeamName}({x.Id})")
  26855. .FirstAsync();
  26856. //创建团组文件夹
  26857. var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
  26858. var randomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  26859. var dirName = $"{groupName}_相关资料_{timestamp}";
  26860. var sourceDirectoryPath = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}";
  26861. var path = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}/{dirName}";
  26862. if (!System.IO.Directory.Exists(path))
  26863. {
  26864. System.IO.Directory.CreateDirectory(path);
  26865. }
  26866. //验证接团客户名单
  26867. string sql = string.Format(@"
  26868. SELECT
  26869. tcl.Id,
  26870. tcl.DiId,
  26871. tcl.IsAccompany,
  26872. temp.*,
  26873. u.CnName AS Operator,
  26874. tcl.CreateTime AS OperatingTime,
  26875. ssd.name AS ShippingSpaceType
  26876. FROM
  26877. Grp_TourClientList tcl
  26878. LEFT JOIN (
  26879. SELECT
  26880. dc.Id AS DcId,
  26881. dc.LastName,
  26882. dc.FirstName,
  26883. ccom.CompanyFullName,
  26884. dc.Job,
  26885. cc.CertNo AS IDCardNo,
  26886. dc.Sex,
  26887. dc.BirthDay
  26888. FROM
  26889. Crm_DeleClient dc
  26890. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  26891. AND ccom.IsDel = 0
  26892. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  26893. AND cc.SdId = 773
  26894. AND cc.IsDel = 0
  26895. WHERE
  26896. dc.IsDel = 0
  26897. ) temp ON temp.DcId = tcl.ClientId
  26898. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  26899. LEFT JOIN sys_setdata ssd ON ssd.isdel = 0 AND ssd.id = tcl.ShippingSpaceTypeid
  26900. WHERE
  26901. tcl.IsDel = 0
  26902. AND tcl.DiId = {0}", groupId);
  26903. var groupClientList = await _sqlSugar.SqlQueryable<TourClientInfosView>(sql).ToListAsync();
  26904. //解密
  26905. foreach (var item in groupClientList)
  26906. {
  26907. EncryptionProcessor.DecryptProperties(item);
  26908. }
  26909. if (groupClientList == null || groupClientList.Count < 1)
  26910. {
  26911. return Ok(JsonView(false, $"团组客户名单未录入客户信息,不可生成相关资料。"));
  26912. }
  26913. #region 生成文件
  26914. //酒店信息
  26915. var hotelInfos = await _sqlSugar.Queryable<Grp_HotelReservations>()
  26916. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  26917. .OrderBy(x => x.CheckInDate)
  26918. .ToListAsync();
  26919. //航班信息
  26920. var airInfos = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  26921. .Where(x => x.IsDel == 0 && x.DIId == groupId)
  26922. .OrderBy(x => x.FlightsDate)
  26923. .ToListAsync();
  26924. foreach (var clientInfo in groupClientList)
  26925. {
  26926. var clientId = clientInfo.DcId;
  26927. var guestName = $"{clientInfo.LastName}{clientInfo.FirstName}";
  26928. #region 个人信息资料
  26929. #endregion
  26930. #region 机票航班信息
  26931. var clientAirInfos = airInfos.Where(x => x.ClientName.Contains(clientId.ToString())).ToList();
  26932. if (clientAirInfos != null && clientAirInfos.Count > 0)
  26933. {
  26934. //创建表格
  26935. Document airDoc = new Document();
  26936. DocumentBuilder airBuilder = new DocumentBuilder(airDoc);
  26937. GeneralMethod.SetupDocumentStyles(airBuilder);
  26938. GeneralMethod.AddTitle(airBuilder, $"{guestName} - 机票信息");
  26939. GeneralMethod.AddAirInfoSections(airBuilder, clientAirInfos, "机票航班信息");
  26940. var airRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  26941. var airFileName = $"{guestName}_机票信息_{airRandomStr}.docx";
  26942. airDoc.Save($"{path}/{airFileName}");
  26943. }
  26944. #endregion
  26945. #region 酒店信息
  26946. var clientHotelInfos = hotelInfos.Where(x => x.GuestName.Contains(clientId.ToString())).ToList();
  26947. if (clientHotelInfos != null && clientHotelInfos.Count > 0)
  26948. {
  26949. //创建表格
  26950. Document hotelDoc = new Document();
  26951. DocumentBuilder HotelBuilder = new DocumentBuilder(hotelDoc);
  26952. GeneralMethod.SetupDocumentStyles(HotelBuilder);
  26953. GeneralMethod.AddTitle(HotelBuilder, $"{guestName} - 酒店信息");
  26954. GeneralMethod.AddHotelInfoSections(HotelBuilder, clientHotelInfos, "酒店信息");
  26955. var hotelRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  26956. var hotelFileName = $"{guestName}_酒店信息_{hotelRandomStr}.docx";
  26957. hotelDoc.Save($"{path}/{hotelFileName}");
  26958. }
  26959. #endregion
  26960. }
  26961. #endregion
  26962. //打包文件夹
  26963. var sourceDirectory = $"{sourceDirectoryPath}/{dirName}";
  26964. var zipFilePath = $"{sourceDirectoryPath}/{dirName}.zip";
  26965. if (System.IO.File.Exists(zipFilePath))
  26966. {
  26967. System.IO.File.Delete(zipFilePath);
  26968. }
  26969. ZipFile.CreateFromDirectory(sourceDirectory, zipFilePath, CompressionLevel.Fastest, false);
  26970. // 等待并验证
  26971. await Task.Delay(100); // 给系统时间完成文件操作
  26972. if (System.IO.File.Exists(zipFilePath))
  26973. {
  26974. var fileInfo = new FileInfo(zipFilePath);
  26975. var url = $"{rootRrl}Office/GrpFile/VisaProcessFiles/{groupName}/{dirName}.zip";
  26976. //记录下载日志
  26977. await _visaProcessRep.LogOperationAsync(null, null, "Download", currUserId);
  26978. return Ok(JsonView(StatusCodes.Status200OK, "操作成功!", url));
  26979. }
  26980. return Ok(JsonView(false));
  26981. }
  26982. /// <summary>
  26983. /// 团组签证流程 - 根据步骤记录ID获取该步骤的所有操作日志
  26984. /// </summary>
  26985. /// <returns></returns>
  26986. [HttpGet]
  26987. public async Task<IActionResult> VisaProcessLogByStepId(int stepId)
  26988. {
  26989. //参数验证
  26990. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == stepId && x.IsDel == 0).FirstAsync();
  26991. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  26992. var logs = await _visaProcessRep.GetStepLogsAsync(stepId);
  26993. return Ok(JsonView(logs));
  26994. }
  26995. /// <summary>
  26996. /// 团组签证流程 - 根据团组ID获取该团组下所有步骤的操作日志
  26997. /// </summary>
  26998. /// <returns></returns>
  26999. [HttpGet]
  27000. public async Task<IActionResult> VisaProcessLogByGroupId(int groupId)
  27001. {
  27002. //参数验证
  27003. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.GroupId == groupId && x.IsDel == 0).FirstAsync();
  27004. if (stepValid == null) return Ok(JsonView(false, "团组ID无效。"));
  27005. var logs = await _visaProcessRep.GetGroupStepLogsAsync(groupId);
  27006. return Ok(JsonView(logs));
  27007. }
  27008. #endregion
  27009. #region 团组总览进程
  27010. /// <summary>
  27011. /// 团组总览进程 - 流程创建测试
  27012. /// </summary>
  27013. /// <returns></returns>
  27014. [HttpGet]
  27015. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27016. public async Task<IActionResult> GroupProcessInitTest(int groupId, int currUserId)
  27017. {
  27018. return Ok(await _processOverviewRep.ProcessInitAsync(groupId, currUserId));
  27019. }
  27020. /// <summary>
  27021. /// 团组总览进程 - 团组名称集合
  27022. /// </summary>
  27023. /// <returns></returns>
  27024. [HttpGet]
  27025. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27026. public async Task<IActionResult> GroupProcessGroupNames()
  27027. {
  27028. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  27029. .Where(x => x.IsDel == 0)
  27030. .OrderByDescending(x => x.VisitDate)
  27031. .Select(x => new
  27032. {
  27033. x.Id,
  27034. GroupName = x.TeamName,
  27035. HasProcess = SqlFunc.Subqueryable<Grp_ProcessOverview>()
  27036. .Where(po => po.GroupId == x.Id && po.IsDel == 0)
  27037. .Any()
  27038. })
  27039. .ToListAsync();
  27040. return Ok(JsonView(groupNames));
  27041. }
  27042. /// <summary>
  27043. /// 团组总览进程 - 流程详情
  27044. /// </summary>
  27045. /// <returns></returns>
  27046. [HttpGet]
  27047. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27048. public async Task<IActionResult> GroupProcessDetails(int groupId)
  27049. {
  27050. var res = await _processOverviewRep.ProcessesDetailsAsync(groupId);
  27051. if (res.Code == StatusCodes.Status200OK)
  27052. {
  27053. return Ok(JsonView(res.Data));
  27054. }
  27055. return Ok(JsonView(false, res.Msg));
  27056. }
  27057. /// <summary>
  27058. /// 团组总览进程 - 更新节点状态
  27059. /// </summary>
  27060. /// <returns></returns>
  27061. [HttpPost]
  27062. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27063. public async Task<IActionResult> GroupProcessUpdateNodeStatus(GroupProcessUpdateNodeStatusDto dto)
  27064. {
  27065. var res = await _processOverviewRep.UpdateNodeStatusAsync(dto.NodeId, dto.CurrUserId);
  27066. if (res.Code == StatusCodes.Status200OK)
  27067. {
  27068. return Ok(JsonView(res.Data));
  27069. }
  27070. return Ok(JsonView(false, res.Msg));
  27071. }
  27072. /// <summary>
  27073. /// 团组总览进程 - 更新签证节点信息
  27074. /// </summary>
  27075. /// <returns></returns>
  27076. [HttpPost]
  27077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27078. public async Task<IActionResult> GroupProcessUpdateVisaNodeDetails(GroupProcessUpdateVisaNodeDetailsDto dto)
  27079. {
  27080. //验证签证信息
  27081. if (dto.VisaSubNodes.Count < 1) return Ok(JsonView(false, "请传入有效的签证节点信息。"));
  27082. var res = await _processOverviewRep.UpdateVisaNodeDetailsAsync(dto);
  27083. if (res.Code == StatusCodes.Status200OK)
  27084. {
  27085. return Ok(JsonView(res.Data));
  27086. }
  27087. return Ok(JsonView(false, res.Msg));
  27088. }
  27089. /// <summary>
  27090. /// 团组总览进程 - 设置实际完成时间
  27091. /// </summary>
  27092. /// <returns></returns>
  27093. [HttpPost]
  27094. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27095. public async Task<IActionResult> GroupProcessSetActualDone(GroupProcessSetActualDoneDto dto)
  27096. {
  27097. //验证签证信息
  27098. var res = await _processOverviewRep.SetActualDoneAsync(dto.NodeId, dto.ActualDone, dto.CurrUserId);
  27099. if (res.Code == StatusCodes.Status200OK)
  27100. {
  27101. return Ok(JsonView(res.Data));
  27102. }
  27103. return Ok(JsonView(false, res.Msg));
  27104. }
  27105. #endregion
  27106. /// <summary>
  27107. /// 123132123
  27108. /// </summary>
  27109. /// <param name="_dto"></param>
  27110. /// <returns></returns>
  27111. [HttpPost]
  27112. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27113. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  27114. {
  27115. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  27116. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  27117. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  27118. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  27119. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  27120. dicDetail.Add(789, 1034);
  27121. dicDetail.Add(790, 1035);
  27122. dicDetail.Add(791, 1036);
  27123. dicDetail.Add(792, 1037);
  27124. dicDetail.Add(793, 1038);
  27125. dicDetail.Add(794, 1039);
  27126. dicDetail.Add(795, 1040);
  27127. dicDetail.Add(796, 1041);
  27128. dicDetail.Add(797, 1042);
  27129. dicDetail.Add(798, 1043);
  27130. dicDetail.Add(801, 1044);
  27131. dicDetail.Add(802, 1045);
  27132. dicDetail.Add(803, 1046);
  27133. Dictionary<int, int> dic = new Dictionary<int, int>();
  27134. dic.Add(806, 1027);
  27135. dic.Add(807, 1028);
  27136. dic.Add(808, 1029);
  27137. dic.Add(809, 1030);
  27138. dic.Add(810, 1031);
  27139. dic.Add(811, 1032);
  27140. dic.Add(812, 1033);
  27141. foreach (var item in list_visa)
  27142. {
  27143. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  27144. temp.Coefficient = item.coefficient;
  27145. DateTime dtCrt;
  27146. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  27147. if (b1)
  27148. {
  27149. temp.CreateTime = dtCrt;
  27150. }
  27151. else
  27152. {
  27153. temp.CreateTime = DateTime.Now;
  27154. }
  27155. temp.CreateUserId = item.Operators;
  27156. temp.DeleteTime = "";
  27157. temp.DeleteUserId = 0;
  27158. temp.DiId = int.Parse(item.DIID);
  27159. temp.FilePath = item.FilePath;
  27160. temp.IsDel = item.IsDel;
  27161. temp.Price = item.Price;
  27162. temp.PriceCount = 1;
  27163. temp.PriceCurrency = item.Currency;
  27164. int detailId = 0;
  27165. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  27166. {
  27167. detailId = dicDetail[item.PriceTypeDetail];
  27168. }
  27169. temp.PriceDetailType = detailId;
  27170. temp.PriceDt = DateTime.Now;
  27171. temp.PriceName = item.PriceName;
  27172. temp.PriceSum = item.Price;
  27173. int tid = 0;
  27174. if (dic.ContainsKey(item.PriceType))
  27175. {
  27176. tid = dic[item.PriceType];
  27177. }
  27178. temp.PriceType = tid;
  27179. temp.Remark = item.Remark;
  27180. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  27181. }
  27182. return Ok(JsonView(true, "操作成功!"));
  27183. }
  27184. [HttpPost]
  27185. public IActionResult TimeTest()
  27186. {
  27187. var jw = JsonView(false, "error");
  27188. _sqlSugar.BeginTran();
  27189. try
  27190. {
  27191. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  27192. .Select(x => new Crm_NewClientData
  27193. {
  27194. Id = x.Id,
  27195. Client = x.Client,
  27196. Contact = x.Contact,
  27197. Location = x.Location,
  27198. })
  27199. .ToList();
  27200. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  27201. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  27202. Stopwatch stopwatch = new Stopwatch();
  27203. // 开始计时
  27204. stopwatch.Start();
  27205. foreach (var item in clientList)
  27206. {
  27207. EncryptionProcessor.DecryptProperties(item);
  27208. }
  27209. stopwatch.Stop();
  27210. jw.Code = 200;
  27211. jw.Data = stopwatch.ElapsedMilliseconds;
  27212. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  27213. }
  27214. catch (Exception ex)
  27215. {
  27216. jw.Code = 400;
  27217. jw.Msg = ex.Message;
  27218. }
  27219. return Ok(jw);
  27220. }
  27221. [HttpPost]
  27222. public async Task<IActionResult> TimeTest1()
  27223. {
  27224. var infos = await _sqlSugar.Queryable<Crm_DeleClient>().ToListAsync();
  27225. return Ok(infos);
  27226. }
  27227. }
  27228. }