GroupsController.cs 1.4 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585
  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. },
  1111. Filters = new List<SearchFilter>()
  1112. {
  1113. new(){Field = "IsDel",Operator="eq",Value="0" }
  1114. },
  1115. OrderBy = "VisitDate",
  1116. ReturnFields = new List<string>() { "TeamName", "ClientUnit", "ClientName" }
  1117. };
  1118. // 验证字段配置
  1119. var validation = _groupSearchService.ValidateFieldConfig(
  1120. searchRequest.FieldWeights,
  1121. searchRequest.ReturnFields);
  1122. if (!validation.IsValid)
  1123. {
  1124. return Ok(JsonView(true, $"暂无数据!{validation.Message}"));
  1125. }
  1126. var result = await _groupSearchService.SearchAsync(searchRequest);
  1127. if (result.Success)
  1128. {
  1129. var data = new List<dynamic>();
  1130. foreach (var item in result.Items)
  1131. {
  1132. data.Add(new
  1133. {
  1134. item.Data.TeamName,
  1135. item.Data.ClientUnit,
  1136. item.Data.ClientName,
  1137. //item.Data.VisitDate
  1138. });
  1139. }
  1140. return Ok(JsonView(true, result.Message, data, data.Count));
  1141. }
  1142. return Ok(JsonView(true, result.Message));
  1143. }
  1144. catch (Exception ex)
  1145. {
  1146. return Ok(JsonView(true, $"搜索服务暂时不可用!"));
  1147. }
  1148. }
  1149. /// <summary>
  1150. /// 接团信息列表 Page
  1151. /// </summary>
  1152. /// <param name="dto">团组列表请求dto</param>
  1153. /// <returns></returns>
  1154. [HttpPost]
  1155. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1156. public async Task<IActionResult> PostGroupPageList(GroupPageListDto dto)
  1157. {
  1158. // 创建Stopwatch实例
  1159. var stopwatch = new Stopwatch();
  1160. stopwatch.Start();
  1161. #region 参数验证
  1162. if (dto.UserId < 1)
  1163. return Ok(JsonView(false, "员工Id为空"));
  1164. if (dto.PageId < 1)
  1165. return Ok(JsonView(false, "页面Id为空"));
  1166. #region 页面操作权限验证
  1167. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1168. if (pageFunAuthView.CheckAuth == 0)
  1169. return Ok(JsonView(false, "您没有查看权限"));
  1170. #endregion
  1171. #endregion
  1172. //if (dto.PortType != 1 && dto.PortType != 2) // web/Android
  1173. // return Ok(JsonView(false, "不支持的端口类型"));
  1174. // 构建查询条件
  1175. var sqlWhereBuilder = new StringBuilder(" WHERE gdi.IsDel = 0");
  1176. var parameters = new List<SugarParameter>();
  1177. // 完成状态筛选
  1178. if (dto.IsSure == 0 || dto.IsSure == 1)
  1179. {
  1180. sqlWhereBuilder.Append(" AND gdi.IsSure = @IsSure");
  1181. parameters.Add(new SugarParameter("@IsSure", dto.IsSure));
  1182. }
  1183. // 搜索条件
  1184. if (!string.IsNullOrWhiteSpace(dto.SearchCriteria))
  1185. {
  1186. var searchParam = $"%{dto.SearchCriteria.Trim()}%";
  1187. sqlWhereBuilder.Append(@"
  1188. AND (ssd.Name LIKE @SearchCriteria
  1189. OR gdi.TeamName LIKE @SearchCriteria
  1190. OR gdi.ClientName LIKE @SearchCriteria
  1191. OR su.CnName LIKE @SearchCriteria)");
  1192. parameters.Add(new SugarParameter("@SearchCriteria", searchParam));
  1193. }
  1194. // 等级筛选
  1195. if (int.TryParse(dto.Rank, out int rankId) && rankId > 0)
  1196. {
  1197. sqlWhereBuilder.Append(" AND gdi.TeamLevSId = @RankId");
  1198. parameters.Add(new SugarParameter("@RankId", rankId));
  1199. }
  1200. // 部门筛选
  1201. var departmentWhere = string.Empty;
  1202. if (!string.IsNullOrWhiteSpace(dto.Department) && !dto.Department.Equals("全部"))
  1203. {
  1204. departmentWhere = " WHERE Department = @Department";
  1205. parameters.Add(new SugarParameter("@Department", dto.Department));
  1206. }
  1207. // 构建SQL查询
  1208. string sql = $@"
  1209. SELECT Row_Number, Id, SalesQuoteNo, TourCode, TeamTypeId, TeamType, Department,
  1210. TeamLevId, TeamLev, TeamName, ClientName, ClientUnit,
  1211. VisitDate, VisitDays, VisitPNumber, JietuanOperatorId,
  1212. JietuanOperator, IsSure, CreateTime, IsBid, Step
  1213. FROM (
  1214. SELECT ROW_NUMBER() OVER(ORDER BY gdi.VisitStartDate DESC) AS Row_Number,
  1215. CASE
  1216. WHEN gdi.JietuanOperator IN (4, 21) THEN '国交部'
  1217. ELSE (SELECT DepName FROM OA2023DB.dbo.Sys_Department WHERE Id = su.DepId)
  1218. END AS 'Department',
  1219. gdi.Id, SalesQuoteNo, TourCode, ssd.Id AS TeamTypeId, ssd.Name AS TeamType, gdi.Step,
  1220. ssd1.Id AS TeamLevId, ssd1.Name AS TeamLev, TeamName, ClientName, ClientUnit,
  1221. VisitDate, VisitDays, VisitPNumber, JietuanOperator AS JietuanOperatorId,
  1222. su.CnName AS JietuanOperator, IsSure, gdi.CreateTime, gdi.IsBid
  1223. FROM Grp_DelegationInfo gdi
  1224. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  1225. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  1226. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  1227. {sqlWhereBuilder}
  1228. ) temp {departmentWhere}";
  1229. // 执行分页查询
  1230. RefAsync<int> total = 0;
  1231. var delegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql)
  1232. .AddParameters(parameters)
  1233. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  1234. if (!delegationList.Any())
  1235. {
  1236. var emptyView = new
  1237. {
  1238. PageFuncAuth = pageFunAuthView,
  1239. Data = delegationList
  1240. };
  1241. return Ok(JsonView(true, "查询成功,暂无数据", emptyView, total));
  1242. }
  1243. // 批量处理团组模块实际操作人和背景颜色设置
  1244. await ProcessDelegationListData(delegationList);
  1245. var resultView = new
  1246. {
  1247. PageFuncAuth = pageFunAuthView,
  1248. Data = delegationList
  1249. };
  1250. stopwatch.Stop();
  1251. return Ok(JsonView(true, $"查询成功!耗时:{stopwatch.Elapsed.TotalSeconds:F3}s", resultView, total));
  1252. }
  1253. /// <summary>
  1254. /// 批量处理团组数据
  1255. /// </summary>
  1256. private async Task ProcessDelegationListData(List<DelegationListView> delegationList)
  1257. {
  1258. var groupIds = delegationList.Select(x => x.Id).ToList();
  1259. // 批量查询信用卡支付记录
  1260. var creditCardPayments = await _sqlSugar.Queryable<Grp_CreditCardPayment>()
  1261. .Where(y => groupIds.Contains(y.DIId) && y.IsDel == 0)
  1262. .Select(y => y.DIId)
  1263. .Distinct()
  1264. .ToListAsync();
  1265. // 批量查询费用确认记录
  1266. var feeAcknowledgements = await _sqlSugar.Queryable<Grp_FeeEntryAcknowledge>()
  1267. .Where(y => groupIds.Contains(y.GroupId) && y.IsDel == 0)
  1268. .Where(y => y.IsAcknowledged == AcknowledgeStatusEnum.Acknowledged)
  1269. .Select(y => y.GroupId)
  1270. .Distinct()
  1271. .ToListAsync();
  1272. var creditCardPaymentSet = creditCardPayments.ToHashSet();
  1273. var feeAcknowledgementSet = feeAcknowledgements.ToHashSet();
  1274. // 并行处理每个团组
  1275. var tasks = delegationList.Select(async x =>
  1276. {
  1277. // 处理团组模块实际操作人
  1278. var operators = GeneralMethod.GetGroupModuleOperators(x.Id);
  1279. var operatorNames = new StringBuilder();
  1280. if (operators.Any())
  1281. {
  1282. foreach (var operatorInfo in operators)
  1283. {
  1284. string label = operatorInfo.OperationUsers.Any()
  1285. ? string.Join('、', operatorInfo.OperationUsers.Select(u => u.UserName))
  1286. : "暂未指定";
  1287. operatorNames.AppendLine($"{operatorInfo.CTableName}:{label}");
  1288. operatorNames.AppendLine();
  1289. }
  1290. }
  1291. x.OperatorLabel = operatorNames.ToString().TrimEnd('\n', '\r');
  1292. // 设置背景颜色为红色
  1293. // C表没数据并且没点提醒确认按钮(无成本费用按钮)的团组该行显示红色
  1294. bool hasCreditCardPayment = creditCardPaymentSet.Contains(x.Id);
  1295. bool hasFeeAcknowledgement = feeAcknowledgementSet.Contains(x.Id);
  1296. x.UseRedBackground = !hasCreditCardPayment && !hasFeeAcknowledgement;
  1297. });
  1298. await Task.WhenAll(tasks);
  1299. }
  1300. /// <summary>
  1301. /// 团组列表
  1302. /// </summary>
  1303. /// <returns></returns>
  1304. [HttpPost]
  1305. public async Task<IActionResult> GetGroupListByWhere(GroupListByWhere dto)
  1306. {
  1307. #region 参数验证
  1308. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  1309. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  1310. #region 页面操作权限验证
  1311. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  1312. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  1313. #endregion
  1314. #endregion
  1315. if (dto.PortType != 1 && dto.PortType != 2)
  1316. {
  1317. return Ok(JsonView(false, "查询失败!"));
  1318. }
  1319. string orderbyStr = "order by gdi.CreateTime Desc";
  1320. string sqlWhere = string.Empty;
  1321. if (dto.IsSure == 0) //未完成
  1322. {
  1323. sqlWhere += string.Format(@" And IsSure = 0");
  1324. }
  1325. else if (dto.IsSure == 1) //已完成
  1326. {
  1327. sqlWhere += string.Format(@" And IsSure = 1");
  1328. }
  1329. //团组类型
  1330. if (dto.TeamDid > 0)
  1331. {
  1332. sqlWhere += string.Format(@"And TeamDid = {0} ", dto.TeamDid);
  1333. }
  1334. //团组名称
  1335. if (!string.IsNullOrEmpty(dto.TeamName))
  1336. {
  1337. sqlWhere += string.Format(@"And TeamName Like '%{0}%'", dto.TeamName);
  1338. }
  1339. //客户名称
  1340. if (!string.IsNullOrEmpty(dto.ClientName))
  1341. {
  1342. sqlWhere += string.Format(@"And ClientName Like '%{0}%'", dto.ClientName);
  1343. }
  1344. //客户单位
  1345. if (!string.IsNullOrEmpty(dto.ClientUnit))
  1346. {
  1347. sqlWhere += string.Format(@"And ClientUnit Like '%{0}%'", dto.ClientUnit);
  1348. }
  1349. //出访时间
  1350. if (!string.IsNullOrEmpty(dto.visitDataTime))
  1351. {
  1352. sqlWhere += string.Format(@"And VisitDate >= '{0}'", dto.visitDataTime);
  1353. orderbyStr = "order by gdi.VisitDate";
  1354. }
  1355. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  1356. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  1357. VisitDate,VisitDays,VisitPNumber,JietuanOperatorId,
  1358. JietuanOperator,IsSure,CreateTime
  1359. From (
  1360. Select row_number() over({0}) as Row_Number,
  1361. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  1362. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  1363. VisitDate,VisitDays,VisitPNumber,JietuanOperator JietuanOperatorId,
  1364. su.CnName JietuanOperator,IsSure,gdi.CreateTime
  1365. From Grp_DelegationInfo gdi
  1366. Left Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  1367. Left Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  1368. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  1369. Where gdi.IsDel = 0 {1}
  1370. ) temp ", orderbyStr, sqlWhere);
  1371. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  1372. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  1373. #region 处理所属部门
  1374. /*
  1375. * 1.sq 和 gyy 等显示 市场部
  1376. * 2.王鸽和主管及张总还有管理员号统一国交部
  1377. * 2-1. 4 管理员 ,21 张海麟
  1378. */
  1379. var userIds = _DelegationList.Select(it => it.JietuanOperatorId).ToList();
  1380. var userIds1 = new List<int>() { 4, 21 };
  1381. var UserDepDatas = _sqlSugar.Queryable<Sys_Users>()
  1382. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  1383. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  1384. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  1385. .ToList();
  1386. foreach (var item in _DelegationList)
  1387. {
  1388. item.Department = UserDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  1389. }
  1390. #endregion
  1391. var _view = new
  1392. {
  1393. PageFuncAuth = pageFunAuthView,
  1394. Data = _DelegationList
  1395. };
  1396. return Ok(JsonView(true, $"查询成功!", _view, total));
  1397. }
  1398. /// <summary>
  1399. /// 接团信息详情
  1400. /// </summary>
  1401. /// <param name="dto">团组info请求dto</param>
  1402. /// <returns></returns>
  1403. [HttpPost]
  1404. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1405. public async Task<IActionResult> GetGroupInfo(GroupInfoDto dto)
  1406. {
  1407. var groupData = await _groupRepository.GetGroupInfo(dto);
  1408. if (groupData.Code != 0)
  1409. {
  1410. return Ok(JsonView(false, groupData.Msg));
  1411. }
  1412. return Ok(JsonView(groupData.Data));
  1413. }
  1414. /// <summary>
  1415. /// 接团信息 编辑添加
  1416. /// 基础信息数据源
  1417. /// </summary>
  1418. /// <param name="dto"></param>
  1419. /// <returns></returns>
  1420. [HttpPost]
  1421. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1422. public async Task<IActionResult> GroupEditBasicSource(GroupListDto dto)
  1423. {
  1424. var groupData = await _groupRepository.GroupEditBasicSource(dto);
  1425. if (groupData.Code != 0)
  1426. {
  1427. return Ok(JsonView(false, groupData.Msg));
  1428. }
  1429. return Ok(JsonView(groupData.Data));
  1430. }
  1431. /// <summary>
  1432. /// 成本修改团组信息
  1433. /// </summary>
  1434. /// <param name="dto"></param>
  1435. /// <returns></returns>
  1436. [HttpPost]
  1437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1438. public async Task<IActionResult> GroupCostEditGroupInfo(GroupCostEditGroupInfoDto dto)
  1439. {
  1440. var jw = JsonView(false, "操作失败");
  1441. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  1442. if (di == null)
  1443. {
  1444. jw.Msg = "参数有误!";
  1445. return Ok(jw);
  1446. }
  1447. #region 添加出访起止时间
  1448. var startTime = new DateTime();
  1449. var endTime = new DateTime();
  1450. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1451. {
  1452. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1453. }
  1454. else
  1455. {
  1456. jw.Msg = "参数有误!";
  1457. return Ok(jw);
  1458. }
  1459. #endregion
  1460. di.VisitDate = startTime;
  1461. di.VisitPNumber = dto.VisitPNumber;
  1462. di.VisitDays = dto.VisitDays;
  1463. di.VisitStartDate = startTime;
  1464. di.VisitEndDate = endTime;
  1465. var count = _sqlSugar.Updateable(di)
  1466. .UpdateColumns(x => new { x.VisitDate, x.VisitPNumber, x.VisitDays, x.VisitStartDate, x.VisitEndDate })
  1467. .ExecuteCommand();
  1468. return Ok(count > 0 ? JsonView(true, "操作成功") : jw);
  1469. }
  1470. /// <summary>
  1471. /// 接团信息 编辑添加
  1472. /// 省份-城市 基础信息数据源
  1473. /// </summary>
  1474. /// <param name="dto"></param>
  1475. /// <returns></returns>
  1476. [HttpPost]
  1477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1478. public async Task<IActionResult> GroupProvCityBasicSource(GroupProvCityBasicSourceDto dto)
  1479. {
  1480. int pageIndex = dto.PageIndex, pageSize = dto.PageSize;
  1481. string search = dto.Search;
  1482. var data = await _groupRepository.CityBasicSource();
  1483. int total = data.Length;
  1484. data = data.WhereIF(!string.IsNullOrEmpty(search), x => x.Name.Contains(search))
  1485. .Skip((pageIndex - 1) * pageSize)
  1486. .Take(pageSize)
  1487. .ToArray();
  1488. return Ok(JsonView(data, total));
  1489. }
  1490. /// <summary>
  1491. /// 接团信息 操作(增改)
  1492. /// </summary>
  1493. /// <param name="dto"></param>
  1494. /// <returns></returns>
  1495. [HttpPost]
  1496. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1497. public async Task<IActionResult> GroupOperation(GroupOperationDto dto)
  1498. {
  1499. // 创建 Stopwatch 实例
  1500. Stopwatch stopwatch = Stopwatch.StartNew();
  1501. decimal ffrPrice = 0.00M;
  1502. DateTime? visitDt = null;
  1503. if (dto.Status == 2)
  1504. {
  1505. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1506. if (groupInfo != null)
  1507. {
  1508. ffrPrice = groupInfo.PaymentMoney;
  1509. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1510. }
  1511. }
  1512. var groupData = await _groupRepository.GroupOperation(dto);
  1513. if (groupData.Code != 0)
  1514. {
  1515. return Ok(JsonView(false, groupData.Msg));
  1516. }
  1517. int diId = 0;
  1518. try
  1519. {
  1520. //添加时 默认加入团组汇率
  1521. if (dto.Status == 1) //添加
  1522. {
  1523. diId = groupData.Data;
  1524. //添加默认币种
  1525. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1526. //默认分配权限
  1527. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1528. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1529. var _managerIds = new List<int>() { 22, 32, 21 };
  1530. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1531. if (userIds.Count > 0)
  1532. {
  1533. userIds.Add(208);
  1534. //创建团组管控
  1535. GroupStepForDelegation.CreateWorkStep(diId);
  1536. //发送消息
  1537. string groupName = dto.TeamName;
  1538. string createGroupUser = string.Empty;
  1539. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1540. if (userInfo != null) createGroupUser = userInfo.CnName;
  1541. string title = $"系统通知";
  1542. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1543. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1544. }
  1545. //默认创建倒推表
  1546. await _invertedListRep._Create(dto.UserId, diId);
  1547. //默认创建签证流程
  1548. await _visaProcessRep.Create(dto.UserId, diId);
  1549. //默认创建团组流程总览信息
  1550. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1551. }
  1552. else if (dto.Status == 2)
  1553. {
  1554. diId = dto.Id;
  1555. }
  1556. #region 签证人员团组时间通知
  1557. #region 计算出访起止时间
  1558. var startTime = new DateTime();
  1559. var endTime = new DateTime();
  1560. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1561. {
  1562. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1563. }
  1564. #endregion
  1565. #endregion
  1566. #region 团组操作默认添加/修改收款账单
  1567. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1568. {
  1569. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1570. .Where(x => x.IsDel == 0 &&
  1571. x.Diid == diId &&
  1572. x.Remark.Equals("预付款")
  1573. )
  1574. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1575. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1576. .FirstAsync();
  1577. ffrInfo = new Fin_ForeignReceivables()
  1578. {
  1579. Diid = diId,
  1580. PriceName = dto.ClientUnit,
  1581. Price = dto.PaymentMoney,
  1582. Count = 1,
  1583. Unit = $"元",
  1584. ItemSumPrice = dto.PaymentMoney,
  1585. Rate = 1.0000M,
  1586. Currency = 836,
  1587. AddingWay = 0,
  1588. CreateUserId = dto.UserId,
  1589. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1590. Remark = $"预付款"
  1591. };
  1592. if (ffrInfo == null) //Add
  1593. {
  1594. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1595. }
  1596. else //修改
  1597. {
  1598. await _sqlSugar.Updateable(ffrInfo)
  1599. .UpdateColumns(x => new
  1600. {
  1601. x.PriceName,
  1602. x.Price,
  1603. x.ItemSumPrice,
  1604. x.CreateTime,
  1605. x.CreateUserId
  1606. })
  1607. .WhereColumns(x => x.Id)
  1608. .ExecuteCommandAsync();
  1609. }
  1610. }
  1611. #endregion
  1612. if (diId > 0)
  1613. {
  1614. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1615. }
  1616. // 停止计时
  1617. stopwatch.Stop();
  1618. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1619. }
  1620. catch (Exception ex)
  1621. {
  1622. // 停止计时
  1623. stopwatch.Stop();
  1624. Logs("[response]" + JsonConvert.SerializeObject(dto));
  1625. Logs(ex.Message);
  1626. //return Ok(JsonView(false, $"{ex.Message}[{stopwatch.ElapsedMilliseconds}ms]"));
  1627. }
  1628. // 停止计时
  1629. stopwatch.Stop();
  1630. return Ok(JsonView(true, $"操作成功!{stopwatch.ElapsedMilliseconds}ms", diId));
  1631. }
  1632. /// <summary>
  1633. /// 接团流程操作(增改)
  1634. /// 安卓端使用 建团时添加客户名单
  1635. /// </summary>
  1636. /// <param name="dto"></param>
  1637. /// <returns></returns>
  1638. [HttpPost]
  1639. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1640. public async Task<IActionResult> GroupProcessOperation(GroupProcessOperationDto dto)
  1641. {
  1642. #region 参数验证
  1643. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1644. #region 页面操作权限验证
  1645. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1646. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1647. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1648. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1649. #endregion
  1650. #endregion
  1651. try
  1652. {
  1653. //_sqlSugar.BeginTran();
  1654. decimal ffrPrice = 0.00M;
  1655. DateTime? visitDt = null;
  1656. if (dto.Status == 2)
  1657. {
  1658. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1659. if (groupInfo != null)
  1660. {
  1661. ffrPrice = groupInfo.PaymentMoney;
  1662. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1663. }
  1664. }
  1665. var _dto = new GroupOperationDto();
  1666. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1667. var groupData = await _groupRepository.GroupOperation(_dto);
  1668. if (groupData.Code != 0)
  1669. {
  1670. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1671. }
  1672. int diId = 0;
  1673. //添加时 默认加入团组汇率
  1674. if (dto.Status == 1) //添加
  1675. {
  1676. diId = groupData.Data;
  1677. //添加默认币种
  1678. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1679. //默认分配权限
  1680. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1681. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1682. var _managerIds = new List<int>() { 21, 22, 32 };
  1683. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1684. if (userIds.Count > 0)
  1685. {
  1686. userIds.Add(208);
  1687. //创建团组管控
  1688. GroupStepForDelegation.CreateWorkStep(diId);
  1689. //发送消息
  1690. string groupName = dto.TeamName;
  1691. string createGroupUser = string.Empty;
  1692. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1693. if (userInfo != null) createGroupUser = userInfo.CnName;
  1694. string title = $"系统通知";
  1695. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1696. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1697. }
  1698. #region 应用推送
  1699. try
  1700. {
  1701. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1702. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1703. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1704. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1705. {
  1706. var userList = new List<string>() { users.QiyeChatUserId };
  1707. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1708. }
  1709. }
  1710. catch (Exception ex)
  1711. {
  1712. }
  1713. #endregion
  1714. //默认创建倒推表
  1715. await _invertedListRep._Create(dto.UserId, diId);
  1716. //默认创建签证流程
  1717. await _visaProcessRep.Create(dto.UserId, diId);
  1718. //默认创建团组流程总览信息
  1719. await _processOverviewRep.ProcessInitAsync(diId, dto.UserId);
  1720. }
  1721. if (dto.Status == 2)
  1722. {
  1723. diId = dto.Id;
  1724. if (diId == 0)
  1725. {
  1726. //_sqlSugar.RollbackTran();
  1727. return Ok(JsonView(false, "修改失败! 未添加团组id" + groupData.Msg));
  1728. }
  1729. }
  1730. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1731. if (viewData.Code != 0)
  1732. {
  1733. //_sqlSugar.RollbackTran();
  1734. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1735. }
  1736. #region 团组操作默认添加/修改收款账单
  1737. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1738. {
  1739. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1740. .Where(x => x.IsDel == 0 &&
  1741. x.Diid == diId &&
  1742. x.Remark.Equals("预付款")
  1743. )
  1744. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1745. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1746. .FirstAsync();
  1747. ffrInfo = new Fin_ForeignReceivables()
  1748. {
  1749. Diid = diId,
  1750. PriceName = dto.ClientUnit,
  1751. Price = dto.PaymentMoney,
  1752. Count = 1,
  1753. Unit = $"元",
  1754. ItemSumPrice = dto.PaymentMoney,
  1755. Rate = 1.0000M,
  1756. Currency = 836,
  1757. AddingWay = 0,
  1758. CreateUserId = dto.UserId,
  1759. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1760. Remark = $"预付款"
  1761. };
  1762. if (ffrInfo == null) //Add
  1763. {
  1764. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1765. }
  1766. else //修改
  1767. {
  1768. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1769. .UpdateColumns(x => new
  1770. {
  1771. x.PriceName,
  1772. x.Price,
  1773. x.ItemSumPrice,
  1774. x.CreateTime,
  1775. x.CreateUserId
  1776. })
  1777. .WhereColumns(x => x.Id)
  1778. .ExecuteCommandAsync();
  1779. }
  1780. }
  1781. #endregion
  1782. #region 签证人员团组时间通知
  1783. #region 计算出访起止时间
  1784. var startTime = new DateTime();
  1785. var endTime = new DateTime();
  1786. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1787. {
  1788. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1789. }
  1790. #endregion
  1791. if (diId > 0)
  1792. {
  1793. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1794. }
  1795. #endregion
  1796. //_sqlSugar.CommitTran();
  1797. return Ok(JsonView(true, "添加成功"));
  1798. }
  1799. catch (Exception ex)
  1800. {
  1801. _sqlSugar.RollbackTran();
  1802. return Ok(JsonView(false, ex.Message));
  1803. }
  1804. }
  1805. /// <summary>
  1806. /// 接团流程操作(增改)
  1807. /// 安卓端使用 建团时添加客户名单
  1808. /// </summary>
  1809. /// <param name="dto"></param>
  1810. /// <returns></returns>
  1811. [HttpPost]
  1812. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1813. public async Task<IActionResult> GroupProcessOperation1(GroupProcessOperationDto dto)
  1814. {
  1815. #region 参数验证
  1816. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  1817. #region 页面操作权限验证
  1818. //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 104);
  1819. //if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "客户名单您没有添加权限!"));
  1820. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, 27);
  1821. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "团组操作您没有添加权限!"));
  1822. #endregion
  1823. #endregion
  1824. _sqlSugar.BeginTran();
  1825. decimal ffrPrice = 0.00M;
  1826. DateTime? visitDt = null;
  1827. if (dto.Status == 2)
  1828. {
  1829. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.Id && x.IsDel == 0);
  1830. if (groupInfo != null)
  1831. {
  1832. ffrPrice = groupInfo.PaymentMoney;
  1833. visitDt = groupInfo.VisitDate.AddDays(-groupInfo.PayDay);
  1834. }
  1835. }
  1836. var _dto = new GroupOperationDto();
  1837. _dto = _mapper.Map<GroupProcessOperationDto, GroupOperationDto>(dto);
  1838. var groupData = await _groupRepository.GroupOperation(_dto);
  1839. if (groupData.Code != 0)
  1840. {
  1841. _sqlSugar.RollbackTran();
  1842. return Ok(JsonView(false, "团组操作添加失败!" + groupData.Msg));
  1843. }
  1844. try
  1845. {
  1846. int diId = 0;
  1847. //添加时 默认加入团组汇率
  1848. if (dto.Status == 1) //添加
  1849. {
  1850. diId = groupData.Data;
  1851. //添加默认币种
  1852. await GeneralMethod.PostGroupRateAddInit(dto.UserId, diId);
  1853. //默认分配权限
  1854. await GeneralMethod.PostGroupAuthAddInit(dto.UserId, diId);
  1855. //消息提示 王鸽 主管号 2024-10-21 新增LZ UID
  1856. var _managerIds = new List<int>() { 21, 22, 32 };
  1857. var userIds = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && _managerIds.Contains(it.JobPostId)).Select(it => it.Id).ToList();
  1858. if (userIds.Count > 0)
  1859. {
  1860. userIds.Add(208);
  1861. //创建团组管控
  1862. GroupStepForDelegation.CreateWorkStep(diId);
  1863. //发送消息
  1864. string groupName = dto.TeamName;
  1865. string createGroupUser = string.Empty;
  1866. var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  1867. if (userInfo != null) createGroupUser = userInfo.CnName;
  1868. string title = $"系统通知";
  1869. string content = $"团组[{groupName}(创建人:{createGroupUser})]创建成功,请前往页面进行下一步操作!";
  1870. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  1871. }
  1872. #region 应用推送
  1873. try
  1874. {
  1875. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(diId, QiyeWeChatEnum.CompanyCRMChat);
  1876. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == dto.UserId).First();
  1877. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  1878. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  1879. {
  1880. var userList = new List<string>() { users.QiyeChatUserId };
  1881. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(diId, userList);
  1882. }
  1883. }
  1884. catch (Exception ex)
  1885. {
  1886. _sqlSugar.CommitTran();
  1887. return Ok(JsonView(true, "操作成功! 应用推送异常:" + groupData.Msg));
  1888. }
  1889. #endregion
  1890. //默认创建倒推表
  1891. await _invertedListRep._Create(dto.UserId, diId);
  1892. }
  1893. else if (dto.Status == 2)
  1894. {
  1895. diId = dto.Id;
  1896. if (diId == 0)
  1897. {
  1898. _sqlSugar.RollbackTran();
  1899. return Ok(JsonView(false, "操作失败! 未添加团组id" + groupData.Msg));
  1900. }
  1901. }
  1902. var viewData = await _tourClientListRep.OperMultiple(dto.TourClientListInfos, diId, dto.UserId);
  1903. if (viewData.Code != 0)
  1904. {
  1905. _sqlSugar.RollbackTran();
  1906. return Ok(JsonView(false, "客户名单添加失败!" + viewData.Msg));
  1907. }
  1908. #region 团组操作默认添加/修改收款账单
  1909. if (dto.PayDay > 0 && dto.PaymentMoney > 0)
  1910. {
  1911. var ffrInfo = await _sqlSugar.Queryable<Fin_ForeignReceivables>()
  1912. .Where(x => x.IsDel == 0 &&
  1913. x.Diid == diId &&
  1914. x.Remark.Equals("预付款")
  1915. )
  1916. .WhereIF(ffrPrice > 0, x => x.ItemSumPrice == ffrPrice)
  1917. .WhereIF(visitDt != null, x => x.CreateTime == visitDt)
  1918. .FirstAsync();
  1919. ffrInfo = new Fin_ForeignReceivables()
  1920. {
  1921. Diid = diId,
  1922. PriceName = dto.ClientUnit,
  1923. Price = dto.PaymentMoney,
  1924. Count = 1,
  1925. Unit = $"元",
  1926. ItemSumPrice = dto.PaymentMoney,
  1927. Rate = 1.0000M,
  1928. Currency = 836,
  1929. AddingWay = 0,
  1930. CreateUserId = dto.UserId,
  1931. CreateTime = Convert.ToDateTime(dto.VisitDate).AddDays(-dto.PayDay),
  1932. Remark = $"预付款"
  1933. };
  1934. if (ffrInfo == null) //Add
  1935. {
  1936. await _sqlSugar.Insertable(ffrInfo).ExecuteCommandAsync();
  1937. }
  1938. else //修改
  1939. {
  1940. await _sqlSugar.Updateable<Fin_ForeignReceivables>(ffrInfo)
  1941. .UpdateColumns(x => new
  1942. {
  1943. x.PriceName,
  1944. x.Price,
  1945. x.ItemSumPrice,
  1946. x.CreateTime,
  1947. x.CreateUserId
  1948. })
  1949. .WhereColumns(x => x.Id)
  1950. .ExecuteCommandAsync();
  1951. }
  1952. }
  1953. #endregion
  1954. #region 签证人员团组时间通知
  1955. #region 计算出访起止时间
  1956. var startTime = new DateTime();
  1957. var endTime = new DateTime();
  1958. if (DateTime.TryParse(dto.VisitDate, out startTime))
  1959. {
  1960. endTime = startTime.AddDays(dto.VisitDays - 1);//含当天
  1961. }
  1962. #endregion
  1963. if (diId > 0)
  1964. {
  1965. await AppNoticeLibrary.SendUserMsg_GroupTimeInfo_ToVisaUser(diId, startTime.ToString("yyyy-MM-dd"), endTime.ToString("yyyy-MM-dd"));
  1966. }
  1967. #endregion
  1968. _sqlSugar.CommitTran();
  1969. return Ok(JsonView(true));
  1970. }
  1971. catch (Exception ex)
  1972. {
  1973. _sqlSugar.RollbackTran();
  1974. return Ok(JsonView(false, ex.Message));
  1975. }
  1976. }
  1977. /// <summary>
  1978. /// 接团信息 操作(删除)
  1979. /// </summary>
  1980. /// <param name="dto"></param>
  1981. /// <returns></returns>
  1982. [HttpPost]
  1983. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  1984. public async Task<IActionResult> GroupDel(GroupDelDto dto)
  1985. {
  1986. var diId = dto.Id;
  1987. if (diId < 1) return Ok(JsonView(false, MsgTips.Id));
  1988. #region 删除 验证
  1989. /*
  1990. * 1、收款账单数据:0 条
  1991. * 2、收款退还数据:0 条
  1992. * 3、机票费用数据:0 条
  1993. * 4、签证费用数据:0 条
  1994. * 5、保险费用数据:0 条
  1995. * 6、酒店费用数据:0 条
  1996. * 7、公务出访数据:1 条
  1997. * 8、邀请公务活动费用数据:1 条
  1998. * 9、OP费用数据:5 条
  1999. * 10、其他费用数据:0 条
  2000. * 11、团组日付报销费用数据:0 条
  2001. *
  2002. * 温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!
  2003. */
  2004. //收款账单
  2005. int frCount = _sqlSugar.Queryable<Fin_ForeignReceivables>().Where(x => x.IsDel == 0 && x.Diid == diId).Count();
  2006. //收款退还
  2007. int fraomCount = _sqlSugar.Queryable<Fin_PaymentRefundAndOtherMoney>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2008. //机票费用
  2009. int arCount = _sqlSugar.Queryable<Grp_AirTicketReservations>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  2010. //签证费用
  2011. int viCount = _sqlSugar.Queryable<Grp_VisaInfo>().Where(x => x.IsDel == 0 && x.DIId == diId).Count();
  2012. //保险费用
  2013. int cCount = _sqlSugar.Queryable<Grp_Customers>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2014. //酒店费用
  2015. int hrCount = _sqlSugar.Queryable<Grp_HotelReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2016. //公务出访
  2017. int oaCount = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2018. //邀请公务活动费用
  2019. int ioaCount = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2020. //OP费用
  2021. int ctggrCount = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2022. //其他费用
  2023. int dpCount = _sqlSugar.Queryable<Grp_DecreasePayments>().Where(x => x.IsDel == 0 && x.DiId == diId).Count();
  2024. //团组日付报销费用
  2025. int dfpCount = _sqlSugar.Queryable<Fin_DailyFeePayment>().Where(x => x.IsDel == 0 && x.GroupId == diId).Count();
  2026. var feeCount = frCount + fraomCount + arCount + viCount + cCount + hrCount + oaCount + ioaCount + ctggrCount + dpCount + dfpCount;
  2027. if (feeCount > 0)
  2028. {
  2029. var delMsgTips = new StringBuilder();
  2030. delMsgTips.AppendLine($"1、收款账单数据:{frCount} 条");
  2031. delMsgTips.AppendLine($"2、收款退换数据:{fraomCount} 条");
  2032. delMsgTips.AppendLine($"3、机票费用数据:{arCount} 条");
  2033. delMsgTips.AppendLine($"4、签证费用数据:{viCount} 条");
  2034. delMsgTips.AppendLine($"5、保险费用数据:{cCount} 条");
  2035. delMsgTips.AppendLine($"6、酒店费用数据:{hrCount} 条");
  2036. delMsgTips.AppendLine($"7、公务出访数据:{oaCount} 条");
  2037. delMsgTips.AppendLine($"8、邀请公务活动费用数据:{ioaCount} 条");
  2038. delMsgTips.AppendLine($"9、OP费用数据:{ctggrCount} 条");
  2039. delMsgTips.AppendLine($"10、其他费用数据:{dpCount} 条");
  2040. delMsgTips.AppendLine($"11、团组日付报销费用数据:{dfpCount} 条");
  2041. delMsgTips.AppendLine($"");
  2042. delMsgTips.AppendLine($"温馨提示:该团组已产生费用,不允许删除;如需删除,请先删除对应版块费用,谢谢!");
  2043. return Ok(JsonView(false, delMsgTips.ToString()));
  2044. }
  2045. #endregion
  2046. var groupData = await _groupRepository.GroupDel(dto);
  2047. if (groupData.Code != 0)
  2048. {
  2049. return Ok(JsonView(false, groupData.Msg));
  2050. }
  2051. return Ok(JsonView(true));
  2052. }
  2053. /// <summary>
  2054. /// 获取团组销售报价号
  2055. /// 团组添加时 使用
  2056. /// </summary>
  2057. /// <returns></returns>
  2058. [HttpPost]
  2059. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2060. public async Task<IActionResult> GetGroupSalesQuoteNo()
  2061. {
  2062. var groupData = await _groupRepository.GetGroupSalesQuoteNo();
  2063. if (groupData.Code != 0)
  2064. {
  2065. return Ok(JsonView(false, groupData.Msg));
  2066. }
  2067. object salesQuoteNo = new
  2068. {
  2069. SalesQuoteNo = groupData.Data
  2070. };
  2071. return Ok(JsonView(salesQuoteNo));
  2072. }
  2073. /// <summary>
  2074. /// 设置确认出团
  2075. /// </summary>
  2076. /// <param name="dto"></param>
  2077. /// <returns></returns>
  2078. [HttpPost]
  2079. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2080. public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
  2081. {
  2082. var groupData = await _groupRepository.ConfirmationGroup(dto);
  2083. if (groupData.Code != 0)
  2084. {
  2085. return Ok(JsonView(false, groupData.Msg));
  2086. }
  2087. var groupInfo = _groupRepository.Query(s => s.Id == dto.GroupId).First();
  2088. #region OA消息推送
  2089. try
  2090. {
  2091. string groupName = groupInfo.TeamName;
  2092. var userIds = _airTicketResRep.Query<Sys_Users>(s => s.DepId == 7 && s.IsDel == 0).Select(x => x.Id).ToList();
  2093. string title = $"系统通知";
  2094. string content = $"团组[{groupName}]已确认出团!";
  2095. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, dto.GroupId);
  2096. }
  2097. catch (Exception ex)
  2098. {
  2099. }
  2100. #endregion
  2101. #region 应用推送
  2102. try
  2103. {
  2104. await AppNoticeLibrary.SendChatMsg_GroupStatus_Create(dto.GroupId, QiyeWeChatEnum.CompanyCRMChat);
  2105. Sys_Users users = _airTicketResRep.Query<Sys_Users>(s => s.Id == groupInfo.JietuanOperator).First();
  2106. Sys_Department department = _airTicketResRep.Query<Sys_Department>(s => s.Id == users.DepId).First();
  2107. if (department.Id == 6 && !string.IsNullOrEmpty(users.QiyeChatUserId))
  2108. {
  2109. var userList = new List<string>() { users.QiyeChatUserId };
  2110. await AppNoticeLibrary.SendUserMsg_GroupStatus_Create(dto.GroupId, userList);
  2111. }
  2112. }
  2113. catch (Exception ex)
  2114. {
  2115. }
  2116. #endregion
  2117. GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
  2118. return Ok(JsonView(true, "操作成功!", groupData.Data));
  2119. }
  2120. /// <summary>
  2121. /// 获取团组名称data And 签证国别Data
  2122. /// </summary>
  2123. /// <param name="dto"></param>
  2124. /// <returns></returns>
  2125. [HttpPost]
  2126. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2127. public async Task<IActionResult> GetGroupNameAndVisaNationality(GroupNameDto dto)
  2128. {
  2129. string sql = string.Format(@"Select Id,TeamName GroupName From Grp_DelegationInfo
  2130. Where TeamName != '' And IsDel = 0
  2131. Order By VisitDate Desc");
  2132. var groupNameList = await _sqlSugar.SqlQueryable<GroupNameView>(sql).ToListAsync();
  2133. var data = new
  2134. {
  2135. groupNameData = groupNameList,
  2136. visaNationalityData = _visaTypeInit.ToList()
  2137. };
  2138. return Ok(JsonView(data));
  2139. }
  2140. /// <summary>
  2141. /// 根据CTable类型返回对应的团组名称及简单数据(APP端)
  2142. /// </summary>
  2143. /// <returns></returns>
  2144. [HttpPost]
  2145. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2146. public async Task<IActionResult> PostGroupNameAndEasy(DecreasePaymentsDto dto)
  2147. {
  2148. try
  2149. {
  2150. Result groupData = await _decreasePaymentsRep.PostGroupNameAndEasy(dto);
  2151. if (groupData.Code != 0)
  2152. {
  2153. return Ok(JsonView(false, groupData.Msg));
  2154. }
  2155. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  2156. }
  2157. catch (Exception ex)
  2158. {
  2159. return Ok(JsonView(false, ex.Message));
  2160. throw;
  2161. }
  2162. }
  2163. /// <summary>
  2164. /// 团组清单 Excel
  2165. /// </summary>
  2166. /// <param name="beginDt">开始时间 EG:“2024-01-01”</param>
  2167. /// <param name="endDt">结束时间 EG;“2024-12-31”</param>
  2168. /// <returns></returns>
  2169. [HttpGet]
  2170. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2171. public async Task<IActionResult> GroupListFile([FromQuery] string beginDt, [FromQuery] string endDt)
  2172. {
  2173. bool beginBool = DateTime.TryParse($"{beginDt} 00:00:00", out DateTime _beginDt),
  2174. endBool = DateTime.TryParse($"{endDt} 23:59:59", out DateTime _endDt);
  2175. if (!beginBool && !endBool)
  2176. {
  2177. return Ok(JsonView(false, "开始或结束时间不正确!"));
  2178. }
  2179. string sql = string.Format(@"
  2180. SELECT
  2181. ROW_NUMBER,
  2182. Id,
  2183. SalesQuoteNo,
  2184. TourCode,
  2185. TeamTypeId,
  2186. TeamType,
  2187. TeamLevId,
  2188. TeamLev,
  2189. TeamName,
  2190. ClientName,
  2191. ClientUnit,
  2192. VisitDate,
  2193. VisitDays,
  2194. VisitPNumber,
  2195. JietuanOperatorId,
  2196. JietuanOperator,
  2197. IsSure,
  2198. CreateUserName,
  2199. IsBid
  2200. FROM
  2201. (
  2202. SELECT
  2203. ROW_NUMBER() OVER(
  2204. ORDER BY
  2205. gdi.VisitDate Desc
  2206. ) AS ROW_NUMBER,
  2207. gdi.Id,
  2208. SalesQuoteNo,
  2209. TourCode,
  2210. ssd.Id TeamTypeId,
  2211. ssd.Name TeamType,
  2212. ssd1.Id TeamLevId,
  2213. ssd1.Name TeamLev,
  2214. TeamName,
  2215. ClientName,
  2216. ClientUnit,
  2217. VisitDate,
  2218. VisitDays,
  2219. VisitPNumber,
  2220. JietuanOperator JietuanOperatorId,
  2221. su.CnName JietuanOperator,
  2222. IsSure,
  2223. gdi.CreateTime,
  2224. su1.CnName As CreateUserName,
  2225. gdi.IsBid
  2226. FROM
  2227. Grp_DelegationInfo gdi
  2228. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  2229. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  2230. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  2231. LEFT JOIN Sys_Users su1 ON gdi.CreateUserId = su1.Id
  2232. WHERE
  2233. gdi.IsDel = 0
  2234. AND gdi.IsBid = 0
  2235. AND gdi.VisitDate BETWEEN '{0}' AND '{1}'
  2236. ) temp", _beginDt.ToString("yyyy-MM-dd HH:mm:ss"), _endDt.ToString("yyyy-MM-dd HH:mm:ss"));
  2237. var groupList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
  2238. #region 处理所属部门
  2239. /*
  2240. * 1.sq 和 gyy 等显示 市场部
  2241. * 2.王鸽和主管及张总还有管理员号统一国交部
  2242. * 2-1. 4 管理员 ,21 张海麟
  2243. */
  2244. var userIds = groupList.Select(it => it.JietuanOperatorId).ToList();
  2245. var userIds1 = new List<int>() { 4, 21 };
  2246. var userDepDatas = await _sqlSugar.Queryable<Sys_Users>()
  2247. .LeftJoin<Sys_Department>((u, d) => u.DepId == d.Id)
  2248. .Where(u => u.IsDel == 0 && userIds.Contains(u.Id))
  2249. .Select((u, d) => new { UserId = u.Id, DepName = userIds1.Contains(u.Id) ? "国交部" : d.DepName })
  2250. .ToListAsync();
  2251. var droupIds = groupList.Select(it => it.Id).ToList();
  2252. var deleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  2253. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  2254. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  2255. .Where((tcl, dc, cc) => tcl.IsDel == 0 && droupIds.Contains(tcl.DiId))
  2256. .Select((tcl, dc, cc) => new ClientInfoInfo_Group
  2257. {
  2258. DiId = tcl.DiId,
  2259. LastName = dc.LastName,
  2260. FirstName = dc.FirstName,
  2261. Sex = dc.Sex,
  2262. Birthday = dc.BirthDay,
  2263. Company = cc.CompanyFullName,
  2264. Job = dc.Job,
  2265. CreateTime = tcl.CreateTime,
  2266. })
  2267. .ToList();
  2268. foreach (var item in groupList)
  2269. {
  2270. item.Department = userDepDatas.Find(it => item.JietuanOperatorId == it.UserId)?.DepName ?? "Unknown";
  2271. string groupFirstName = "";
  2272. var currDatas = deleClientList.Where(x => x.DiId == item.Id).ToList();
  2273. if (currDatas.Any())
  2274. {
  2275. groupFirstName = AesEncryptionHelper.Decrypt(currDatas[0].LastName) + AesEncryptionHelper.Decrypt(currDatas[0].FirstName);
  2276. }
  2277. item.GroupFirst = groupFirstName;
  2278. }
  2279. #endregion
  2280. #region Excel
  2281. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  2282. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  2283. var savePath = AppSettingsHelper.Get("GrpListFileBasePath");
  2284. var ftpPath = AppSettingsHelper.Get("GrpListFileFtpPath");
  2285. var fileName = $"团组清单({beginDt}~{endDt}){DateTime.Now:yyyyMMddHHmmss}.xlsx";
  2286. //载入模板
  2287. var designer = new WorkbookDesigner
  2288. {
  2289. Workbook = new Workbook($"{tempPath}团组清单模板.xlsx")
  2290. };
  2291. designer.SetDataSource("Titel", $"团组清单({beginDt}~{endDt})");
  2292. DataTable dt = CommonFun.GetDataTableFromIList<DelegationListView>(groupList); ;
  2293. dt.TableName = "GroupList";
  2294. designer.SetDataSource(dt);
  2295. designer.Process();
  2296. if (!Directory.Exists(savePath))
  2297. {
  2298. Directory.CreateDirectory(savePath);
  2299. }
  2300. string serverPath = $"{savePath}{fileName}";
  2301. designer.Workbook.Save(serverPath);
  2302. string rst = $"{servicePath}{ftpPath}{fileName}";
  2303. #endregion
  2304. return Ok(JsonView(true, "操作成功!", rst));
  2305. }
  2306. /// <summary>
  2307. /// 团组合同下载(1.付款80% 2.付全款)
  2308. /// </summary>
  2309. /// <param name="dto"></param>
  2310. /// <returns></returns>
  2311. /// <exception cref="Exception"></exception>
  2312. [HttpPost]
  2313. public async Task<IActionResult> DownGroupContractFile(DownGroupContractFileDto dto)
  2314. {
  2315. var jw = JsonView(false);
  2316. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  2317. .FirstAsync(x => x.Id == dto.GroupId && x.IsDel == 0);
  2318. if (di == null)
  2319. {
  2320. jw.Msg = "团组Id有误!";
  2321. return Ok(jw);
  2322. }
  2323. #region 权限校验
  2324. var allDownFile = new List<int>() { 21 };
  2325. try
  2326. {
  2327. var setting = _sqlSugar.Queryable<Sys_SetData>()
  2328. .First(x => x.Id == 1418 && x.IsDel == 0);
  2329. allDownFile.AddRange(JsonConvert.DeserializeObject<List<int>>(setting.Remark));
  2330. }
  2331. catch (Exception)
  2332. { }
  2333. var guojiaoDownFile = new List<int>() { 330, 383 };
  2334. var shichangDownFile = new List<int>() { 95 };
  2335. if (allDownFile.Contains(dto.UserId))
  2336. {
  2337. }
  2338. else if (guojiaoDownFile.Contains(dto.UserId))
  2339. {
  2340. var guojiaobuDi = new List<int>() { 4, 21 };
  2341. var departmentStr = _sqlSugar.Queryable<Sys_Department>()
  2342. .LeftJoin<Sys_Users>((d, u) => d.Id == u.DepId && u.IsDel == 0)
  2343. .Where((d, u) => u.Id == di.JietuanOperator)
  2344. .Select((d, u) => d.DepName)
  2345. .First();
  2346. if (!guojiaobuDi.Contains(di.JietuanOperator) && departmentStr != "策划部" && departmentStr != "国交部")
  2347. {
  2348. jw.Msg = "暂无下载权限!";
  2349. return Ok(jw);
  2350. }
  2351. }
  2352. else if (shichangDownFile.Contains(dto.UserId))
  2353. {
  2354. var dic = new Dictionary<int, int[]>()
  2355. {
  2356. { 95, new int []{ 95 , 337 , 302, 350, 355, 357, 353 , 359 , 361, 368, 364, 366, 369} }
  2357. };
  2358. try
  2359. {
  2360. var sqSetting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1417);
  2361. if (sqSetting != null)
  2362. {
  2363. Dictionary<int, int[]> result = JsonConvert.DeserializeObject<Dictionary<int, int[]>>(sqSetting.Remark);
  2364. foreach (var item in result.Keys)
  2365. {
  2366. if (dic.ContainsKey(item))
  2367. {
  2368. int[] dilatation = new int[dic[item].Length + result[item].Length];
  2369. Array.Copy(dic[item], dilatation, dic[item].Length);
  2370. Array.Copy(result[item], 0, dilatation, dic[item].Length, result[item].Length);
  2371. dic[item] = dilatation;
  2372. }
  2373. else
  2374. {
  2375. dic.Add(item, result[item]);
  2376. }
  2377. }
  2378. }
  2379. if (!dic[95].Contains(di.CreateUserId))
  2380. {
  2381. jw.Msg = "暂无下载权限!";
  2382. return Ok(jw);
  2383. }
  2384. }
  2385. catch (Exception)
  2386. { }
  2387. }
  2388. else if (dto.UserId == di.CreateUserId)
  2389. {
  2390. }
  2391. else
  2392. {
  2393. jw.Msg = "暂无下载权限!";
  2394. return Ok(jw);
  2395. }
  2396. #endregion
  2397. var blackCodeList = await _sqlSugar.Queryable<Air_TicketBlackCode>()
  2398. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  2399. .ToListAsync();
  2400. if (!blackCodeList.Any())
  2401. {
  2402. jw.Msg = "该团无机票行程代码!";
  2403. return Ok(jw);
  2404. }
  2405. var groupEnterExitCost = await _sqlSugar.Queryable<Grp_EnterExitCost>()
  2406. .FirstAsync(x => x.DiId == dto.GroupId && x.IsDel == 0);
  2407. if (groupEnterExitCost == null)
  2408. {
  2409. jw.Msg = "暂无三公费用信息!";
  2410. return Ok(jw);
  2411. }
  2412. var rateList = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(groupEnterExitCost.CurrencyRemark);
  2413. rateList ??= new List<CurrencyInfo>();
  2414. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == di.Id).ToList();
  2415. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  2416. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  2417. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  2418. .Where((x, a, b) => x.IsDel == 0 && x.Diid == di.Id)
  2419. .Select((x, a, b) => new
  2420. {
  2421. x.Index,
  2422. itemName = a.Name,
  2423. CurrencyStr = b.Name,
  2424. x.Cost,
  2425. x.SubTotal,
  2426. x.Remark
  2427. })
  2428. .OrderBy((x) => x.Index)
  2429. .ToList();
  2430. decimal stayFeeTotal = groupEnterExitCost.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  2431. decimal mealsFeeTotal = groupEnterExitCost.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  2432. decimal miscellaneousFeeTotal = groupEnterExitCost.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  2433. decimal tainFeeTotal = groupEnterExitCost.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  2434. decimal otherPriceTotal = groupEnterExitCost.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  2435. decimal insidePayTotal = groupEnterExitCost.ChoiceOne == 1 ? groupEnterExitCost.InsidePay : 0.00M;
  2436. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  2437. decimal subJJC = 0.00M,
  2438. subGWC = 0.00M,
  2439. subTDC = 0.00M;
  2440. //经济舱
  2441. if (groupEnterExitCost.SumJJC == 1)
  2442. {
  2443. subJJC = otherFeeTotal + groupEnterExitCost.OutsideJJPay;
  2444. }
  2445. //公务舱
  2446. if (groupEnterExitCost.SumGWC == 1)
  2447. {
  2448. subGWC = otherFeeTotal + groupEnterExitCost.OutsideGWPay;
  2449. }
  2450. //头等舱
  2451. if (groupEnterExitCost.SumTDC == 1)
  2452. {
  2453. subTDC = otherFeeTotal + groupEnterExitCost.OutsideTDPay;
  2454. }
  2455. var groupClints = await _sqlSugar.Queryable<Grp_TourClientList>()
  2456. .LeftJoin<Sys_SetData>((x, s) => s.Id == x.ShippingSpaceTypeId && s.IsDel == 0)
  2457. .LeftJoin<Crm_DeleClient>((x, s, dc) => x.ClientId == dc.Id && dc.IsDel == 0)
  2458. .LeftJoin<Crm_CustomerCompany>((x, s, dc, cc) => dc.CrmCompanyId == cc.Id && cc.IsDel == 0)
  2459. .Where((x, s, dc, cc) => x.DiId == dto.GroupId && x.IsDel == 0)
  2460. .Select((x, s, dc, cc) => new GroupClints
  2461. {
  2462. Id = x.Id,
  2463. Name = s.Name,
  2464. IsAccompany = x.IsAccompany,
  2465. CompanyFullName = cc.CompanyFullName
  2466. })
  2467. .ToListAsync();
  2468. groupClints.ForEach(x => x.CompanyFullName = AesEncryptionHelper.Decrypt(x.CompanyFullName));
  2469. //获取舱位人数
  2470. var cabinCount = groupClints.Where(x => x.IsAccompany != 2 && !x.CompanyFullName.Contains("泛美国际"))
  2471. .GroupBy(x => x.Name)
  2472. .Select(x => new { Cabin = x.Key, Count = x.Count() })
  2473. .ToList();
  2474. string cityPath = string.Empty;
  2475. string startCity = string.Empty;
  2476. string endCity = string.Empty;
  2477. foreach (var item in blackCodeList)
  2478. {
  2479. string city = GeneralMethod.GetGroupCityLine(item, "-");
  2480. cityPath += city + "\r\n";
  2481. if (item.Equals(blackCodeList.First()))
  2482. {
  2483. var sp = city.Split('-');
  2484. startCity = sp[0];
  2485. endCity = sp[^1];
  2486. }
  2487. }
  2488. di.VisitCountry = Regex.Replace(di.VisitCountry, @"[|-]", "、");
  2489. var bookMarkDic = new Dictionary<string, string>
  2490. {
  2491. { "ClientUnit", di.ClientUnit },
  2492. { "VisitCountry", di.VisitCountry },
  2493. { "VisitDate", di.VisitDate.ToString("yyyy年MM月dd日") },
  2494. { "VisitPNumber", di.VisitPNumber.ToString() },
  2495. { "CityPath", cityPath },
  2496. { "StartCity", startCity },
  2497. { "EndCity", endCity },
  2498. { "StayDays", $"{di.VisitDays}天{di.VisitDays - 1}晚" }
  2499. };
  2500. Document doc = null;
  2501. var percentage = 0.8M;
  2502. var fileNameadd = "预付";
  2503. if (dto.FileType == 1)
  2504. {
  2505. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同bookmarkFormat.doc");
  2506. }
  2507. else if (dto.FileType == 2)
  2508. {
  2509. doc = new Document($"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Template/团组合同全款无表格.doc");
  2510. percentage = 1;
  2511. fileNameadd = "全款";
  2512. }
  2513. else
  2514. {
  2515. throw new Exception("FileType有误!");
  2516. }
  2517. var builder = new DocumentBuilder(doc);
  2518. decimal totalPrice = 0.00M;
  2519. Table firstTable = (Table)doc.GetChild(NodeType.Table, 0, true);
  2520. if (firstTable != null)
  2521. {
  2522. // 遍历表格的行和单元格
  2523. foreach (Aspose.Words.Tables.Row row in firstTable.Rows)
  2524. {
  2525. for (int i = 0; i < row.Cells.Count; i++)
  2526. {
  2527. var cell = row.Cells[i];
  2528. // 读取单元格内容
  2529. string cellTextFirst = row.Cells[0].FirstParagraph.ToString(Aspose.Words.SaveFormat.Text).Trim();
  2530. if (cellTextFirst.Contains("舱位"))
  2531. {
  2532. break;
  2533. }
  2534. if (cellTextFirst == "经济舱" || cellTextFirst == "公务舱")
  2535. {
  2536. if (i == 2)
  2537. {
  2538. if (cellTextFirst == "经济舱")
  2539. {
  2540. // 设置单元格内容
  2541. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2542. cell.FirstParagraph.AppendChild(new Run(doc, subJJC.ToString())); // 添加
  2543. }
  2544. else
  2545. {
  2546. // 设置单元格内容
  2547. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2548. cell.FirstParagraph.AppendChild(new Run(doc, subGWC.ToString())); // 添加
  2549. }
  2550. }
  2551. if (i == 3)
  2552. {
  2553. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2554. if (count != null)
  2555. {
  2556. // 设置单元格内容
  2557. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2558. cell.FirstParagraph.AppendChild(new Run(doc, count.ToString())); // 添加
  2559. }
  2560. }
  2561. if (i == 4)
  2562. {
  2563. var rowPrice = 0.00M;
  2564. var count = cabinCount.Find(x => x.Cabin == cellTextFirst)?.Count;
  2565. count ??= 0;
  2566. if (cellTextFirst == "经济舱")
  2567. {
  2568. rowPrice = subJJC * (int)count;
  2569. }
  2570. else
  2571. {
  2572. rowPrice = subGWC * (int)count;
  2573. }
  2574. totalPrice += rowPrice;
  2575. // 设置单元格内容
  2576. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2577. cell.FirstParagraph.AppendChild(new Run(doc, rowPrice.ToString())); // 添加
  2578. }
  2579. }
  2580. }
  2581. }
  2582. }
  2583. bookMarkDic.Add("TotalPrice", (totalPrice).ToString("#0.00"));
  2584. bookMarkDic.Add("TotalPrice1", (totalPrice * percentage).ToString("#0.00"));
  2585. bookMarkDic.Add("TotalPriceChinese", decimal.Parse((totalPrice * percentage).ToString("#0.00")).ConvertCNYUpper());
  2586. //--合同表格部分
  2587. bookMarkDic.Add("TimeNowDate", DateTime.Now.ToString("yyyy年MM月dd日"));
  2588. bookMarkDic.Add("ClientUnit1", di.ClientUnit);
  2589. bookMarkDic.Add("VisitCountry1", di.VisitCountry);
  2590. bookMarkDic.Add("DayCount", di.VisitDays.ToString());
  2591. bookMarkDic.Add("VisitingArea", di.VisitDate.ToString("yyyy年MM月dd日") + "-" + di.VisitEndDate.ToString("yyyy年MM月dd日"));
  2592. bookMarkDic.Add("CityPath1", cityPath);
  2593. bookMarkDic.Add("CityPath2", cityPath);
  2594. Table contractTable = (Table)doc.GetChild(NodeType.Table, 1, true);
  2595. if (contractTable != null)
  2596. {
  2597. //数据源
  2598. var _DayAndCostsAndCity = _sqlSugar.Queryable<Grp_DayAndCost>()
  2599. .LeftJoin<Grp_NationalTravelFee>((it, y) => it.NationalTravelFeeId == y.Id && y.IsDel == 0)
  2600. .LeftJoin<Sys_SetData>((it, y, s) => s.IsDel == 0 && s.Id == it.Currency)
  2601. .Where((it, y, s) => it.IsDel == 0 && it.DiId == di.Id)
  2602. .Select((it, y, s) => new
  2603. {
  2604. it.Cost,
  2605. it.SubTotal,
  2606. it.Type,
  2607. y.Id,
  2608. y.City,
  2609. s.Name,
  2610. CurrencyCodeCn = s.Remark
  2611. })
  2612. .ToList()
  2613. .Select(x => new
  2614. {
  2615. CurrencyCode = x.Name,
  2616. CityId = x.Id,
  2617. x.City,
  2618. di.VisitPNumber,
  2619. x.Type,
  2620. x.Cost,
  2621. x.SubTotal,
  2622. rateList.Find(y => y.CurrencyCode == x.Name)?.Rate,
  2623. x.CurrencyCodeCn,
  2624. });
  2625. var dac1 = _DayAndCostsAndCity.Where(it => it.Type == 1).GroupBy(x => x.CityId).ToList(); //住宿费
  2626. var dac2 = _DayAndCostsAndCity.Where(it => it.Type == 2).GroupBy(x => x.CityId).ToList(); //伙食费
  2627. var dac3 = _DayAndCostsAndCity.Where(it => it.Type == 3).GroupBy(x => x.CityId).ToList(); //公杂费
  2628. var dac4 = _DayAndCostsAndCity.Where(it => it.Type == 4).GroupBy(x => x.CityId).ToList(); //培训费
  2629. var tableSettings = new List<tableSetting>()
  2630. {
  2631. new(){ Index = 1 , Property = "City"},
  2632. new(){ Index = 2 , Property = "CurrencyCodeCn"},
  2633. new(){ Index = 3 , Property = "Cost"},
  2634. new(){ Index = 4 , Property = "VisitPNumber"},
  2635. //new tableSetting{ Index = 5 , Property = ""},
  2636. //new tableSetting{ Index = 6 , Property = ""},
  2637. new(){ Index = 7 , Property = "Rate"},
  2638. //new tableSetting{ Index = 8 , Property = ""},
  2639. };
  2640. //1.住宿费
  2641. int cloneRow = 8;
  2642. int startDayPrice = 8; //写入index
  2643. decimal ZSPriceSum = 0.00M, HSPriceSum = 0.00M, GZPriceSum = 0.00M;
  2644. foreach (var dac in dac1)
  2645. {
  2646. var first = dac.First();
  2647. var dayCount = dac.Count();
  2648. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2649. for (int i = 1; i < row.Cells.Count; i++)
  2650. {
  2651. var cell = row.Cells[i];
  2652. var findProperty = tableSettings.Find(x => x.Index == i);
  2653. if (findProperty != null)
  2654. {
  2655. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2656. // 设置单元格内容
  2657. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2658. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2659. }
  2660. else
  2661. {
  2662. switch (i)
  2663. {
  2664. case 5:
  2665. cell.FirstParagraph.Runs.Clear();
  2666. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2667. break;
  2668. case 6:
  2669. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2670. cell.FirstParagraph.Runs.Clear();
  2671. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2672. break;
  2673. case 8:
  2674. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2675. cell.FirstParagraph.Runs.Clear();
  2676. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2677. ZSPriceSum += xiaojiRMB;
  2678. break;
  2679. default:
  2680. break;
  2681. }
  2682. }
  2683. }
  2684. startDayPrice++;
  2685. if (!dac1.Last().Equals(dac))
  2686. {
  2687. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2688. // 将克隆的行追加到原行后面
  2689. contractTable.Rows.Insert(startDayPrice, newRow);
  2690. }
  2691. else
  2692. {
  2693. cloneRow += dac1.Count + 1;
  2694. startDayPrice = cloneRow;
  2695. }
  2696. }
  2697. //2.伙食费
  2698. foreach (var dac in dac2)
  2699. {
  2700. var first = dac.First();
  2701. var dayCount = dac.Count();
  2702. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2703. for (int i = 1; i < row.Cells.Count; i++)
  2704. {
  2705. var cell = row.Cells[i];
  2706. var findProperty = tableSettings.Find(x => x.Index == i);
  2707. if (findProperty != null)
  2708. {
  2709. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2710. // 设置单元格内容
  2711. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2712. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2713. }
  2714. else
  2715. {
  2716. switch (i)
  2717. {
  2718. case 5:
  2719. cell.FirstParagraph.Runs.Clear();
  2720. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2721. break;
  2722. case 6:
  2723. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2724. cell.FirstParagraph.Runs.Clear();
  2725. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2726. break;
  2727. case 8:
  2728. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2729. cell.FirstParagraph.Runs.Clear();
  2730. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2731. HSPriceSum += xiaojiRMB;
  2732. break;
  2733. default:
  2734. break;
  2735. }
  2736. }
  2737. }
  2738. startDayPrice++;
  2739. if (!dac2.Last().Equals(dac))
  2740. {
  2741. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2742. // 将克隆的行追加到原行后面
  2743. contractTable.Rows.Insert(startDayPrice, newRow);
  2744. }
  2745. else
  2746. {
  2747. cloneRow += dac2.Count + 1;
  2748. startDayPrice = cloneRow;
  2749. }
  2750. }
  2751. //3.公杂费
  2752. foreach (var dac in dac3)
  2753. {
  2754. var first = dac.First();
  2755. var dayCount = dac.Count();
  2756. Aspose.Words.Tables.Row row = contractTable.Rows[startDayPrice];
  2757. for (int i = 1; i < row.Cells.Count; i++)
  2758. {
  2759. var cell = row.Cells[i];
  2760. var findProperty = tableSettings.Find(x => x.Index == i);
  2761. if (findProperty != null)
  2762. {
  2763. string value = first.GetType().GetProperty(findProperty.Property).GetValue(first).ToString();
  2764. // 设置单元格内容
  2765. cell.FirstParagraph.Runs.Clear(); // 清除原有内容
  2766. cell.FirstParagraph.AppendChild(new Run(doc, value)); // 添加
  2767. }
  2768. else
  2769. {
  2770. switch (i)
  2771. {
  2772. case 5:
  2773. cell.FirstParagraph.Runs.Clear();
  2774. cell.FirstParagraph.AppendChild(new Run(doc, dayCount.ToString()));
  2775. break;
  2776. case 6:
  2777. var xiaoji = dayCount * first.VisitPNumber * first.Cost;
  2778. cell.FirstParagraph.Runs.Clear();
  2779. cell.FirstParagraph.AppendChild(new Run(doc, xiaoji.ToString("F2")));
  2780. break;
  2781. case 8:
  2782. var xiaojiRMB = dayCount * first.VisitPNumber * first.SubTotal;
  2783. cell.FirstParagraph.Runs.Clear();
  2784. cell.FirstParagraph.AppendChild(new Run(doc, xiaojiRMB.ToString("F2")));
  2785. GZPriceSum += xiaojiRMB;
  2786. break;
  2787. default:
  2788. break;
  2789. }
  2790. }
  2791. }
  2792. startDayPrice++;
  2793. if (!dac3.Last().Equals(dac))
  2794. {
  2795. Aspose.Words.Tables.Row newRow = (Aspose.Words.Tables.Row)contractTable.Rows[cloneRow].Clone(true);
  2796. // 将克隆的行追加到原行后面
  2797. contractTable.Rows.Insert(startDayPrice, newRow);
  2798. }
  2799. else
  2800. {
  2801. cloneRow += dac3.Count + 1;
  2802. startDayPrice = cloneRow;
  2803. }
  2804. }
  2805. //合并单元格
  2806. for (int i = 8; i < contractTable.Rows.Count - 1; i++)
  2807. {
  2808. var currentRow = contractTable.Rows[i];
  2809. var nextRow = contractTable.Rows[i + 1];
  2810. // 获取当前行和下一行的第一个单元格
  2811. Cell currentCell = currentRow.Cells[0];
  2812. Cell nextCell = nextRow.Cells[0];
  2813. // 检查单元格内容是否一致(去除尾部的换行符)
  2814. string currentText = currentCell.GetText().Trim();
  2815. string nextText = nextCell.GetText().Trim();
  2816. if (currentText == nextText)
  2817. {
  2818. // 如果当前单元格已经被合并,找到合并的起始单元格
  2819. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2820. {
  2821. // 找到合并的起始单元格
  2822. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2823. // 将下一行的单元格设置为合并的后续单元格
  2824. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2825. }
  2826. else
  2827. {
  2828. // 如果当前单元格是合并的起始单元格
  2829. currentCell.CellFormat.VerticalMerge = CellMerge.First;
  2830. // 将下一行的单元格设置为合并的后续单元格
  2831. nextCell.CellFormat.VerticalMerge = CellMerge.Previous;
  2832. }
  2833. }
  2834. else
  2835. {
  2836. // 如果内容不一致,重置当前单元格的合并属性
  2837. if (currentCell.CellFormat.VerticalMerge == CellMerge.Previous)
  2838. {
  2839. // 如果当前单元格是合并的后续单元格,找到合并的起始单元格并重置
  2840. int mergeStartIndex = FindMergeStartRowIndex(contractTable, i);
  2841. contractTable.Rows[mergeStartIndex].Cells[0].CellFormat.VerticalMerge = CellMerge.First;
  2842. }
  2843. else
  2844. {
  2845. currentCell.CellFormat.VerticalMerge = CellMerge.None;
  2846. }
  2847. }
  2848. }
  2849. bookMarkDic.Add("ZSPriceSum", ZSPriceSum.ToString("F2"));
  2850. bookMarkDic.Add("HSPriceSum", HSPriceSum.ToString("F2"));
  2851. bookMarkDic.Add("GZPriceSum", GZPriceSum.ToString("F2"));
  2852. }
  2853. foreach (var bookmarkName in bookMarkDic.Keys)
  2854. {
  2855. Bookmark bookmark = doc.Range.Bookmarks[bookmarkName];
  2856. if (bookmark != null)
  2857. {
  2858. if (bookmarkName == "ClientUnit")
  2859. {
  2860. // 移动到书签位置
  2861. builder.MoveTo(bookmark.BookmarkStart);
  2862. // 设置字体样式为下划线
  2863. builder.Font.Underline = Aspose.Words.Underline.Single;
  2864. // 插入书签值
  2865. builder.Write(bookMarkDic[bookmarkName]);
  2866. // 清除字体格式,避免影响后续文本
  2867. builder.Font.ClearFormatting();
  2868. }
  2869. else
  2870. {
  2871. builder.MoveToBookmark(bookmarkName);
  2872. builder.Write(bookMarkDic[bookmarkName]);
  2873. }
  2874. }
  2875. }
  2876. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupContractFile/Export/{di.TeamName}_{fileNameadd}版本合同文件.doc";
  2877. doc.Save(savePaht);
  2878. jw.Msg = "生成成功!";
  2879. jw.Code = 200;
  2880. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  2881. return Ok(jw);
  2882. }
  2883. static int FindMergeStartRowIndex(Table table, int rowIndex)
  2884. {
  2885. int index = rowIndex;
  2886. while (index > 0 && table.Rows[index].Cells[0].CellFormat.VerticalMerge == CellMerge.Previous)
  2887. {
  2888. index--;
  2889. }
  2890. return index;
  2891. }
  2892. /// <summary>
  2893. /// 报批完成企微通知
  2894. /// </summary>
  2895. /// <param name="dto"></param>
  2896. /// <returns></returns>
  2897. [HttpPost]
  2898. public async Task<IActionResult> EnterpriseWeChatNotificationAsyncBaoPi(EnterpriseWeChatNotificationAsyncBaoPiDto dto)
  2899. {
  2900. int currUserId = dto.currUserId;
  2901. int diid = dto.diid;
  2902. var jw = JsonView(true);
  2903. var users = new List<string>();
  2904. var ssd = _sqlSugar.Queryable<Sys_SetData>()
  2905. .First(x => x.Id == 1460);
  2906. try
  2907. {
  2908. users = JsonConvert.DeserializeObject<List<string>>(ssd.Remark);
  2909. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(dto.diid);
  2910. //添加分配人员
  2911. // 79 车/导游地接
  2912. // 80 签证
  2913. // 81 邀请/公务活动
  2914. var setdataids = new List<int>() { 79, 81 };
  2915. foreach (var groupModule in groupModuleOperators)
  2916. {
  2917. if (setdataids.Contains(groupModule.CTableId))
  2918. {
  2919. users.AddRange(groupModule.OperationUsers.Select(x => x.UserId.ToString()));
  2920. }
  2921. }
  2922. var res = await AppNoticeLibrary.SendUserMsg_BaoPi_ToUser(users, diid);
  2923. //消息通知成功 更改团组step、记录日志
  2924. if (res)
  2925. {
  2926. var groupStep = 0; //0-新建 1-企微消息通知
  2927. //更改团组step
  2928. var updStatus = await _sqlSugar.Updateable<Grp_DelegationInfo>()
  2929. .SetColumns(x => new Grp_DelegationInfo()
  2930. {
  2931. Step = 2,
  2932. StepOperationTime = DateTime.Now
  2933. })
  2934. .Where(x => x.Id == diid && x.IsDel == 0)
  2935. .ExecuteCommandAsync();
  2936. if (updStatus > 0) groupStep = 2;
  2937. string groupStepLabel = groupStep switch
  2938. {
  2939. 1 => "新建",
  2940. 2 => "企微消息通知(报批)",
  2941. _ => "未设置"
  2942. };
  2943. //记录日志
  2944. var teamName = _sqlSugar.Queryable<Grp_DelegationInfo>()
  2945. .Where(x => x.Id == diid && x.IsDel == 0)
  2946. .Select(x => x.TeamName)
  2947. .First() ?? "-";
  2948. var operationName = _sqlSugar.Queryable<Sys_Users>()
  2949. .Where(x => x.Id == currUserId && x.IsDel == 0)
  2950. .Select(x => x.CnName)
  2951. .First() ?? "-";
  2952. _groupTextLogger.LogInformation("团组:【{teamName}({groupId})】 操作人:【{operationName}】 操作时间:【{operationTime}】{logContent}", teamName, diid, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), groupStepLabel);
  2953. //设置 签证流程初始值
  2954. await _visaProcessRep.UpdateBatchTop4Step(dto.diid, dto.currUserId);
  2955. }
  2956. }
  2957. catch (Exception ex)
  2958. {
  2959. return Ok(JsonView(false, ex.Message));
  2960. }
  2961. return Ok(jw);
  2962. }
  2963. #endregion
  2964. #region 团组&签证
  2965. #region 团组&签证 New
  2966. /// <summary>
  2967. /// 团组&签证 New
  2968. /// DeepSeek API:测试API连通性
  2969. /// </summary>
  2970. /// <param name="file">请求dto</param>
  2971. /// <returns></returns>
  2972. [HttpPost]
  2973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2974. public async Task<IActionResult> TestDeepSeekApiConnectivityAsync()
  2975. {
  2976. return Ok(JsonView(await _deepSeekService.TestApiConnectivityAsync()));
  2977. }
  2978. /// <summary>
  2979. /// 团组&签证 New
  2980. /// DeepSeek API:检查可用端点
  2981. /// </summary>
  2982. /// <param name="file">请求dto</param>
  2983. /// <returns></returns>
  2984. [HttpPost]
  2985. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  2986. public async Task<IActionResult> DiscoverAvailableEndpointsAsync()
  2987. {
  2988. return Ok(JsonView(await _deepSeekService.DiscoverAvailableEndpointsAsync()));
  2989. }
  2990. /// <summary>
  2991. /// 团组&签证 New
  2992. /// 上传签证文件(客户填写签证文件),新增或更新 签证信息
  2993. /// </summary>
  2994. /// <param name="visaFile">文件</param>
  2995. /// <param name="fileTypeId">
  2996. /// 1. 澳新签证个人申请表
  2997. /// 2. 出国个人申请表
  2998. /// 3. 美国签证个人申请表格
  2999. /// 4. 沙特个人信息表格
  3000. /// 5. 申根签证个人资料表
  3001. /// 6. 中文个人简历模板
  3002. /// </param>
  3003. /// <returns></returns>
  3004. [HttpPost]
  3005. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3006. public async Task<IActionResult> VisaFileUploadAndUpdate(IFormFile visaFile, int fileTypeId)
  3007. {
  3008. //文件验证
  3009. if (visaFile.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  3010. //var visaFiles = new VisaUploadFileTypeView();
  3011. //var filetypes = VisaUploadFileTypeView.GetVisaUploadFileTypeViewItemInit();
  3012. //if (!filetypes.Any(x => x.FileId == fileTypeId)) return Ok(JsonView(false, "请选择文件类型!"));
  3013. //服务器存储文件
  3014. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Uploads";
  3015. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  3016. var filePath = Path.Combine(fileServerPath, visaFile.FileName);
  3017. using (var stream = new FileStream(filePath, FileMode.Create))
  3018. {
  3019. await visaFile.CopyToAsync(stream);
  3020. }
  3021. //日志记录-上传文件
  3022. _logger.LogInformation("【签证上传文件操作信息】签证文件存储成功!路径:{fileServerPath} 文件名称:{fileName}", fileServerPath, visaFile.FileName);
  3023. #region 上传文件到DeepSeekAPI
  3024. //IFormFile localFile = null;
  3025. ////获取项目中的cs文件
  3026. //try
  3027. //{
  3028. // _logger.LogInformation("读取并上传项目文件请求");
  3029. // // 1. 读取项目文件
  3030. // var readResponse = await _deepSeekService.ReadProjectFilesAsync(new List<string>() { @"OASystem.Domain\ViewModels\VisaFormDetails\AusNewVisaApplicationForm.cs" });
  3031. // if (readResponse.SuccessCount == 0)
  3032. // {
  3033. // return Ok(JsonView(false, "读取项目文件失败"));
  3034. // }
  3035. // localFile = readResponse.FileInfos.FirstOrDefault().FormFile;
  3036. //}
  3037. //catch (Exception ex)
  3038. //{
  3039. // _logger.LogError(ex, "读取项目文件失败");
  3040. // return Ok(JsonView(false, "读取项目文件失败"));
  3041. //}
  3042. //if (localFile == null)
  3043. //{
  3044. // return Ok(JsonView(false, "读取项目文件失败"));
  3045. //}
  3046. //var fileReq = new DeepSeekFileUploadRequest()
  3047. //{
  3048. // Files = new List<IFormFile> { localFile, visaFile },
  3049. //};
  3050. //var filesResult = new List<FileUploadResult>();
  3051. //try
  3052. //{
  3053. // _logger.LogInformation("开始上传 {FileCount} 个文件到DeepSeek API", fileReq.Files.Count);
  3054. // filesResult = await _deepSeekService.UploadFilesAsync(fileReq.Files, fileReq.Purpose);
  3055. // // 需要等待处理完成
  3056. // if (fileReq.WaitForProcessing)
  3057. // {
  3058. // foreach (var result in filesResult)
  3059. // {
  3060. // if (result.Success)
  3061. // {
  3062. // try
  3063. // {
  3064. // var processedFile = await _deepSeekService.WaitForFileProcessingAsync(result.FileId);
  3065. // result.Status = processedFile.Status;
  3066. // }
  3067. // catch (Exception ex)
  3068. // {
  3069. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  3070. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  3071. // }
  3072. // }
  3073. // }
  3074. // }
  3075. //}
  3076. //catch (Exception ex)
  3077. //{
  3078. // _logger.LogError(ex, "DeepSeek API文件上传失败");
  3079. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败: {ex.Message}"));
  3080. //}
  3081. //#endregion
  3082. //if (filesResult == null || filesResult.Count < 1)
  3083. //{
  3084. // return Ok(JsonView(false, $"DeepSeek API文件上传处理失败"));
  3085. //}
  3086. ////
  3087. //try
  3088. //{
  3089. // var fileIds = filesResult.Where(x => x.Success).Select(x => x.FileId).ToList();
  3090. // _logger.LogInformation("使用 {FileCount} 个文件进行聊天", fileIds.Count);
  3091. // string question = string.Format("将上传的文件内容按照识别为JSON格式,并按照 AusNewVisaApplicationForm 指定的实体类结构进行映射。确保字段和值对应、文档中数据的完整性、复选框选择打勾后的文本。第一项从不识别\"比如美国(2024年7月29日)\"相关文字。");
  3092. // var response = await _deepSeekService.ChatWithFilesAsync(fileIds, question);
  3093. // return Ok(response);
  3094. //}
  3095. //catch (Exception ex)
  3096. //{
  3097. // _logger.LogError(ex, "使用文件聊天失败");
  3098. // return Ok(JsonView(false, $"聊天失败: {ex.Message}"));
  3099. //}
  3100. #endregion
  3101. #region kimi API
  3102. //加载文件OpCarTouristGuideGroundContent
  3103. //kimi AI 识别文档返回json结果
  3104. int kimiAI_API_Index = 0; //KIMI-AI-API 访问计次
  3105. var KiMiApi = new KiMiApiClient();
  3106. var files = new List<IFormFile>() { visaFile };
  3107. var seedConter = await KiMiApi.UploadFilesAsync(files);
  3108. if (seedConter.Count == 0) return Ok(JsonView(false, "Kimi AI 文件上传结果为空!"));
  3109. //var seedMessage = filetypes.Where(x => x.FileId == fileTypeId).FirstOrDefault()?.KimiAITips;
  3110. var seedMessage = string.Format(@"你是领事馆电子材料审核员,只关注 Word 里的表格,正文、页眉页脚、水印、批注全部忽略。
  3111. 任务:把表格里的每个可填字段转换成“标题:值”的键值对,标题用原文,值用原文,不翻译。
  3112. 规则如下:
  3113. 1. 行列对齐:先按视觉补齐所有合并单元格——纵向合并则重复上方单元格内容,横向合并则留空字符串;无线表按对齐虚拟列线。
  3114. 2. 单格内出现多个“□”时,把被勾选(☑、√、×、■)的选项原文输出;若没有任何勾选,该字段输出 null。
  3115. 3. 所有日期统一转 yyyy-mm-dd,原格式“1990年1月1日”→1990-01-01;若缺日/月,用-01补位。
  3116. 4. 电话、传真、手机号:输出连续数字,遇到“(0 )”或“-”一律删除,只保留 7~15 位数字;若缺区号,原样保留。
  3117. 5. 金额:保留原数字,如“3000”。
  3118. 6. 地址:省、市、区、街道、门牌、邮编用空格分隔,不省略。
  3119. 7. 若同一张表出现“现住址”“家庭地址”“单位地址”等多列,依次编号 address_home / address_unit / address_legal。
  3120. 8. 输出顺序:按表格从左到右、从上到下逐行扫描,字段名重复时加序号,如 child_name_1、child_name_2。
  3121. 9. 结果格式:每行一个键值对,字段名与值之间用英文冒号+空格分隔,不要表格 Markdown,不要多余说明。
  3122. 10. 文件命名空间:每份表的最前面加一行 filename 作为起始标记(例:出国个人申请表.doc)。
  3123. 11. 内容为空的字段,显示标题,记空值。
  3124. 12. 只返回json结果,不需要其他内容;json内容去掉换行。");
  3125. var messages = new List<SeedMessages>
  3126. {
  3127. new() { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长识别文件为Json格式的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  3128. new() { Role = KimiRole.user, Content = seedMessage }
  3129. };
  3130. messages.InsertRange(1, seedConter);
  3131. string jsonString = string.Empty;
  3132. object jsonData = null;
  3133. bool isJson = false; // 是否是json格式 不是json格式继续访问AI
  3134. while (!isJson)
  3135. {
  3136. kimiAI_API_Index++;
  3137. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  3138. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  3139. jsonString += kimiApiResult_JObject["content"].ToString();
  3140. string startStr = "```json", endStr = "```";
  3141. // 判断并清除开头部分
  3142. if (jsonString.StartsWith(startStr))
  3143. {
  3144. jsonString = jsonString.Replace(startStr, "");
  3145. }
  3146. // 判断并清除结尾部分
  3147. if (jsonString.EndsWith(endStr))
  3148. {
  3149. jsonString = jsonString.Replace(endStr, "");
  3150. }
  3151. //验证json格式是否正确
  3152. try
  3153. {
  3154. jsonData = JsonDocument.Parse(jsonString);
  3155. isJson = true; // 如果解析成功,则是json格式
  3156. }
  3157. catch (Exception)
  3158. {
  3159. //messages = new List<SeedMessages>() { new() { Role = KimiRole.user, Content = "接着说" } };
  3160. messages.Add(new() { Role = KimiRole.user, Content = "接着上一个话题继续完成未完成的内容。" });
  3161. }
  3162. }
  3163. if (jsonData == null)
  3164. {
  3165. return Ok(JsonView(false, "kimi识别json转换失败。"));
  3166. }
  3167. var visaDetails = new VisaDetailsView();
  3168. //按照表格类型分别进行参数处理
  3169. // 1. 澳新签证个人申请表
  3170. // 2. 出国个人申请表
  3171. // 3. 美国签证个人申请表格
  3172. // 4. 沙特个人信息表格
  3173. // 5. 申根签证个人资料表
  3174. // 6. 中文个人简历模板
  3175. switch (fileTypeId)
  3176. {
  3177. //澳新签证个人申请表
  3178. case 1:
  3179. _logger.LogInformation("【签证上传文件操作信息】【澳新签证个人申请表】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3180. VisaApplication resInfo = System.Text.Json.JsonSerializer.Deserialize<VisaApplication>(jsonString);
  3181. break;
  3182. //美国签证个人申请表格
  3183. case 3:
  3184. _logger.LogInformation("【签证上传文件操作信息】【美国签证个人申请表格】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3185. string name = (string)jsonData.GetType().GetProperty("姓名")!.GetValue(jsonData)!;
  3186. string passportNo = (string)jsonData.GetType().GetProperty("护照号码")!.GetValue(jsonData)!;
  3187. string passportPlace = (string)jsonData.GetType().GetProperty("护照签发地")!.GetValue(jsonData)!;
  3188. string idNo = (string)jsonData.GetType().GetProperty("身份证号码")!.GetValue(jsonData)!;
  3189. string maritalStatusText = (string)jsonData.GetType().GetProperty("婚姻状况")!.GetValue(jsonData)!;
  3190. int maritalStatus = maritalStatusText switch
  3191. {
  3192. "未设置" => 0,
  3193. "未婚" => 1,
  3194. "已婚" => 2,
  3195. "离异" => 3,
  3196. "丧偶" => 4,
  3197. _ => -1
  3198. };
  3199. string birthDay = (string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!;
  3200. DateTime.TryParse(birthDay, out DateTime birthDayDt);
  3201. string birthPlace = (string)jsonData.GetType().GetProperty("出生地点")!.GetValue(jsonData)!;
  3202. var birthDay1 = CommonFun.SplitProvinceCity(birthPlace);
  3203. string birthDay_mate = (string)jsonData.GetType().GetProperty("配偶出生日期")!.GetValue(jsonData)!;
  3204. DateTime.TryParse(birthDay_mate, out DateTime birthDayDt_mate);
  3205. string birthPlace_mate = (string)jsonData.GetType().GetProperty("配偶出生地")!.GetValue(jsonData)!;
  3206. var birthDay1_mate = CommonFun.SplitProvinceCity(birthPlace_mate);
  3207. var addressText = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3208. var address = SplitAddressZip(addressText);
  3209. //美国驾照信息
  3210. string driveText = (string)jsonData.GetType().GetProperty("是否有美国驾照")!.GetValue(jsonData)!;
  3211. var driveInfo = LicenseParser(driveText);
  3212. //美国社会安全号或者纳税ID号
  3213. string ssnText = (string)jsonData.GetType().GetProperty("是否有美国社会安全号或者纳税ID号")!.GetValue(jsonData)!;
  3214. //单位信息
  3215. string clientName = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校")!.GetValue(jsonData)!;
  3216. string clientAddr = (string)jsonData.GetType().GetProperty("目前就职单位或就读学校地址")!.GetValue(jsonData)!;//
  3217. var (hasSsnItin, number) = SsnItinParser(ssnText);
  3218. //婚姻相关
  3219. var WeddingText = (string)jsonData.GetType().GetProperty("若离婚,婚姻起止时间")!.GetValue(jsonData)!;
  3220. var (f, t) = WeddingParser(WeddingText);
  3221. //美国联系人电话和邮箱
  3222. var peText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  3223. var usa_phone = Regex.Match(peText ?? "", @"[\d-]+").Value; // 数字和中横线
  3224. var usa_email = Regex.Match(peText ?? "", @"[^@\s]+@[^@\s]+\.[^@\s]+").Value;
  3225. //赴美时间、停留时间处理
  3226. var usa_dateText = (string)jsonData.GetType().GetProperty("联系人电话及邮箱")!.GetValue(jsonData)!;
  3227. var (usa_d, usa_days) = TravelParser(usa_dateText);
  3228. //赴美同行人
  3229. string usaCmpNameText = (string)jsonData.GetType().GetProperty("赴美同行人")!.GetValue(jsonData)!;
  3230. string usaCmpName = string.Empty;
  3231. if (usaCmpNameText.Contains("是"))
  3232. {
  3233. var usaCmpNameTextSplit = usaCmpNameText.Replace(":", "-").Replace("", "-").Split("-");
  3234. if (usaCmpNameTextSplit.Length > 1)
  3235. {
  3236. usaCmpName = usaCmpNameTextSplit[1];
  3237. }
  3238. }
  3239. //是否丢失过护照
  3240. string loseCodeText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  3241. string loseCode = string.Empty;
  3242. if (loseCodeText.Contains("是"))
  3243. {
  3244. var loseCodeTextSplit = loseCodeText.Replace(":", "-").Replace("", "-").Split("-");
  3245. if (loseCodeTextSplit.Length > 1)
  3246. {
  3247. usaCmpName = loseCodeTextSplit[1];
  3248. }
  3249. }
  3250. //是否获得过美国签证
  3251. string usaVisaText = (string)jsonData.GetType().GetProperty("是否丢失过护照")!.GetValue(jsonData)!;
  3252. string usaVisaDateText = (string)jsonData.GetType().GetProperty("获得日期")!.GetValue(jsonData)!;
  3253. //DateTime usaVisaDate;
  3254. if (!string.IsNullOrEmpty(usaVisaDateText))
  3255. {
  3256. if (DateTime.TryParse(usaVisaDateText, out DateTime usaVisaDate))
  3257. {
  3258. visaDetails.ClientInfo.GetUSAVisaDate = usaVisaDate;
  3259. }
  3260. }
  3261. string usaFingerText = (string)jsonData.GetType().GetProperty("是否留过十指指纹")!.GetValue(jsonData)!;
  3262. int usaFinger = 0;
  3263. if (usaFingerText.Contains('是')) usaFinger = 1;
  3264. string usaLoseText = (string)jsonData.GetType().GetProperty("签证是否曾遗失")!.GetValue(jsonData)!;
  3265. int usaLose = 0;
  3266. if (usaLoseText.Contains("是")) usaLose = 1;
  3267. //是否曾抵达过美国
  3268. string usaHadArrival‌Text = (string)jsonData.GetType().GetProperty("是否曾抵达过美国")!.GetValue(jsonData)!;
  3269. var (usaHadArrivalf, usaHadArrivalD, usaHadArrivalDays) = TravelHadFlagParser(usaHadArrival‌Text);
  3270. //是否有被美国拒发签证的经历
  3271. string usaRejecteVisaTest = (string)jsonData.GetType().GetProperty("是否有被美国拒发签证的经历")!.GetValue(jsonData)!;
  3272. var (denied, rejectedDate, rejectedPlace, rejectedType) = VisaDenialParser(usaRejecteVisaTest);
  3273. if (denied)
  3274. {
  3275. visaDetails.ClientInfo.RejectedDate = rejectedDate;
  3276. visaDetails.ClientInfo.RejectedPlace = rejectedPlace;
  3277. visaDetails.ClientInfo.RejectedVisa = rejectedType;
  3278. }
  3279. //是否在申请或曾经申请过美国移民签证
  3280. string usaImmVisaText‌ = (string)jsonData.GetType().GetProperty("是否在申请或曾经申请过美国移民签证")!.GetValue(jsonData)!;
  3281. var (immDenied, immDate, immPlace, immType) = VisaDenialParser(usaImmVisaText‌);
  3282. if (immDenied)
  3283. {
  3284. visaDetails.ClientInfo.USAImmVisa‌Date = immDate;
  3285. visaDetails.ClientInfo.USAImmVisa‌Place = immPlace;
  3286. visaDetails.ClientInfo.USAImmVisa‌ = immType;
  3287. }
  3288. //在美直系
  3289. string usaImmedText‌ = (string)jsonData.GetType().GetProperty("是否有直系亲属在美国")!.GetValue(jsonData)!;
  3290. var (immedDenied, immedName, immedRel, immedStat) = FourFieldParser(usaImmedText‌);
  3291. if (immedDenied)
  3292. {
  3293. visaDetails.ClientInfo.USAImmedFamName = immedName;
  3294. visaDetails.ClientInfo.USAImmedFamRel = immedRel;
  3295. visaDetails.ClientInfo.USAImmedFamStat = immedStat;
  3296. }
  3297. //在美旁系
  3298. string usaUncleText‌ = (string)jsonData.GetType().GetProperty("是否有旁系亲属在美国")!.GetValue(jsonData)!;
  3299. var (uncleDenied, uncleName, uncleRel, uncleStat) = FourFieldParser(usaUncleText‌);
  3300. if (immedDenied)
  3301. {
  3302. visaDetails.ClientInfo.USAUncleFamName = uncleName;
  3303. visaDetails.ClientInfo.USAUncleFamRel = uncleName;
  3304. visaDetails.ClientInfo.USAUncleFamStat = uncleStat;
  3305. }
  3306. //服役时间 MilitaryParser
  3307. string militaryText‌ = (string)jsonData.GetType().GetProperty("是否曾参过军")!.GetValue(jsonData)!;
  3308. var (militaryH, militaryB, militaryR, militaryS, (militaryStart, militaryEnd)) = MilitaryParser(militaryText‌);
  3309. var militarys = new List<MilitaryInfo>();
  3310. if (militaryH)
  3311. {
  3312. militarys.Add(new()
  3313. {
  3314. MilBranch = militaryB,
  3315. MilRank = militaryR,
  3316. MilSkill = militaryS,
  3317. ServeTimeBegin = militaryStart,
  3318. ServeTimeEnd = militaryEnd,
  3319. });
  3320. }
  3321. //申请人父母信息 ParentParser
  3322. string fthMthText‌ = (string)jsonData.GetType().GetProperty("申请人父母信息")!.GetValue(jsonData)!;
  3323. if (!string.IsNullOrEmpty(fthMthText‌))
  3324. {
  3325. var (fName, fDob, mName, mDob) = ParentParser(fthMthText‌);
  3326. visaDetails.ClientInfo.FthName = fName;
  3327. visaDetails.ClientInfo.FthBirth = fDob;
  3328. visaDetails.ClientInfo.MthName = mName;
  3329. visaDetails.ClientInfo.MthBirth = mDob;
  3330. }
  3331. visaDetails.ClientInfo = new()
  3332. {
  3333. LastName = name.GetLastName(),
  3334. FirstName = name.GetFirstName(),
  3335. Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1,
  3336. OldName = (string)jsonData.GetType().GetProperty("曾用名")!.GetValue(jsonData)!,
  3337. BirthDay = birthDayDt,
  3338. BirthProvince = birthDay1.province,
  3339. BirthCity = birthDay1.city,
  3340. Address = address.address,
  3341. PostCodes = address.zipCode,
  3342. Marriage = maritalStatus,
  3343. MateName = (string)jsonData.GetType().GetProperty("配偶姓名")!.GetValue(jsonData)!,
  3344. MateBirthDay = birthDayDt_mate,
  3345. MateBirthCountry = birthDay1_mate.province,
  3346. MateBirthCity = birthDay1_mate.city,
  3347. USA_DLNo = driveInfo.number,
  3348. USA_DLPlace = driveInfo.place,
  3349. USA_SSNOrITIN = number,
  3350. Resident = CleanPrefix((string)jsonData.GetType().GetProperty("是否是其他国家的永久居民")!.GetValue(jsonData)!),
  3351. HasSocialAcc‌ = CleanPrefix((string)jsonData.GetType().GetProperty("近五年内是否使用过任何社交账号")!.GetValue(jsonData)!),
  3352. WeddingDate = f,
  3353. DivorceDate = t,
  3354. DivorceRsn = (string)jsonData.GetType().GetProperty("离婚原因")!.GetValue(jsonData)!,
  3355. Job = (string)jsonData.GetType().GetProperty("职务")!.GetValue(jsonData)!,
  3356. Wage = (string)jsonData.GetType().GetProperty("月薪")!.GetValue(jsonData)!,
  3357. WorkState = (string)jsonData.GetType().GetProperty("工作职责")!.GetValue(jsonData)!,
  3358. WorkDate = (string)jsonData.GetType().GetProperty("入职/入学时间(详细到月)")!.GetValue(jsonData)!,
  3359. USAAddress = (string)jsonData.GetType().GetProperty("请提供美国详细住址")!.GetValue(jsonData)!,
  3360. USAPurpose = (string)jsonData.GetType().GetProperty("赴美目的")!.GetValue(jsonData)!,
  3361. CostBearers = (string)jsonData.GetType().GetProperty("费用谁付")!.GetValue(jsonData)!,
  3362. USAContact = (string)jsonData.GetType().GetProperty("美国联系人或组织")!.GetValue(jsonData)!,
  3363. USAContactTel = usa_phone,
  3364. USAContactEmail = usa_email,
  3365. USADate = usa_d,
  3366. USADays = usa_days,
  3367. USAArrivalCity‌ = (string)jsonData.GetType().GetProperty("赴美的到达城市")!.GetValue(jsonData)!,
  3368. USADepartCity‌ = (string)jsonData.GetType().GetProperty("赴美的离开城市")!.GetValue(jsonData)!,
  3369. USAVisitSites‌ = (string)jsonData.GetType().GetProperty("计划在美国访问的景点")!.GetValue(jsonData)!,
  3370. USACmpName = usaCmpName,
  3371. USACmpRelation = (string)jsonData.GetType().GetProperty("同行人关系")!.GetValue(jsonData)!,
  3372. Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!,
  3373. ClientPhone = (string)jsonData.GetType().GetProperty("单位电话")!.GetValue(jsonData)!,
  3374. Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!,
  3375. Cntry5Y‌ = (string)jsonData.GetType().GetProperty("过去5年内到过的国家")!.GetValue(jsonData)!,
  3376. LangSkill‌ = (string)jsonData.GetType().GetProperty("面签时能流利交流的语言")!.GetValue(jsonData)!,
  3377. LoseCode = loseCode,
  3378. DenyNationRsn = (string)jsonData.GetType().GetProperty("曾被哪些国家拒签/拒签原因")!.GetValue(jsonData)!,
  3379. USAVisaCode = (string)jsonData.GetType().GetProperty("签证号码")!.GetValue(jsonData)!,
  3380. USAVisaCate = (string)jsonData.GetType().GetProperty("获签类型")!.GetValue(jsonData)!,
  3381. //GetUSAVisaDate = usaVisaDate,
  3382. USAFinger = usaFinger,
  3383. IsLose = usaLose,
  3384. USAHadArrival = usaHadArrivalD,
  3385. USAHadDays = usaHadArrivalDays,
  3386. ArmyState = JsonConvert.SerializeObject(militarys)
  3387. };
  3388. visaDetails.ClientCerts = new() {
  3389. new(){ SdId = 74,CertNo = passportNo,IDCardAddress = passportPlace },
  3390. new(){ SdId = 73,CertNo = idNo},
  3391. };
  3392. visaDetails.ClientCompany = new() { CompanyFullName = clientName, Address = clientAddr };
  3393. break;
  3394. //中文个人简历模板
  3395. case 6:
  3396. _logger.LogInformation("【签证上传文件操作信息】【中文个人简历模板】【KIMI-AI-API访问计次】{count} 次", kimiAI_API_Index);
  3397. visaDetails.ClientInfo.LastName = (string)jsonData.GetType().GetProperty("姓名(中英文拼音)")!.GetValue(jsonData)!;
  3398. visaDetails.ClientInfo.Sex = (string)jsonData.GetType().GetProperty("性别")!.GetValue(jsonData)! == "男" ? 0 : 1;
  3399. DateTime.TryParse((string)jsonData.GetType().GetProperty("出生日期")!.GetValue(jsonData)!, out DateTime birthDay11);
  3400. visaDetails.ClientInfo.BirthDay = birthDay11;
  3401. visaDetails.ClientInfo.BirthProvince = (string)jsonData.GetType().GetProperty("出生地")!.GetValue(jsonData)!;
  3402. visaDetails.ClientInfo.Address = (string)jsonData.GetType().GetProperty("家庭地址")!.GetValue(jsonData)!;
  3403. visaDetails.ClientInfo.Tel = (string)jsonData.GetType().GetProperty("家庭电话")!.GetValue(jsonData)!;
  3404. visaDetails.ClientInfo.TableOpTel = (string)jsonData.GetType().GetProperty("工作电话")!.GetValue(jsonData)!;
  3405. visaDetails.ClientInfo.Phone = (string)jsonData.GetType().GetProperty("移动电话")!.GetValue(jsonData)!;
  3406. visaDetails.ClientInfo.Email = (string)jsonData.GetType().GetProperty("电子邮件")!.GetValue(jsonData)!;
  3407. //学校信息
  3408. visaDetails.ClientSchools.Add(new()
  3409. {
  3410. School = (string)jsonData.GetType().GetProperty("教育学校名称")!.GetValue(jsonData)!,
  3411. Education = (string)jsonData.GetType().GetProperty("教育学位")!.GetValue(jsonData)!,
  3412. Subject = (string)jsonData.GetType().GetProperty("教育专业")!.GetValue(jsonData)!,
  3413. Remark = (string)jsonData.GetType().GetProperty("教育论文题目/研究重点(硕士、博士)")!.GetValue(jsonData)!,
  3414. });
  3415. //工作信息
  3416. visaDetails.ClientCompany = new()
  3417. {
  3418. CompanyFullName = (string)jsonData.GetType().GetProperty("工作经历雇主")!.GetValue(jsonData)!,
  3419. };
  3420. visaDetails.ClientInfo.Job = (string)jsonData.GetType().GetProperty("工作经历职位或头衔职责")!.GetValue(jsonData)!;
  3421. break;
  3422. default:
  3423. break;
  3424. }
  3425. //数据提交
  3426. #region 数据提交
  3427. _sqlSugar.BeginTran();
  3428. // 客户公司表
  3429. var compId = UpsertReturnId<Crm_CustomerCompany>(visaDetails.ClientCompany, o => o.CompanyFullName);
  3430. if (compId < 1)
  3431. {
  3432. _sqlSugar.RollbackTran();
  3433. return Ok(JsonView(false, "公司信息更新失败!"));
  3434. }
  3435. visaDetails.ClientInfo.CrmCompanyId = compId;
  3436. // 客户资料表
  3437. var clientId = UpsertReturnId<Crm_DeleClient>(visaDetails.ClientInfo, o => new { o.LastName, o.FirstName });
  3438. if (clientId < 1)
  3439. {
  3440. _sqlSugar.RollbackTran();
  3441. return Ok(JsonView(false, "客户信息更新失败!"));
  3442. }
  3443. for (int i = 0; i < visaDetails.ClientFamilys.Count(); i++)
  3444. {
  3445. visaDetails.ClientFamilys[i].DcId = clientId;
  3446. }
  3447. for (int i = 0; i < visaDetails.ClientCerts.Count(); i++)
  3448. {
  3449. visaDetails.ClientCerts[i].DcId = clientId;
  3450. }
  3451. for (int i = 0; i < visaDetails.ClientSchools.Count(); i++)
  3452. {
  3453. visaDetails.ClientSchools[i].DcId = clientId;
  3454. }
  3455. // 客户家庭表
  3456. foreach (var item in visaDetails.ClientFamilys)
  3457. {
  3458. var famId = UpsertReturnId<Crm_VisaCustomerFamily>(item, o => o.Name);
  3459. if (famId < 1)
  3460. {
  3461. _sqlSugar.RollbackTran();
  3462. return Ok(JsonView(false, "客户家庭信息更新失败!"));
  3463. }
  3464. }
  3465. // 客户证件表
  3466. foreach (var item in visaDetails.ClientCerts)
  3467. {
  3468. var certId = UpsertReturnId<Crm_CustomerCert>(item, o => o.CertNo);
  3469. if (certId < 1)
  3470. {
  3471. _sqlSugar.RollbackTran();
  3472. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3473. }
  3474. }
  3475. // 客户学历表
  3476. foreach (var item in visaDetails.ClientSchools)
  3477. {
  3478. var schoolId = UpsertReturnId<Crm_VisaCustomerSchool>(item, o => o.School);
  3479. if (schoolId < 1)
  3480. {
  3481. _sqlSugar.RollbackTran();
  3482. return Ok(JsonView(false, "客户证件信息更新失败!"));
  3483. }
  3484. }
  3485. _sqlSugar.CommitTran();
  3486. #endregion
  3487. #endregion
  3488. return Ok(JsonView(true, jsonString));
  3489. }
  3490. #region 扩展处理
  3491. // 从 Expression<Func<T,object>> 里取出属性名
  3492. static string GetPropName<T>(Expression<Func<T, object>> expr)
  3493. {
  3494. if (expr.Body is UnaryExpression ue) expr = Expression.Lambda<Func<T, object>>(ue.Operand, expr.Parameters);
  3495. return ((MemberExpression)expr.Body).Member.Name;
  3496. }
  3497. /// <summary>
  3498. /// 5.1.4.193 可用:存在更新(非NULL非空串),不存在插入,返回主键ID
  3499. /// </summary>
  3500. public int UpsertReturnId<T>(T entity, Expression<Func<T, object>> whereExpr) where T : class, new()
  3501. {
  3502. // 1. 空字符串→NULL,让后续忽略
  3503. foreach (var pi in typeof(T).GetProperties())
  3504. if (pi.PropertyType == typeof(string) &&
  3505. pi.GetValue(entity) is string s &&
  3506. string.IsNullOrWhiteSpace(s))
  3507. pi.SetValue(entity, null);
  3508. // 2. 从表达式里拿属性名
  3509. string propName = GetPropName(whereExpr);
  3510. var propValue = typeof(T).GetProperty(propName)?.GetValue(entity);
  3511. // 3. 判断存在
  3512. bool exists = _sqlSugar.Queryable<T>().Where(propName, propValue).Any();
  3513. // 4. 执行 Upsert
  3514. if (exists)
  3515. {
  3516. _sqlSugar.Updateable(entity)
  3517. .WhereColumns(propName) // 指定条件列
  3518. .IgnoreColumns(ignoreAllNullColumns: true) // 忽略 NULL
  3519. .ExecuteCommand();
  3520. }
  3521. else
  3522. {
  3523. _sqlSugar.Insertable(entity).ExecuteReturnIdentity();
  3524. }
  3525. // 5. 返回主键值(自增/雪花已回填)
  3526. var idProp = typeof(T).GetProperties()
  3527. .First(p => p.GetCustomAttributes<SugarColumn>()
  3528. .Any(a => a.IsPrimaryKey));
  3529. return (int)idProp.GetValue(entity)!;
  3530. }
  3531. /// <summary>
  3532. /// 地址喊邮编 相关处理
  3533. /// </summary>
  3534. public static (string address, string zipCode) SplitAddressZip(string? s)
  3535. {
  3536. if (string.IsNullOrWhiteSpace(s))
  3537. return ("", "");
  3538. ReadOnlySpan<char> src = s.AsSpan();
  3539. int i = src.IndexOf("邮编".AsSpan());
  3540. if (i < 0) // 没有“邮编”字样
  3541. return (src.Trim().ToString(), "");
  3542. ReadOnlySpan<char> addr = src[..i].TrimEnd();
  3543. ReadOnlySpan<char> zip = src[(i + 3)..].Trim(); // 跳过“邮编:”
  3544. // 可能只有“邮编:”而没有数字
  3545. return (addr.IsEmpty ? "" : addr.ToString(),
  3546. zip.IsEmpty ? "" : zip.ToString());
  3547. }
  3548. /// <summary>
  3549. /// 驾照相 关处理
  3550. /// </summary>
  3551. /// <param name="raw"></param>
  3552. /// <returns></returns>
  3553. public static (bool hasLicense, string number, string place) LicenseParser(string? raw)
  3554. {
  3555. if (string.IsNullOrWhiteSpace(raw))
  3556. return (false, "", "");
  3557. // 1. 是否持有
  3558. bool has = raw.StartsWith("是", System.StringComparison.OrdinalIgnoreCase) ||
  3559. raw.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3560. // 2. 去掉前缀,按空格切
  3561. ReadOnlySpan<char> s = raw.AsSpan();
  3562. int colon = s.IndexOf(':');
  3563. ReadOnlySpan<char> after = colon < 0 ? s : s[(colon + 1)..];
  3564. after = after.Trim();
  3565. int space = after.IndexOf(' ');
  3566. ReadOnlySpan<char> num = space < 0 ? after : after[..space];
  3567. ReadOnlySpan<char> st = space < 0 ? ReadOnlySpan<char>.Empty : after[(space + 1)..];
  3568. return (has, num.ToString().Trim(), st.ToString().Trim());
  3569. }
  3570. /// <summary>
  3571. /// 美国社会安全号或者纳税ID号 相关处理
  3572. /// </summary>
  3573. /// <param name="raw"></param>
  3574. /// <returns></returns>
  3575. public static (bool hasSsnItin, string number) SsnItinParser(string? raw)
  3576. {
  3577. if (string.IsNullOrWhiteSpace(raw))
  3578. return (false, "");
  3579. ReadOnlySpan<char> s = raw.AsSpan();
  3580. // 1. 是否持有
  3581. bool has = s.StartsWith("是", System.StringComparison.Ordinal) ||
  3582. s.StartsWith("Y", System.StringComparison.OrdinalIgnoreCase);
  3583. // 2. 取号码(去掉前缀和空格)
  3584. int colon = s.IndexOf(':');
  3585. ReadOnlySpan<char> num = colon < 0
  3586. ? ReadOnlySpan<char>.Empty
  3587. : s[(colon + 1)..].Trim();
  3588. return (has, num.ToString());
  3589. }
  3590. /// <summary>
  3591. /// 取消开始的“是:”或者“是”或者“ :”
  3592. /// </summary>
  3593. /// <param name="raw"></param>
  3594. /// <returns></returns>
  3595. public static string CleanPrefix(string? raw)
  3596. {
  3597. if (string.IsNullOrWhiteSpace(raw)) return "";
  3598. // 跳过第一个“是”或“Y”
  3599. ReadOnlySpan<char> s = raw.AsSpan();
  3600. int start = 0;
  3601. if (s.StartsWith("是") || s.StartsWith("Y", StringComparison.OrdinalIgnoreCase))
  3602. start = 1;
  3603. // 跳过连续 : 或空格
  3604. while (start < s.Length && (s[start] == ':' || s[start] == ' '))
  3605. start++;
  3606. return s[start..].Trim().ToString();
  3607. }
  3608. /// <summary>
  3609. /// 婚姻起止时间处理
  3610. /// </summary>
  3611. /// <param name="raw"></param>
  3612. /// <returns></returns>
  3613. public static (DateTime? fromDate, DateTime? toDate) WeddingParser(string? raw)
  3614. {
  3615. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3616. Regex _clean = new(@"[\s~至]+", RegexOptions.Compiled);
  3617. // 1. 把所有“空格~至”统一成 '-'
  3618. string normalized = _clean.Replace(raw, "-");
  3619. // 2. 切两段
  3620. string[] parts = normalized.Split('-', StringSplitOptions.RemoveEmptyEntries);
  3621. if (parts.Length != 2) return (null, null);
  3622. // 3. 解析
  3623. bool ff = DateTime.TryParse(parts[0].Trim(), out var from);
  3624. bool tf = DateTime.TryParse(parts[1].Trim(), out var to);
  3625. return (tf ? from : null, tf ? to : null);
  3626. }
  3627. /// <summary>
  3628. /// 出行日期和天数处理
  3629. /// </summary>
  3630. /// <param name="raw"></param>
  3631. /// <returns></returns>
  3632. public static (DateTime? travelDate, int? days) TravelParser(string? raw)
  3633. {
  3634. if (string.IsNullOrWhiteSpace(raw)) return (null, null);
  3635. // 切成两段:第一段日期,第二段天数
  3636. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3637. string[] parts = sep.Split(raw.Trim());
  3638. if (parts.Length < 2) return (null, null);
  3639. bool okDate = DateTime.TryParse(parts[0], out DateTime date);
  3640. bool okDays = int.TryParse(parts[1], out int days) && days > 0;
  3641. return (okDate ? date : null, okDays ? days : null);
  3642. }
  3643. /// <summary>
  3644. /// 是否曾抵达过美国
  3645. /// </summary>
  3646. /// <param name="raw"></param>
  3647. /// <returns></returns>
  3648. public static (bool hasTravel, string date, string days) TravelHadFlagParser(string? raw)
  3649. {
  3650. if (string.IsNullOrWhiteSpace(raw)) return (false, string.Empty, string.Empty);
  3651. Regex sep = new(@"[^0-9./-]+", RegexOptions.Compiled);
  3652. // 1. 是否持有
  3653. bool has = raw.AsSpan().TrimStart().StartsWith("是") ||
  3654. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3655. // 2. 用非数字分隔符切成三段:第一段空,第二段日期,第三段天数
  3656. string[] parts = sep.Split(raw.Trim());
  3657. if (parts.Length < 3) return (has, string.Empty, string.Empty);
  3658. return (has, parts[1], parts[2]);
  3659. }
  3660. /// <summary>
  3661. /// 是否有被美国拒发签证的经历
  3662. /// </summary>
  3663. /// <param name="raw"></param>
  3664. /// <returns></returns>
  3665. public static (bool wasDenied, DateTime? date, string place, string visaType) VisaDenialParser(string? raw)
  3666. {
  3667. if (string.IsNullOrWhiteSpace(raw)) return (false, null, "", "");
  3668. bool denied = raw.AsSpan().TrimStart().StartsWith("有") ||
  3669. raw.AsSpan().TrimStart().StartsWith("Y", StringComparison.OrdinalIgnoreCase);
  3670. var parts = Regex.Split(raw.Trim(), @"[^0-9A-Za-z-]+");
  3671. if (parts.Length < 4) return (denied, null, "", "");
  3672. DateTime.TryParse(parts[1], out var dt); // ← 这里改为 DateTime
  3673. return (denied, dt, parts[2], parts[3]);
  3674. }
  3675. /// <summary>
  3676. /// 在美直系、旁系 处理
  3677. /// </summary>
  3678. /// <param name="raw"></param>
  3679. /// <returns></returns>
  3680. public static (bool flag, string name, string rel, string stat) FourFieldParser(string? raw)
  3681. {
  3682. if (string.IsNullOrWhiteSpace(raw)) return (false, "", "", "");
  3683. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3684. if (parts.Length < 4) return (false, "", "", "");
  3685. bool flag = parts[0] is "有" or "是" or "Y" or "Yes";
  3686. string name = parts[1];
  3687. string rel = parts[2];
  3688. string stat = parts[3];
  3689. return (flag, name, rel, stat);
  3690. }
  3691. /// <summary>
  3692. /// 服役时间处理
  3693. /// </summary>
  3694. /// <param name="raw"></param>
  3695. /// <returns></returns>
  3696. public static (bool hasService, string branch, string rank, string specialty, (DateTime? start, DateTime? end) period) MilitaryParser(string? raw)
  3697. {
  3698. const string fmt = "yyyy年MM月dd日";
  3699. if (string.IsNullOrWhiteSpace(raw))
  3700. return (false, "", "", "", (null, null));
  3701. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3702. if (parts.Length < 5) return (false, "", "", "", (null, null));
  3703. bool has = parts[0] is "是" or "Y" or "Yes";
  3704. string branch = parts[1];
  3705. string rank = parts[2];
  3706. string specialty = parts[3];
  3707. // 拼回时间字符串
  3708. string periodRaw = string.Join(" ", parts[4..]);
  3709. var span = periodRaw.AsSpan();
  3710. int zhi = span.IndexOf("至");
  3711. if (zhi < 0) return (has, branch, rank, specialty, (null, null));
  3712. var startStr = span.Slice(0, zhi).Trim();
  3713. var endStr = span.Slice(zhi + 1).Trim();
  3714. bool okStart = DateTime.TryParseExact(startStr.ToString(), fmt, null, DateTimeStyles.None, out var start);
  3715. bool okEnd = DateTime.TryParseExact(endStr.ToString(), fmt, null, DateTimeStyles.None, out var end);
  3716. return (has, branch, rank, specialty, (okStart ? start : null, okEnd ? end : null));
  3717. }
  3718. /// <summary>
  3719. /// 申请人父母信息
  3720. /// </summary>
  3721. /// <param name="raw"></param>
  3722. /// <returns></returns>
  3723. public static (string fatherName, DateTime? fatherDob, string motherName, DateTime? motherDob) ParentParser(string? raw)
  3724. {
  3725. const string fmt = "yyyy年MM月dd日";
  3726. if (string.IsNullOrWhiteSpace(raw)) return ("", null, "", null);
  3727. // 按空格切,去掉空元素
  3728. var parts = raw.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
  3729. if (parts.Length < 4) return ("", null, "", null);
  3730. // 父亲
  3731. string fName = parts[0];
  3732. DateTime.TryParseExact(parts[1], fmt, null, DateTimeStyles.None, out var fDob);
  3733. // 母亲
  3734. string mName = parts[2];
  3735. DateTime.TryParseExact(parts[3], fmt, null, DateTimeStyles.None, out var mDob);
  3736. return (fName, fDob, mName, mDob);
  3737. }
  3738. public class VisaDetailsView
  3739. {
  3740. /// <summary>
  3741. /// 客户资料表
  3742. /// </summary>
  3743. public Crm_DeleClient ClientInfo { get; set; }
  3744. /// <summary>
  3745. /// 客户家庭表
  3746. /// </summary>
  3747. public List<Crm_VisaCustomerFamily> ClientFamilys { get; set; }
  3748. /// <summary>
  3749. /// 客户公司表
  3750. /// </summary>
  3751. public Crm_CustomerCompany ClientCompany { get; set; }
  3752. /// <summary>
  3753. /// 客户证件表
  3754. /// </summary>
  3755. public List<Crm_CustomerCert> ClientCerts { get; set; }
  3756. /// <summary>
  3757. /// 客户学历表
  3758. /// </summary>
  3759. public List<Crm_VisaCustomerSchool> ClientSchools { get; set; }
  3760. }
  3761. private int GetSuccessCount(List<FileUploadResult> results)
  3762. {
  3763. var count = 0;
  3764. foreach (var result in results)
  3765. {
  3766. if (result.Success) count++;
  3767. }
  3768. return count;
  3769. }
  3770. #endregion
  3771. #region 文件下载
  3772. /// <summary>
  3773. /// 签证下载类型初始化
  3774. /// </summary>
  3775. private readonly static Dictionary<int, string> _visaTypeInit = new()
  3776. {
  3777. { 1, "美国" },
  3778. { 2, "日本" },
  3779. { 3, "韩国" },
  3780. { 4, "瑞典" },
  3781. { 5, "波兰" },
  3782. };
  3783. //申根国
  3784. private readonly static string[] _shenGenGuos = new string[] { "奥地利", "比利时", "丹麦", "芬兰", "法国", "德国", "冰岛", "意大利", "希腊", "卢森堡", "荷兰", "挪威", "葡萄牙", "西班牙",
  3785. "瑞典", "匈牙利", "捷克", "斯洛伐克", "斯洛文尼亚","波兰","爱沙尼亚","拉脱维亚","立陶宛","马耳他","瑞士","列支敦士登" };
  3786. //欧盟国家
  3787. private readonly static string[] _eucountries = new string[] { "奥地利", "比利时", "丹麦", "芬兰", "法国", "德国", "意大利", "希腊", "卢森堡", "荷兰", "葡萄牙", "西班牙","爱尔兰","罗马尼亚",
  3788. "保加利亚","匈牙利", "捷克", "斯洛伐克", "斯洛文尼亚","波兰","爱沙尼亚","拉脱维亚","立陶宛","马耳他","瑞士","列支敦士登" };
  3789. //欧洲国家
  3790. private readonly static string[] _aBC = new string[] { "英国", "爱尔兰" };
  3791. /// <summary>
  3792. /// 团组&签证 New
  3793. /// 签证文申请表下载
  3794. /// </summary>
  3795. /// <param name="groupId">
  3796. /// <param name="fileTypeId">
  3797. /// </param>
  3798. /// <returns></returns>
  3799. [HttpGet]
  3800. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  3801. public async Task<IActionResult> VisaFileDownload(int groupId, int fileTypeId)
  3802. {
  3803. if (!_visaTypeInit.TryGetValue(fileTypeId, out _))
  3804. {
  3805. return Ok(JsonView(false, "请选择正确的文件类型!"));
  3806. }
  3807. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == groupId).First();
  3808. if (groupInfo == null)
  3809. {
  3810. return Ok(JsonView(false, "团组信息不存在!"));
  3811. }
  3812. //访问路径
  3813. var serverPath = $"http://132.232.92.186:24/Word/VisaClientData/Downloads/{groupInfo.TeamName}/";
  3814. //模板存储位置
  3815. var tempPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Template/";
  3816. //服务器存储文件位置
  3817. var fileServerPath = $"D:/FTP/File/OA2023/Office/Word/VisaClientData/Downloads/{groupInfo.TeamName}/";
  3818. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(fileServerPath);
  3819. //文件生成路径
  3820. string url = string.Empty;
  3821. //基础数据
  3822. //团组客户名单
  3823. var groupClients = await _sqlSugar.Queryable<Grp_TourClientList>()
  3824. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  3825. .Select(x => x.ClientId)
  3826. .ToListAsync();
  3827. if (groupClients.Count < 1)
  3828. {
  3829. return Ok(JsonView(false, "该团组下暂无团组名单!"));
  3830. }
  3831. //团组客户详细信息
  3832. var groupCustInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(x => x.IsDel == 0 && groupClients.Contains(x.Id)).ToList();
  3833. //家庭成员资料
  3834. var familyInfos = _sqlSugar.Queryable<Crm_VisaCustomerFamily>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3835. //公司资料
  3836. var companyInfo‌‌s = _sqlSugar.Queryable<Crm_VisaCustomerCompany>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3837. //学校资料
  3838. var schoolInfos = _sqlSugar.Queryable<Crm_VisaCustomerSchool>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3839. /* 证件类型
  3840. *
  3841. * 773 身份证
  3842. * 774 护照
  3843. * 775 学生证
  3844. * 776 军人证
  3845. * 777 回乡证
  3846. * 778 台胞证
  3847. * 779 港澳通行证
  3848. * 780 国际海员证
  3849. * 781 外国人永久居留证
  3850. * 782 旅行证
  3851. * 783 台湾通行证
  3852. * 784 港澳台居住证
  3853. * 785 其他
  3854. */
  3855. //证件资料
  3856. var certInfos = _sqlSugar.Queryable<Crm_CustomerCert>().Where(x => x.IsDel == 0 && groupClients.Contains(x.DcId)).ToList();
  3857. //利用字典创建书签与书签的值的键值对,第一个string为键,第二个string为值
  3858. var applyDate = DateTime.Now.ToString("yyyy-MM-dd");
  3859. var filePaths = new List<string>();
  3860. var visaTypeName = string.Empty;
  3861. var currTempPath = string.Empty;
  3862. switch (fileTypeId)
  3863. {
  3864. case 1: // 美国
  3865. visaTypeName = $"美国签证申请表";
  3866. currTempPath = $"{tempPath}{visaTypeName}.doc";
  3867. var usaSavePath = $"{fileServerPath}{visaTypeName}/";
  3868. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(usaSavePath);
  3869. foreach (var custInfo in groupCustInfos)
  3870. {
  3871. //解密
  3872. EncryptionProcessor.DecryptProperties(custInfo);
  3873. Dictionary<string, string> dics = new();
  3874. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  3875. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  3876. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  3877. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  3878. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  3879. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  3880. #region 美国签证模板书签值处理
  3881. dics.Add("LastNameEn", custInfo?.LastName ?? "");//名拼音
  3882. dics.Add("FirstNameEn", custInfo?.FirstName ?? "");//姓拼音
  3883. dics.Add("LastName", custInfo?.LastName ?? "");//名
  3884. dics.Add("FirstName", custInfo?.FirstName ?? "");//姓
  3885. dics.Add("OldNameEn", custInfo?.OldName ?? "");//曾用姓名拼音
  3886. dics.Add("OldName", custInfo?.FirstName ?? "");//曾用姓名
  3887. //未设置、未婚、已婚、离异、丧偶
  3888. var marriage = custInfo.Marriage switch
  3889. {
  3890. 0 => "未设置",
  3891. 1 => "未婚",
  3892. 2 => "已婚",
  3893. 3 => "离异",
  3894. 4 => "丧偶",
  3895. _ => "未知"
  3896. };
  3897. dics.Add("Marriage", marriage);//婚姻状况
  3898. dics.Add("Phone", custInfo?.Phone ?? "");//家庭电话
  3899. dics.Add("BirthCity", custInfo?.BirthCity ?? "");//出生城市
  3900. dics.Add("BirthProvince", custInfo?.BirthProvince ?? "");//出生省份
  3901. string m_idCard = idInfo?.CertNo ?? "";
  3902. string m_birthday = string.Empty;
  3903. if (!string.IsNullOrEmpty(m_idCard))
  3904. {
  3905. string m_year = m_idCard.Substring(6, 4);
  3906. string m_month = m_idCard.Substring(10, 2);
  3907. string m_day = m_idCard.Substring(12, 2);
  3908. m_birthday = m_year + "." + m_month + "." + m_day;
  3909. }
  3910. dics.Add("BirthDay", m_birthday);//出生日期
  3911. dics.Add("Tel", custInfo?.Tel ?? "");//移动电话
  3912. dics.Add("Email", custInfo?.Email ?? "");//电子信箱
  3913. dics.Add("IdCard", m_idCard);//身份证号码
  3914. dics.Add("Address", custInfo?.Address ?? "");//现居家庭地址
  3915. dics.Add("PostCodes", custInfo?.PostCodes ?? "");//邮编
  3916. dics.Add("Client", clinetInfo?.Company ?? "");//单位名称
  3917. dics.Add("ClientAddress", clinetInfo?.CompanyAddress ?? "");//单位地址
  3918. dics.Add("ClientPostCodes", custInfo?.PostCodes ?? "");//单位邮编
  3919. dics.Add("Job", custInfo?.Job ?? "");//职务
  3920. dics.Add("WorkDate", custInfo?.WorkDate ?? "");//入职时间
  3921. dics.Add("Wage", custInfo?.Wage ?? "");//月薪
  3922. dics.Add("ClientPhone", custInfo?.ClientPhone ?? "");//单位电话
  3923. dics.Add("ClientFax", custInfo?.ClientFax ?? "");//单位传真
  3924. dics.Add("ClientEmail", custInfo?.ClientEmail ?? "");//单位邮箱
  3925. dics.Add("ClientLeader", custInfo?.ClientLeader ?? "");//单位主管姓名
  3926. dics.Add("ClientLeaderJob", custInfo?.ClientLeaderJob ?? "");//单位主管职务
  3927. dics.Add("WorkState", custInfo?.WorkState ?? "");//工作内容简单介绍
  3928. dics.Add("IsGetSchengen", custInfo?.IsGetSchengen == 0 ? "否" : "是");//是否有获批的申根签证
  3929. dics.Add("StartTime", custInfo?.StartTime.ToString("yyyy-MM-dd") ?? "");//申根签证有效期开始
  3930. dics.Add("EndTime", custInfo?.EndTime.ToString("yyyy-MM-dd") ?? "");//申根签证有效期结束
  3931. dics.Add("IsFinger", custInfo.IsFinger == 0 ? "否" : "是");//申根签证是否有指纹记录
  3932. dics.Add("FingerDate", custInfo?.FingerDate.ToString("yyyy-MM-dd") ?? "");//申根签指纹采集时间
  3933. dics.Add("TableOpName", custInfo?.TableOpName ?? "");//填表经办人
  3934. dics.Add("TableOpTel", custInfo?.TableOpTel ?? "");//填表经办人联系电话
  3935. dics.Add("TableDate", custInfo?.TableDate.ToString("yyyy-MM-dd") ?? "");//填表日期
  3936. dics.Add("Party", custInfo?.Party ?? "");//所属党派或宗教
  3937. dics.Add("Nationality", custInfo?.Nationality ?? "");//国籍
  3938. var sex = custInfo.Sex switch
  3939. {
  3940. 0 => "男",
  3941. 1 => "女",
  3942. _ => "未知"
  3943. };
  3944. dics.Add("Sex", sex);//性别
  3945. dics.Add("WeddingDate", custInfo?.WeddingDate?.ToString("yyyy-MM-dd") ?? "");//结婚日期
  3946. dics.Add("DivorceDate", custInfo?.DivorceDate?.ToString("yyyy-MM-dd") ?? "");//离婚日期
  3947. dics.Add("MateName", custInfo?.MateName ?? "");//配偶姓名
  3948. dics.Add("MateBirthDay", custInfo?.MateBirthDay.ToString("yyyy-MM-dd") ?? "");//配偶出生日期
  3949. dics.Add("MateBirthCity", custInfo?.MateBirthCity ?? "");//配偶出生城市
  3950. dics.Add("MateBirthCountry", custInfo?.MateBirthCountry ?? "");//配偶出生省份
  3951. dics.Add("MateAddress", custInfo?.MateAddress ?? "");//配偶住址
  3952. dics.Add("MateClient", custInfo?.MateClient ?? "");//配偶工作单位名称
  3953. dics.Add("MateClientAddress", custInfo?.MateClientAddress ?? "");//配偶工作单位地址
  3954. dics.Add("MateJob", custInfo?.MateJob ?? "");//配偶职务
  3955. dics.Add("VisitCountry", custInfo?.VisitCountry ?? "");//因公出访的国家
  3956. dics.Add("Paper", custInfo?.Paper ?? "");//发表的期刊、论文
  3957. dics.Add("Papent", custInfo?.Papent ?? "");//专利
  3958. dics.Add("PhD", custInfo?.PhD ?? "");//博士论文
  3959. dics.Add("IsVisitUC", custInfo?.IsVisitUC == 0 ? "否" : "是" ?? "");//是否因公去过美国/加拿大
  3960. dics.Add("USADate", custInfo?.USADate?.ToString("yyyy-MM-dd") ?? "");//美国抵达日期
  3961. dics.Add("USADays", custInfo?.USADays.ToString() ?? "");//美国停留天数
  3962. dics.Add("CanDate", custInfo?.CanDate.ToString("yyyy-MM-dd") ?? "");//加拿大抵达日期
  3963. dics.Add("CanDays", custInfo?.CanDays.ToString() ?? "");//加拿大停留天数
  3964. dics.Add("IsUSAVia", custInfo?.IsUSAVia == 0 ? "否" : "是" ?? "");//是否获得过因公美国签证
  3965. dics.Add("GetUSAVisaDate", custInfo?.GetUSAVisaDate.ToString("yyyy-MM-dd") ?? "");//因公美国签证时间
  3966. dics.Add("GetUPPlace", custInfo?.GetUPPlace ?? "");//因公美国签证地点
  3967. dics.Add("USAVisaCate", custInfo?.USAVisaCate ?? "");//因公美国签证种类
  3968. dics.Add("USAVisaCode", custInfo?.USAVisaCode ?? "");//因公美国签证编码
  3969. dics.Add("USAFinger", custInfo?.USAFinger == 0 ? "否" : "是" ?? "");//是否在使馆留过十指的指纹
  3970. dics.Add("IsRejected", custInfo?.IsRejected == 0 ? "否" : "是" ?? "");//是否被拒
  3971. dics.Add("RejectedDate", custInfo?.RejectedDate?.ToString("yyyy-MM-dd") ?? "");//被拒时间
  3972. dics.Add("RejectedPlace", custInfo?.RejectedPlace ?? "");//被拒地点
  3973. dics.Add("RejectedVisa", custInfo?.RejectedVisa ?? "");//被拒签证种类
  3974. dics.Add("IsRevoke", custInfo?.IsRevoke == 0 ? "否" : "是" ?? "");//美国签证是否被吊销
  3975. dics.Add("IsLose", custInfo?.IsLose == 0 ? "否" : "是" ?? "");//护照是否丢失
  3976. dics.Add("LoseDate", custInfo?.LoseDate.ToString("yyyy-MM-dd") ?? "");//丢失的护照时间
  3977. dics.Add("LoseCode", custInfo?.LoseCode ?? "");//丢失的护照号码
  3978. dics.Add("IsUSAVisa", custInfo?.IsUSAVisa == 0 ? "否" : "是" ?? "");//丢失的护照是否有美国签证
  3979. dics.Add("MateUSA", custInfo?.MateUSA == 0 ? "否" : "是" ?? "");//夫/妻是否已在美国
  3980. dics.Add("MateIden", custInfo?.MateIden ?? "");//夫/妻身份
  3981. dics.Add("WHUSA", custInfo?.WHUSA == 0 ? "否" : "是" ?? "");//未婚夫/妻是否已在美国
  3982. dics.Add("WHIden", custInfo?.WHIden ?? "");//未婚夫/妻身份
  3983. dics.Add("ParentUSA", custInfo?.ParentUSA == 0 ? "否" : "是" ?? "");//父/母是否已在美国
  3984. dics.Add("ParentIden", custInfo?.ParentIden ?? "");//父/母身份
  3985. dics.Add("ChildUSA", custInfo?.ChildUSA == 0 ? "否" : "是" ?? "");//儿子/女儿是否已在美国
  3986. dics.Add("ChildIden", custInfo?.ChildIden ?? "");//儿子/女儿身份
  3987. dics.Add("BroUSA", custInfo?.BroUSA == 0 ? "否" : "是" ?? "");//兄弟/姐妹是否已在美国
  3988. dics.Add("BroIden", custInfo?.BroIden ?? "");//兄弟/姐妹身份
  3989. dics.Add("Social", custInfo?.Social ?? "");//所属/捐助/工作过的职业协会、社会团体和慈善机构
  3990. dics.Add("IsArmy", custInfo?.IsArmy == 0 ? "否" : "是" ?? "");//是否参军
  3991. dics.Add("ArmyState", custInfo?.ArmyState ?? "");//参军详情
  3992. dics.Add("ApplyDate", applyDate);//申请日期
  3993. //公司信息书签
  3994. if (currCompanyInfos.Count > 0)
  3995. {
  3996. for (int i = 0; i < currCompanyInfos.Count; i++)
  3997. {
  3998. var compnayInfo = currCompanyInfos[i];
  3999. if (!string.IsNullOrEmpty(compnayInfo.Company))
  4000. {
  4001. dics.Add("Company", compnayInfo?.Company ?? "");//公司名称
  4002. dics.Add("CompanyAddress", compnayInfo?.CompanyAddress ?? "");//公司地址
  4003. dics.Add("CompanyPhone", compnayInfo?.Phone ?? "");//公司电话
  4004. dics.Add("CompanyJob", compnayInfo?.Job ?? "");//职务
  4005. dics.Add("CompanyLeaderName", compnayInfo?.LeaderName ?? "");//主管名字
  4006. dics.Add("CompanyWorkStart", compnayInfo?.WorkStart.ToString("yyyy-MM-dd") ?? "");//雇佣起始年月日
  4007. dics.Add("CompanyWorkEnd", compnayInfo?.WorkEnd.ToString("yyyy-MM-dd") ?? "");//雇佣结束年月日
  4008. dics.Add("CompanyWorkState", compnayInfo?.WorkState ?? "");//工作职责及内容简述
  4009. }
  4010. else break;
  4011. }
  4012. }
  4013. //学校信息书签
  4014. if (currSchoolInfos.Count > 0)
  4015. {
  4016. for (int i = 0; i < currSchoolInfos.Count; i++)
  4017. {
  4018. var schoolInfo = currSchoolInfos[i];
  4019. if (!string.IsNullOrEmpty(schoolInfo.School))
  4020. {
  4021. dics.Add("School", schoolInfo?.School ?? "");//学校名称和学历
  4022. dics.Add("SchoolAddress", schoolInfo?.Address ?? "");//学校地址
  4023. dics.Add("SchoolTeacher", schoolInfo?.Teacher ?? "");//指导老师
  4024. dics.Add("SchoolSubject", schoolInfo?.Subject ?? "");//所学课程或专业名称
  4025. dics.Add("SchoolStudyStart", schoolInfo?.StudyStart.ToString("yyyy-MM-dd") ?? "");//就读起始日
  4026. dics.Add("SchoolStudyEnd", schoolInfo?.StudyEnd.ToString("yyyy-MM-dd") ?? "");//就读结束日
  4027. }
  4028. else break;
  4029. }
  4030. }
  4031. //家人信息书签
  4032. if (currFamilyInfos.Count > 0)
  4033. {
  4034. for (int i = 0; i < currFamilyInfos.Count; i++)
  4035. {
  4036. var familyInfo = currFamilyInfos[i];
  4037. if (!string.IsNullOrEmpty(familyInfo.Appellation))
  4038. {
  4039. dics.Add("FamilyAppellation", familyInfo?.Appellation ?? "");//家庭成员称谓
  4040. dics.Add("FamilyName", familyInfo?.Name ?? "");//家庭成员姓名
  4041. dics.Add("FamilyBirthDay", familyInfo?.BirthDay.ToString("yyyy-MM-dd") ?? "");//家庭成员出生日期
  4042. dics.Add("FamilyBirthPlace", familyInfo?.BirthPlace ?? "");// 家庭成员出生地
  4043. dics.Add("FamilyPolitics", familyInfo?.Politics ?? "");//家庭成员政治面貌
  4044. dics.Add("FamilyClient", familyInfo?.Client ?? "");//家庭成员工作单位
  4045. dics.Add("FamilyAddress", familyInfo?.Address ?? "");// 家庭地址
  4046. dics.Add("IsEu", familyInfo?.IsEu == 0 ? "No" : "Yes" ?? "");// 欧盟公民
  4047. dics.Add("FamilyNameSnd", familyInfo?.NameSnd ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员姓名
  4048. dics.Add("FamilyBirthDaySnd", familyInfo?.BirthDaySnd.ToString("yyyy-MM-dd") ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员生日
  4049. dics.Add("FamilyNationality", familyInfo?.Nationality ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员国籍
  4050. dics.Add("FamilyIDCard", familyInfo?.IDCard ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员旅行证件编号或身份证号码
  4051. dics.Add("FamilyReletionship", familyInfo?.Reletionship ?? "");//拥有欧盟、欧洲经济区或瑞士公民身份的家庭成员与申请人的关系
  4052. dics.Add("IsUSA", familyInfo?.IsUSA == 1 ? "是" : "否" ?? "");// 家庭成员是否在美国
  4053. }
  4054. else break;
  4055. }
  4056. }
  4057. #endregion
  4058. #region 生成文件
  4059. try
  4060. {
  4061. _logger.LogInformation("模板位置:{currTempPath}", currTempPath);
  4062. Document doc = new(currTempPath);
  4063. Aspose.Words.DocumentBuilder builder = new(doc);
  4064. string strTemp = "";
  4065. //循环键值对
  4066. foreach (var key in dics.Keys)
  4067. {
  4068. //将光标移入书签的位置
  4069. builder.MoveToBookmark(key);
  4070. //判断书签值是否为空
  4071. if (!string.IsNullOrEmpty(dics[key]))
  4072. {
  4073. strTemp = dics[key];
  4074. }
  4075. else strTemp = "";
  4076. //填充书签
  4077. builder.Write(strTemp.Replace("\\N", "\n"));
  4078. }
  4079. var custName = custInfo.LastName + custInfo.FirstName;
  4080. string fileName = $"{custName}_{visaTypeName}.doc";
  4081. var currFilePath = $"{usaSavePath}{fileName}";
  4082. doc.Save(currFilePath);
  4083. filePaths.Add(currFilePath);
  4084. }
  4085. catch (Exception ex)
  4086. {
  4087. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4088. }
  4089. #endregion
  4090. }
  4091. break;
  4092. case 2: // 日本
  4093. visaTypeName = $"日本签证申请表";
  4094. currTempPath = $"{tempPath}/{visaTypeName}.doc";
  4095. var jpnSavePath = $"{fileServerPath}/{visaTypeName}/";
  4096. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(jpnSavePath);
  4097. foreach (var custInfo in groupCustInfos)
  4098. {
  4099. EncryptionProcessor.DecryptProperties(custInfo);
  4100. Dictionary<string, string> dics = new();
  4101. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  4102. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  4103. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  4104. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4105. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4106. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4107. #region 日本签证模板书签
  4108. dics.Add("LastNameEn", CommonFun.ConvertToPinyin(custInfo?.LastName?.Trim() ?? "")?.ToLower() ?? "");//姓
  4109. dics.Add("FirstNameEn", CommonFun.ConvertToPinyin(custInfo?.FirstName?.Trim() ?? "")?.ToLower() ?? "");//名
  4110. if (!string.IsNullOrEmpty(custInfo.OldName)) dics.Add("OldNameEn", custInfo?.OldName ?? "");//名
  4111. else dics.Add("OldNameEn", "无");//名
  4112. dics.Add("LastName", custInfo?.LastName ?? "");//姓
  4113. dics.Add("FirstName", custInfo?.FirstName ?? "");//名
  4114. if (!string.IsNullOrEmpty(custInfo.OldName)) dics.Add("OldName", custInfo?.OldName ?? "");//名
  4115. else dics.Add("OldName", "无");//名
  4116. string idCard = idInfo?.CertNo?.Trim() ?? "";
  4117. string birthday = string.Empty;
  4118. if (!string.IsNullOrEmpty(idCard))
  4119. {
  4120. string year = idCard.Substring(6, 4);
  4121. string month = idCard.Substring(10, 2);
  4122. string day = idCard.Substring(12, 2);
  4123. birthday = year + "/" + month + "/" + day;
  4124. }
  4125. dics.Add("BirthDay", birthday); //出生日期
  4126. dics.Add("BirthProvince", custInfo?.BirthProvince ?? "");//出生省
  4127. dics.Add("BirthCity", custInfo?.BirthCity ?? "");//出生城市
  4128. dics.Add("Nationality", "中国");//国籍
  4129. dics.Add("Address", custInfo?.Address ?? "");//现居家庭地址
  4130. dics.Add("IdCard", idCard);//身份证号码
  4131. dics.Add("OldNationality", "无");//默认没有
  4132. dics.Add("Tel11", custInfo?.Phone ?? "");//座机
  4133. //护照
  4134. if (passportInfo != null)
  4135. {
  4136. dics.Add("PassprotNo", passportInfo?.CertNo ?? "");// 护照編號
  4137. dics.Add("PassprotIssuePlase", passportInfo?.Area ?? "");// 护照签发地
  4138. dics.Add("PassprotStartTime", passportInfo?.IssueDt?.ToString("yyyy/MM/dd") ?? "");//护照开始时间
  4139. dics.Add("PassprotEndTime", passportInfo?.ExpiryDt?.ToString("yyyy/MM/dd") ?? "");// 护照过期时间
  4140. }
  4141. //得到签证国家下的城市
  4142. string city = "";
  4143. string county = "";
  4144. //ResidenceTime1 机票三字码信息
  4145. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  4146. if (atbc != null)
  4147. {
  4148. string startTime = ""; //开始停留时间
  4149. string endTime = ""; //离开时间
  4150. string three = ""; //航司
  4151. string threeCode = ""; //入境口岸
  4152. for (int i = 0; i < atbc.Rows.Count; i++)
  4153. {
  4154. if (i == 0) //得到抵达日期
  4155. {
  4156. three = atbc.Rows[i]["Fliagtcode"].ToString();
  4157. startTime = atbc.Rows[i]["Day"].ToString();
  4158. threeCode = atbc.Rows[i]["Three"].ToString();
  4159. continue;
  4160. }
  4161. if (i == 1)
  4162. endTime = atbc.Rows[i]["Day"].ToString();
  4163. }
  4164. dics.Add("ResidenceTime1", startTime);
  4165. dics.Add("ResidenceTime2", endTime);
  4166. dics.Add("EntryTime", startTime);
  4167. if (!string.IsNullOrEmpty(three))
  4168. {
  4169. //查询航司名称
  4170. var threeCodeTwo = three.Substring(0, 2);
  4171. var ac = _sqlSugar.Queryable<Res_AirCompany>().Where(x => x.ShortCode == threeCodeTwo).First();
  4172. if (ac != null)
  4173. {
  4174. dics.Add("AirName", $"{ac?.EnName ?? ""} {three}"); //入境口岸
  4175. }
  4176. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == threeCodeTwo).First();
  4177. if (tc != null)
  4178. {
  4179. county = tc.Country;
  4180. city = tc.City;
  4181. dics.Add("PortOfEntry", tc?.City ?? ""); //入境口岸
  4182. }
  4183. }
  4184. }
  4185. //团组信息
  4186. if (groupInfo != null)
  4187. {
  4188. dics.Add("Destination", groupInfo?.VisitPurpose ?? ""); //出访目的 Destination2
  4189. //DickeyValue.Add("Destination2", dgi.VisitCountry); //出访目的地
  4190. }
  4191. if (!string.IsNullOrEmpty(city))
  4192. {
  4193. //得到当前国家下的城市酒店信息
  4194. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  4195. .Where(x => x.DiId == groupId)
  4196. .Where(x => x.City.contains(city))
  4197. .First();
  4198. //酒店住址
  4199. if (hotelInfo != null)
  4200. {
  4201. dics.Add("HotalName", hotelInfo?.HotelName ?? ""); //酒店名称
  4202. dics.Add("HotalAddress", hotelInfo?.HotelAddress ?? ""); //酒店地址
  4203. dics.Add("HotalTel", hotelInfo?.HotelTel ?? ""); //酒店电话
  4204. }
  4205. }
  4206. dics.Add("Tel", custInfo?.Tel ?? "");//移动电话
  4207. dics.Add("Client", companyInfos?.FirstOrDefault()?.Company ?? "");//单位名称
  4208. dics.Add("ClientPhone", companyInfos?.FirstOrDefault()?.Phone ?? "");//单位电话
  4209. dics.Add("ClientAddress", companyInfos?.FirstOrDefault()?.CompanyAddress ?? "");//单位地址
  4210. dics.Add("Job", custInfo?.Job ?? "");//职务
  4211. dics.Add("MateJob", custInfo?.MateJob ?? "");//配偶职务
  4212. //InvitingPartyInfo RB_IP = new InvitingPartyInfoService().GetAddSelect(int.Parse(ddlTeamNames.SelectedValue), RB_County, RB_City);
  4213. if (!string.IsNullOrEmpty(county) && !string.IsNullOrEmpty(city))
  4214. {
  4215. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  4216. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  4217. .Where(x => x.Country.Contains(county))
  4218. .Where(x => x.Area.Contains(city))
  4219. .First();
  4220. //邀请 接待单位
  4221. if (oa != null)
  4222. {
  4223. dics.Add("OA12", oa?.Contact ?? ""); //接待单位联系人
  4224. dics.Add("OAJob", oa?.Job ?? ""); //接待联系人职务
  4225. dics.Add("OATel", oa?.Tel ?? ""); //接待单位电话
  4226. dics.Add("OAAddress", oa?.Address ?? "");//接待单位地址
  4227. dics.Add("ApplicantGuanxi", "邀请方"); //和申请人关系
  4228. dics.Add("OACountry", "日本"); //邀请方国家
  4229. dics.Add("OADan", "同上"); // 同上
  4230. dics.Add("OAJob1", "同上"); //接待联系人职务
  4231. dics.Add("OATel1", "同上"); // 同上
  4232. dics.Add("OAAddress1", "同上"); // 同上
  4233. dics.Add("ApplicantGuanxi1", "同上"); // 同上
  4234. dics.Add("OACountry1", "同上"); //邀请方国家
  4235. }
  4236. }
  4237. dics.Add("NowTime", DateTime.Now.ToString("yyyy/MM/dd")); //获取当前系统时间
  4238. #endregion
  4239. #region 生成文件
  4240. try
  4241. {
  4242. Document doc = new(currTempPath);
  4243. Aspose.Words.DocumentBuilder builder = new(doc);
  4244. string strTemp = "";
  4245. //循环键值对
  4246. foreach (var key in dics.Keys)
  4247. {
  4248. //将光标移入书签的位置
  4249. builder.MoveToBookmark(key);
  4250. //判断书签值是否为空
  4251. if (!string.IsNullOrEmpty(dics[key]))
  4252. {
  4253. strTemp = dics[key];
  4254. }
  4255. else strTemp = "";
  4256. //填充书签
  4257. builder.Write(strTemp.Replace("\\N", "\n"));
  4258. }
  4259. var custName = custInfo?.LastName + custInfo?.FirstName;
  4260. string fileName = $"{custName}_{visaTypeName}.doc";
  4261. var currFilePath = $"{jpnSavePath}{fileName}";
  4262. doc.Save(currFilePath);
  4263. filePaths.Add(currFilePath);
  4264. }
  4265. catch (Exception ex)
  4266. {
  4267. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4268. }
  4269. #endregion
  4270. }
  4271. break;
  4272. case 3: // 韩国
  4273. visaTypeName = $"韩国签证申请表";
  4274. currTempPath = $"{tempPath}{visaTypeName}.doc";
  4275. var korSavePath = $"{fileServerPath}{visaTypeName}/";
  4276. if (!Directory.Exists(fileServerPath)) Directory.CreateDirectory(korSavePath);
  4277. foreach (var custInfo in groupCustInfos)
  4278. {
  4279. EncryptionProcessor.DecryptProperties(custInfo);
  4280. Dictionary<string, string> dics = new();
  4281. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  4282. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  4283. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  4284. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4285. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4286. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4287. #region 韩国签证模板书签
  4288. dics.Add("LastNameEn", custInfo?.LastName ?? "");//姓
  4289. dics.Add("FirstNameEn", custInfo?.FirstName ?? "");//名
  4290. var userName = $"{custInfo?.LastName ?? ""}{custInfo?.FirstName ?? ""}";
  4291. dics.Add("User", userName);//姓名
  4292. //判断性别
  4293. if (custInfo.Sex == 0)
  4294. dics.Add("SexMale", "√");
  4295. else if (custInfo.Sex == 1)
  4296. dics.Add("SexFemale", "√");
  4297. string idCard = idInfo.CertNo;
  4298. string birthday = string.Empty;
  4299. if (!string.IsNullOrEmpty(idCard))
  4300. {
  4301. string year = idCard.Substring(6, 4);
  4302. string month = idCard.Substring(10, 2);
  4303. string day = idCard.Substring(12, 2);
  4304. birthday = year + "/" + month + "/" + day;
  4305. }
  4306. dics.Add("BirthDay", birthday);//出生日期
  4307. dics.Add("Nationality", "中国");//国籍
  4308. dics.Add("NationalityCountry", "中国");//出生国
  4309. dics.Add("IdCard", idCard);//身份证号码
  4310. dics.Add("OtherPassProt", "√"); //默认没有其他护照
  4311. //判断是否否曾用名 是否申请过该国家
  4312. string isGetSchengenStr = custInfo.IsGetSchengen == 0 ? "否" : "是";
  4313. if (!string.IsNullOrEmpty(custInfo.OldName) && isGetSchengenStr.equals("是"))
  4314. {
  4315. dics.Add("IsGetSchengenYes", "√");
  4316. string oldName = custInfo?.OldName ?? "";
  4317. if (!string.IsNullOrEmpty(oldName))
  4318. {
  4319. dics.Add("OldLastName", oldName.Substring(0, 1));
  4320. dics.Add("OldFirstName", oldName.Remove(0, 1));
  4321. }
  4322. }
  4323. else
  4324. dics.Add("IsGetSchengenNo", "√");
  4325. dics.Add("IsDoubleNationality", "√"); //默认没有双重国籍
  4326. //护照
  4327. if (passportInfo != null)
  4328. {
  4329. dics.Add("PassprotNo", passportInfo?.CertNo ?? ""); // 护照編號
  4330. dics.Add("PassprotCountry", passportInfo?.Country ?? ""); // 护照签发国
  4331. dics.Add("PassprotIssuePlase", passportInfo?.Area ?? ""); // 护照签发地
  4332. dics.Add("PassprotStartTime", passportInfo?.IssueDt?.ToString("yyyy-MM-dd") ?? ""); //护照开始时间
  4333. dics.Add("PassprotEndTime", passportInfo?.ExpiryDt?.ToString("yyyy-MM-dd") ?? ""); // 护照过期时间
  4334. }
  4335. dics.Add("Address", custInfo?.Address ?? "");//现居家庭地址
  4336. dics.Add("Tel1", custInfo?.Tel ?? "");//移动电话 /家庭电话 /电子信箱
  4337. //dics.Add("Tel2", );//电子信箱
  4338. dics.Add("Email", custInfo?.Email ?? "");//电子信箱
  4339. //判断婚姻状况
  4340. var marriage = custInfo.Marriage switch
  4341. {
  4342. 1 => "未婚",
  4343. 2 => "已婚",
  4344. 3 => "离异",
  4345. 4 => "丧偶",
  4346. _ => "未设置"
  4347. };
  4348. if (marriage.Contains("未婚") || marriage == null || marriage == "")
  4349. dics.Add("Single", "√");
  4350. else if (marriage == "已婚")
  4351. dics.Add("Married", "√");
  4352. else if (marriage == "离婚" || marriage == "离异")
  4353. dics.Add("Divorced", "√");
  4354. //判断是否已婚 已婚则输出配偶信息
  4355. if (marriage == "已婚")
  4356. {
  4357. string mateName = custInfo?.MateName ?? "";
  4358. if (!string.IsNullOrEmpty(mateName))
  4359. {
  4360. try
  4361. {
  4362. string mateFirstName = mateName.Remove(0, 1);
  4363. dics.Add("MateLastName", mateName.Substring(0, 1)); //配偶姓
  4364. dics.Add("MateFirstName", mateFirstName); //配偶名
  4365. //dics.Add("MateLastName", MateName.Substring(0, 1)); //配偶姓
  4366. //dics.Add("MateFirstName", MateName.Substring(1, MateName.Length - 1)); //配偶名
  4367. }
  4368. catch { }
  4369. dics.Add("MateBirthDay", custInfo?.MateBirthDay.ToString("yyyy-MM-dd")); //配偶生日
  4370. //dics.Add("MateNationality", custInfo.ma.ToString()); //配偶国籍
  4371. //dics.Add("MateTel", custInfo..ToString()); //配偶联系电话
  4372. dics.Add("MateAddress", custInfo.MateAddress.ToString()); //配偶居住地址
  4373. //家人信息书签
  4374. if (currFamilyInfos.Count > 0)
  4375. {
  4376. //定义接受子女人数
  4377. int children = currFamilyInfos.Where(x => x.Appellation.contains("儿子") || x.Appellation.contains("女儿")).ToList().Count;
  4378. //判断子女人数
  4379. if (children == 0) //无子女
  4380. dics.Add("NoChildren", "√"); //未查询出 则无子女
  4381. else
  4382. {
  4383. dics.Add("HaveChildren", "√");
  4384. dics.Add("ChildrenNum", children.ToString());//有子女则输出人数
  4385. }
  4386. }
  4387. else
  4388. dics.Add("NoChildren", "√"); //未查询出 则无子女
  4389. }
  4390. }
  4391. else
  4392. dics.Add("NoChildren", "√"); //未婚则无子女
  4393. //学历
  4394. if (custInfo.HighestEducation.Contains("硕士") || custInfo.HighestEducation.Contains("博士"))
  4395. dics.Add("Master", "√");
  4396. else if (custInfo.HighestEducation.Contains("学士"))
  4397. dics.Add("Bachelor", "√");
  4398. else if (custInfo.HighestEducation.Contains("高中"))
  4399. dics.Add("HighSchool", "√");
  4400. else
  4401. {
  4402. dics.Add("Other", "√");
  4403. dics.Add("OtherDetails", custInfo.HighestEducation.Trim());
  4404. }
  4405. //dics.Add("Job", custInfo.Job.ToString()); ;//职业
  4406. dics.Add("Company", companyInfos.FirstOrDefault()?.Company ?? "");//单位名称
  4407. dics.Add("jobs", companyInfos.FirstOrDefault()?.Job ?? ""); //职务
  4408. dics.Add("CompanyAddress", companyInfos.FirstOrDefault()?.CompanyAddress ?? "");//单位地址
  4409. dics.Add("CompanyTel", companyInfos.FirstOrDefault()?.Phone ?? "");//单位电话
  4410. string day1 = ""; //得到抵达日期
  4411. string day2 = ""; //得到离开日期
  4412. string country = groupInfo.VisitCountry; //国家名
  4413. string HG_City = ""; //城市
  4414. string HG_Country = "";//国家
  4415. string[] HG_countryName = new string[] { };
  4416. if (!string.IsNullOrEmpty(country))
  4417. {
  4418. //处理国家名
  4419. if (country.Contains(" "))
  4420. HG_countryName = country.Split(' ');
  4421. else if (country.Contains(","))
  4422. HG_countryName = country.Split(',');
  4423. else if (country.Contains(","))
  4424. HG_countryName = country.Split(',');
  4425. else if (country.Contains("、"))
  4426. HG_countryName = country.Split('、');
  4427. }
  4428. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  4429. int k = 0;
  4430. for (int i = 0; i < HG_countryName.Length; i++)
  4431. {
  4432. for (int j = 0; j < atbc.Rows.Count; j++)
  4433. {
  4434. string HL_Three = atbc.Rows[j]["Three"].ToString();
  4435. if (!string.IsNullOrEmpty(HL_Three))
  4436. {
  4437. var hl_three = HL_Three.Substring(3);
  4438. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == hl_three).First();
  4439. if (tc != null)
  4440. {
  4441. HG_Country = HG_countryName[i];
  4442. HG_City = tc.City; //得到当前国家 城市名
  4443. day1 = atbc.Rows[j]["Day"].ToString(); //得到抵达日期
  4444. k = j + 1;
  4445. }
  4446. }
  4447. if (k == j)
  4448. day2 = atbc.Rows[j]["Day"].ToString(); //离开航班起飞时间
  4449. }
  4450. }
  4451. if (atbc != null)
  4452. {
  4453. if (day2 != null && day1 != null)
  4454. {
  4455. try
  4456. {
  4457. int Han_day = (Convert.ToDateTime(day2) - Convert.ToDateTime(day1)).Days; //得到天数
  4458. dics.Add("Days", Han_day.ToString() + "天");//滞留天数
  4459. dics.Add("EntryTime", day1.ToString());//入境日期 TemporaryAddress
  4460. }
  4461. catch (Exception) { }
  4462. }
  4463. }
  4464. //得到当前国家下的城市酒店信息
  4465. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  4466. .Where(x => x.DiId == groupId)
  4467. .Where(x => x.City.contains(HG_City))
  4468. .First();
  4469. //访问信息
  4470. if (hotelInfo != null)
  4471. {
  4472. dics.Add("TemporaryAddress", hotelInfo?.HotelAddress ?? "");//停留酒店地址 TATel
  4473. dics.Add("TATel", hotelInfo?.HotelTel ?? ""); //停留酒店联系电话
  4474. }
  4475. if (!string.IsNullOrEmpty(HG_Country) && !string.IsNullOrEmpty(HG_City))
  4476. {
  4477. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  4478. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  4479. .Where(x => x.Country.Contains(HG_Country))
  4480. .Where(x => x.Area.Contains(HG_City))
  4481. .First();
  4482. //在韩邀请方信息
  4483. if (oa != null)
  4484. {
  4485. dics.Add("IsYes", "√");
  4486. dics.Add("TT", oa?.Contact ?? ""); //联系人
  4487. dics.Add("TTAddress", oa?.Address ?? ""); //联系地址
  4488. dics.Add("TTtel", oa?.Tel ?? ""); //联系电话
  4489. dics.Add("TTGuanxi", "BY INVITED"); //和在邀联系人关系
  4490. }
  4491. else
  4492. dics.Add("IsNo", "√");
  4493. }
  4494. //费用信息
  4495. if (groupInfo != null)
  4496. {
  4497. //dics.Add("Payer", "Unit"); //在外期间费用承担
  4498. dics.Add("Team1", groupInfo.ClientUnit); //客户单位名称
  4499. dics.Add("Team12", "雇佣"); //与申请人关系 BY INVITED
  4500. dics.Add("PriceType", "Payment By Unit"); //资金类型
  4501. dics.Add("TeamNameTel", custInfo.ClientPhone); //联系方式
  4502. }
  4503. //是否有协助填表人
  4504. if (!string.IsNullOrEmpty(custInfo.TableOpName))
  4505. dics.Add("WirteTableNo", "√");
  4506. else
  4507. {
  4508. dics.Add("WirteTableYes", "√");
  4509. dics.Add("OpTableName", custInfo.TableOpName.ToString()); //协助填表人姓名
  4510. //dics.Add("OpTableDateTime",custInfo.OpDate.ToString()); //填表时间
  4511. dics.Add("OpTableTel", custInfo.TableOpTel.ToString()); //协助人联系电话
  4512. dics.Add("OpTableGuanXi", "雇佣"); //和协助人关系
  4513. }
  4514. dics.Add("NowDateTime", DateTime.Now.ToString("yyyy/MM/dd")); //获取当前系统时间
  4515. dics.Add("ApplicantName", custInfo.LastName + " " + custInfo.FirstName); //申请人
  4516. #endregion
  4517. #region 生成文件
  4518. try
  4519. {
  4520. Document doc = new(currTempPath);
  4521. Aspose.Words.DocumentBuilder builder = new(doc);
  4522. string strTemp = "";
  4523. //循环键值对
  4524. foreach (var key in dics.Keys)
  4525. {
  4526. //将光标移入书签的位置
  4527. builder.MoveToBookmark(key);
  4528. //判断书签值是否为空
  4529. if (!string.IsNullOrEmpty(dics[key]))
  4530. {
  4531. strTemp = dics[key];
  4532. }
  4533. else strTemp = "";
  4534. //填充书签
  4535. builder.Write(strTemp.Replace("\\N", "\n"));
  4536. }
  4537. var custName = custInfo.LastName + custInfo.FirstName;
  4538. string fileName = $"{custName}_{visaTypeName}.doc";
  4539. var currFilePath = $"{korSavePath}{fileName}";
  4540. doc.Save(currFilePath);
  4541. filePaths.Add(currFilePath);
  4542. }
  4543. catch (Exception ex)
  4544. {
  4545. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4546. }
  4547. #endregion
  4548. }
  4549. break;
  4550. case 4: // 瑞典
  4551. visaTypeName = $"瑞典签证申请表";
  4552. currTempPath = $"{tempPath}{visaTypeName}.pdf";
  4553. var swedenSavePath = $"{fileServerPath}{visaTypeName}/";
  4554. if (!Directory.Exists(swedenSavePath)) Directory.CreateDirectory(swedenSavePath);
  4555. if (!System.IO.File.Exists(currTempPath))
  4556. {
  4557. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4558. }
  4559. foreach (var custInfo in groupCustInfos)
  4560. {
  4561. EncryptionProcessor.DecryptProperties(custInfo);
  4562. var idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773);
  4563. var passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774);
  4564. var clinetInfo = companyInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.Id == custInfo.CrmCompanyId);
  4565. var currSchoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4566. var currFamilyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4567. var currCompanyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList();
  4568. #region 生成文件
  4569. PdfReader reader = null;
  4570. FileStream templateStream = null;
  4571. FileStream outputStream = null;
  4572. PdfStamper stamper = null;
  4573. try
  4574. {
  4575. string outputPath = $"{swedenSavePath}{custInfo.LastName}{custInfo.FirstName}.pdf";
  4576. //读取模板文件
  4577. templateStream = new FileStream(currTempPath, FileMode.Open, FileAccess.Read, FileShare.Read);
  4578. reader = new PdfReader(templateStream);
  4579. //创建输出文件
  4580. outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write);
  4581. stamper = new PdfStamper(reader, outputStream);
  4582. AcroFields formFields = stamper.AcroFields;
  4583. #region 设置文本值
  4584. SetFieldValue(formFields, "LastName", custInfo.LastName); //姓
  4585. SetFieldValue(formFields, "BirthLastName", custInfo.LastName); // 出生时姓氏
  4586. SetFieldValue(formFields, "FirstName", custInfo.FirstName); // 名
  4587. // 出生日期(日-月-年)
  4588. string idCard = idInfo.CertNo;
  4589. string birthday = string.Empty;
  4590. if (!string.IsNullOrEmpty(idCard))
  4591. {
  4592. string year = idCard.Substring(6, 4);
  4593. string month = idCard.Substring(10, 2);
  4594. string day = idCard.Substring(12, 2);
  4595. birthday = day + "-" + month + "-" + year;
  4596. }
  4597. SetFieldValue(formFields, "Birthday", birthday);
  4598. string currentNationality = custInfo.BirthProvince + custInfo.BirthCity;
  4599. SetFieldValue(formFields, "CurrentNationality", currentNationality); // 出生地
  4600. SetFieldValue(formFields, "CountryBirth","中国"); // 出生国
  4601. SetFieldValue(formFields, "CurrentNationalityCountry", "中国"); // 现国籍
  4602. SetFieldValue(formFields, "NationalityBirth", ""); // 出生时国籍,如与现国籍不同
  4603. SetFieldValue(formFields, "OtherNationalities", ""); // 其他国籍
  4604. #region 性别处理
  4605. //清除性别
  4606. SetFieldValue(formFields, "Male", "Off"); // 性别 - 男
  4607. SetFieldValue(formFields, "Female", "Off"); // 性别 - 女
  4608. //设置性别
  4609. if (custInfo.Sex == 0) //男
  4610. {
  4611. SetFieldValue(formFields, "Male", "Yes"); // 性别 - 男
  4612. }
  4613. else if (custInfo.Sex == 1) //女
  4614. {
  4615. SetFieldValue(formFields, "Female", "Yes"); // 性别 - 女
  4616. }
  4617. #endregion
  4618. #region 婚姻状况处理
  4619. //清除婚姻状况
  4620. SetFieldValue(formFields, "Single", "Off"); // 婚姻状况 - 未婚
  4621. SetFieldValue(formFields, "Married", "Off"); // 婚姻状况 - 已婚
  4622. SetFieldValue(formFields, "RegisteredPartnership", "Off"); // 婚姻状况 - 注册伴侣关系
  4623. SetFieldValue(formFields, "Separated", "Off"); // 婚姻状况 - 分居
  4624. SetFieldValue(formFields, "Divorced", "Off"); // 婚姻状况 - 离婚
  4625. SetFieldValue(formFields, "Widow(er)", "Off"); // 婚姻状况 - 丧偶
  4626. SetFieldValue(formFields, "OtherCivilStatus", "Off"); // 婚姻状况 - 其它
  4627. SetFieldValue(formFields, "CivilStatusOther", ""); // 婚姻状况 - 其它(请注明)
  4628. //设置婚姻状况
  4629. switch (custInfo.Marriage)
  4630. {
  4631. case 1: // 未婚
  4632. SetFieldValue(formFields, "Single", "Yes");
  4633. break;
  4634. case 2: // 已婚
  4635. SetFieldValue(formFields, "Married", "Yes");
  4636. break;
  4637. case 3: // 离异
  4638. SetFieldValue(formFields, "Divorced", "Yes");
  4639. break;
  4640. case 4: // 离异
  4641. SetFieldValue(formFields, "Widow(er)", "Yes");
  4642. break;
  4643. }
  4644. #endregion
  4645. //亲权人(如是未成年申请人 )/合法监护人(姓名、住址,如与申请人不同) 电话号码、电子邮件及国籍
  4646. SetFieldValue(formFields, "ParentalAuthority", "");
  4647. SetFieldValue(formFields, "NationalIdentityNumber", idCard); //公民身份证号码
  4648. #region 护照(旅行证件类型)处理
  4649. //清除值
  4650. SetFieldValue(formFields, "OrdinaryPassport", "Off"); //旅行证件类型 - 普通护照
  4651. SetFieldValue(formFields, "DiplomaticPassport", "Off"); //旅行证件类型 - 外交护照
  4652. SetFieldValue(formFields, "ServicePassport", "Off"); //旅行证件类型 - 公务护照
  4653. SetFieldValue(formFields, "OfficialPassport", "Off"); //旅行证件类型 - 因公护照
  4654. SetFieldValue(formFields, "SpecialPassport", "Off"); //旅行证件类型 - 特殊护照
  4655. SetFieldValue(formFields, "OtherTravel", "Off"); //旅行证件类型 - 其它旅行证件
  4656. SetFieldValue(formFields, "OtherTravelDesc", ""); //旅行证件类型 - 其它旅行证件(请注明)
  4657. //设置值
  4658. SetFieldValue(formFields, "OrdinaryPassport", "Yes"); //旅行证件类型 - 普通护照
  4659. if (passportInfo != null)
  4660. {
  4661. SetFieldValue(formFields, "TravelNumber", passportInfo.CertNo); //旅行证件编号
  4662. SetFieldValue(formFields, "IssueDate", passportInfo.IssueDt?.ToString("yyyy-MM-dd") ?? ""); //签发日期
  4663. SetFieldValue(formFields, "ValidUntil", passportInfo.ExpiryDt?.ToString("yyyy-MM-dd") ?? ""); //有效期至
  4664. SetFieldValue(formFields, "IssuedCountry", passportInfo.Country); //签发(国)
  4665. }
  4666. #endregion
  4667. //如有家庭成员为欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的,请填写该家庭成员的个人信息
  4668. SetFieldValue(formFields, "LastName_om", ""); //姓
  4669. SetFieldValue(formFields, "FirstName_om", ""); //名
  4670. SetFieldValue(formFields, "BirthDate_om", ""); //出生日期(日-月-年)
  4671. SetFieldValue(formFields, "Nationality_om", ""); //国籍
  4672. SetFieldValue(formFields, "TravelNuber_om", ""); //旅行证件或身分证编号
  4673. //申请人与欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的关系
  4674. SetFieldValue(formFields, "Spouse_om", ""); //配偶
  4675. SetFieldValue(formFields, "RegisteredPartnership_om", ""); //注册伴侣
  4676. SetFieldValue(formFields, "Child_om", ""); //子女
  4677. SetFieldValue(formFields, "DependentAscendant_om", ""); //受养人
  4678. SetFieldValue(formFields, "Grandchild_om", ""); //孙子女
  4679. SetFieldValue(formFields, "FamilyOther_om", ""); //其他
  4680. SetFieldValue(formFields, "FamilyOtherDesc_om", ""); //其他(说明)
  4681. //申请人住址及电子邮件
  4682. string applicantHomeAddress = $"{custInfo.Address} {custInfo.Email}";
  4683. SetFieldValue(formFields, "ApplicantHomeAddress", applicantHomeAddress); //申请人住址及电子邮件
  4684. SetFieldValue(formFields, "TelephoneNo", custInfo.Tel); //电话号码
  4685. //是否居住在现时国籍以外的国家
  4686. SetFieldValue(formFields, "AnotherCountryNo", "Yes"); //否
  4687. SetFieldValue(formFields, "AnotherCountryYes", ""); //是。
  4688. SetFieldValue(formFields, "ResidencePermit", ""); //居住许可或同等证
  4689. SetFieldValue(formFields, "Number", ""); //编号
  4690. SetFieldValue(formFields, "ValidUntils", ""); //有效期至
  4691. SetFieldValue(formFields, "CurrentOccupation", custInfo.Job); //当前职业
  4692. //工作单位名称,地址和电话,学生填写学校名称及地址
  4693. var currCompanyInfo = currCompanyInfos.FirstOrDefault();
  4694. string employerInfoStr = $"{currCompanyInfo?.Company ?? ""} {currCompanyInfo?.CompanyAddress ?? ""} {currCompanyInfo?.Phone ?? ""}";
  4695. SetFieldValue(formFields, "EmployerInfo", employerInfoStr);
  4696. #region 旅行的目的
  4697. //清空值
  4698. SetFieldValue(formFields, "Tourism", "Off"); //旅游
  4699. SetFieldValue(formFields, "Business", "Off"); //商务
  4700. SetFieldValue(formFields, "VisitingFamily", "Off"); //探亲访友
  4701. SetFieldValue(formFields, "Cultural", "Off"); //文化
  4702. SetFieldValue(formFields, "Sports", "Off"); //体育
  4703. SetFieldValue(formFields, "OfficialVisit", "Off"); //官方访问
  4704. SetFieldValue(formFields, "MedicalReasons", "Off"); //医疗
  4705. SetFieldValue(formFields, "Study", "Off"); //学习
  4706. SetFieldValue(formFields, "AirportTransit", "Off"); //机场过境
  4707. SetFieldValue(formFields, "Other", "Off"); //其它
  4708. SetFieldValue(formFields, "OtherDesc", ""); //其它 (请注明)
  4709. //设置值
  4710. if (groupInfo.VisitPurpose.contains("旅游")) SetFieldValue(formFields, "Tourism", "Yes"); //旅游
  4711. if (groupInfo.VisitPurpose.contains("商务")) SetFieldValue(formFields, "Business", "Yes"); //商务
  4712. if (groupInfo.VisitPurpose.contains("探亲访友")) SetFieldValue(formFields, "VisitingFamily", "Yes"); //探亲访友
  4713. if (groupInfo.VisitPurpose.contains("文化")) SetFieldValue(formFields, "Cultural", "Yes"); //文化
  4714. if (groupInfo.VisitPurpose.contains("体育")) SetFieldValue(formFields, "Sports", "Yes"); //体育
  4715. if (groupInfo.VisitPurpose.contains("官方访问")) SetFieldValue(formFields, "OfficialVisit", "Yes"); //官方访问
  4716. if (groupInfo.VisitPurpose.contains("医疗")) SetFieldValue(formFields, "MedicalReasons", "Yes"); //医疗
  4717. if (groupInfo.VisitPurpose.contains("学习")) SetFieldValue(formFields, "Study", "Yes"); //学习
  4718. if (groupInfo.VisitPurpose.contains("机场过境")) SetFieldValue(formFields, "AirportTransit", "Yes"); //机场过境
  4719. #endregion
  4720. SetFieldValue(formFields, "AdditionalInfo", ""); //有关停留原因的补充信息
  4721. string[] RD_country = new string[] { }; //接收处理的国家
  4722. string firstEntryLabel = string.Empty; //首入申根国标签
  4723. string membeDescLabel = string.Empty; //申根国目的地
  4724. string stopDays = string.Empty; //停留天数
  4725. if (!string.IsNullOrEmpty(groupInfo.VisitCountry))
  4726. {
  4727. List<string> SGGNames = new List<string>();//接收处理后的国家 是申根国
  4728. if (groupInfo.VisitCountry.Contains(","))
  4729. RD_country = groupInfo.VisitCountry.Split(',');
  4730. else if (groupInfo.VisitCountry.Contains(' '))
  4731. RD_country = groupInfo.VisitCountry.Split(' ');
  4732. else if (groupInfo.VisitCountry.Contains(","))
  4733. RD_country = groupInfo.VisitCountry.Split(',');
  4734. else if (groupInfo.VisitCountry.Contains("、"))
  4735. RD_country = groupInfo.VisitCountry.Split('、');
  4736. else if (groupInfo.VisitCountry.Contains("|"))
  4737. RD_country = groupInfo.VisitCountry.Split('|');
  4738. //判断是否是申根国家
  4739. for (int i = 0; i < RD_country.Length; i++)
  4740. {
  4741. if (RD_country[i].ToString() != null)
  4742. {
  4743. //在申根国家中筛选 该国家是否是申根国家
  4744. for (int j = 0; j < _shenGenGuos.Length; j++)
  4745. {
  4746. if (RD_country[i] == _shenGenGuos[j])
  4747. SGGNames.Add(_shenGenGuos[j]); //添加申根国
  4748. }
  4749. }
  4750. }
  4751. //目的地国是否有申根国
  4752. if (SGGNames.Count > 0)
  4753. {
  4754. firstEntryLabel = SGGNames.First();
  4755. membeDescLabel = string.Join(",", SGGNames.ToArray());
  4756. //接收生根国详细信息 存储顺序 起飞日期:Day 起飞时刻:StartTime 抵达日期:ArrivedDate 到达时刻:EndTime
  4757. List<SSGDetails> ListSSGDetails = new List<SSGDetails>();
  4758. //处理申根国家 预定到达时间 预定离开时间 预定停留天数
  4759. for (int i = 0; i < SGGNames.Count; i++)
  4760. {
  4761. //在相同的国家下 得到该航班的信息 //抵达时间 起飞日期:Day 起飞时刻:StartTime 到达时刻:EndTime 抵达日期:ArrivedDate 飞行时间:FlightTime 航司 Fliagtcode 入境口岸
  4762. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  4763. //ResidenceTime1 机票三字码信息
  4764. if (atbc != null)
  4765. {
  4766. string HL_Three = ""; //三字码 Three
  4767. for (int j = 0; j < atbc.Rows.Count; j++)
  4768. {
  4769. HL_Three = atbc.Rows[j]["Three"].ToString();
  4770. if (!string.IsNullOrEmpty(HL_Three))
  4771. {
  4772. string threeCodeTwo = HL_Three.Substring(3);
  4773. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == threeCodeTwo).First();
  4774. if (tc != null)
  4775. {
  4776. //首入申根国时间
  4777. if (SGGNames[i] == tc.Country)
  4778. {
  4779. SSGDetails SSGDetails = new SSGDetails()
  4780. {
  4781. Three = atbc.Rows[j]["Three"].ToString(), //三字码
  4782. Fliagtcode = atbc.Rows[j]["Fliagtcode"].ToString(), //航司
  4783. startDate = atbc.Rows[j]["Day"].ToString(), //整理起飞日期
  4784. startTime = atbc.Rows[j]["StartTime"].ToString(), //整理起飞时刻
  4785. endDate = atbc.Rows[j]["ArrivedDate"].ToString(), //整理抵达日期
  4786. endTime = atbc.Rows[j]["EndTime"].ToString() //整理抵达时刻
  4787. };
  4788. ListSSGDetails.Add(SSGDetails);
  4789. }
  4790. }
  4791. }
  4792. }
  4793. }
  4794. }
  4795. ListSSGDetails.Sort((a, b) => a.startDate.CompareTo(b.startDate));
  4796. //得到并计算出入境时间
  4797. if (ListSSGDetails != null)
  4798. {
  4799. string RuJingTime = ListSSGDetails.First().endDate + " " + ListSSGDetails.First().endTime.Substring(0, 2) + ":" + ListSSGDetails.First().endTime.Substring(2); //入境时间
  4800. string LiJingTime = ListSSGDetails[ListSSGDetails.Count - 1].startDate + " " + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(0, 2) + ":" + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(2); //离境时间
  4801. stopDays = Convert.ToDateTime(LiJingTime).Subtract(Convert.ToDateTime(RuJingTime)).Days.ToString();
  4802. }
  4803. }
  4804. }
  4805. SetFieldValue(formFields, "MembeDesc", membeDescLabel); //主要申根目的地 (以及其他申根目的地,如适用)
  4806. SetFieldValue(formFields, "FirstEntry", firstEntryLabel); //首入申根国
  4807. //申请入境次数
  4808. SetFieldValue(formFields, "27.SingleEntry", ""); //单次
  4809. SetFieldValue(formFields, "27.TwoEntries", ""); //两次
  4810. SetFieldValue(formFields, "27.MultipleEntries", ""); //多次
  4811. SetFieldValue(formFields, "27.IntendedDateIn", ""); //在申根地区预计首次停留的预计抵达日期
  4812. SetFieldValue(formFields, "27.IntendedDateOut", ""); //在申根地区预计首次停留之后的预计离开日期
  4813. //以往申根国签证是否有指纹记录
  4814. SetFieldValue(formFields, "28.No", ""); //否
  4815. SetFieldValue(formFields, "28.Yes", ""); //是
  4816. SetFieldValue(formFields, "28.KnownDate", ""); //如有,请写明日期
  4817. SetFieldValue(formFields, "28.KnownVisanumber", ""); //如有,请写明签证贴纸号码
  4818. //最后目的地之入境许可
  4819. SetFieldValue(formFields, "29.Issued", ""); //签发机关
  4820. SetFieldValue(formFields, "29.ValidFrom", ""); //有效期由
  4821. SetFieldValue(formFields, "29.Until", ""); //至
  4822. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  4823. //得到当前国家下的城市酒店信息
  4824. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  4825. .Where(x => x.DiId == groupId)
  4826. //.Where(x => x.City.contains(city))
  4827. .First();
  4828. //酒店住址
  4829. if (hotelInfo != null)
  4830. {
  4831. SetFieldValue(formFields, "30.SurnameFirstName", hotelInfo?.HotelName ?? ""); //申根国的酒店
  4832. var otherInfo = $"{hotelInfo.HotelAddress}";
  4833. SetFieldValue(formFields, "30.HotelInfo", otherInfo); //邀请人/酒店/暂住居所的地址及电子邮件
  4834. SetFieldValue(formFields, "30.TelephoneNo", hotelInfo?.HotelTel ?? ""); //电话号码
  4835. }
  4836. //邀请公司或机构的名称及地址
  4837. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  4838. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  4839. //.Where(x => x.Country.Contains(county))
  4840. //.Where(x => x.Area.Contains(city))
  4841. .First();
  4842. if (oa != null)
  4843. {
  4844. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  4845. SetFieldValue(formFields, "30.SurnameFirstName", oa?.Contact ?? ""); //申根国的酒店
  4846. SetFieldValue(formFields, "30.HotelInfo", oa?.Address ?? ""); //邀请人/酒店/暂住居所的地址及电子邮件
  4847. SetFieldValue(formFields, "30.TelephoneNo", oa?.Tel ?? ""); //电话号码
  4848. string nameAddressLabel = $"{oa.Client} {oa.Address}";
  4849. SetFieldValue(formFields, "31.NameAddress", nameAddressLabel); //邀请公司或机构的名称及地址
  4850. string surnameLabel = $"{oa.Contact} {oa.Tel}";
  4851. SetFieldValue(formFields, "31.Surname", surnameLabel); //邀请公司或机构的联系人姓名、地址、电话号码及电子邮件
  4852. SetFieldValue(formFields, "31.TelephoneNo", oa?.Tel ?? ""); //邀请公司或机构的电话
  4853. }
  4854. //申请人的旅费以及在国外停留期间的生活费用
  4855. SetFieldValue(formFields, "32.Applicant", ""); //由申请人支付
  4856. SetFieldValue(formFields, "32.Cash", ""); //支付方式 - 现金
  4857. SetFieldValue(formFields, "32.Traveller", ""); //支付方式 - 旅行支票
  4858. SetFieldValue(formFields, "32.CreditCard", ""); //支付方式 - 信用卡
  4859. SetFieldValue(formFields, "32.Prepaid", ""); //支付方式 - 预缴住宿
  4860. SetFieldValue(formFields, "32.Prepaid1", ""); //支付方式 - 预缴交通
  4861. SetFieldValue(formFields, "32.OtherMeans", ""); //支付方式 - 其它
  4862. SetFieldValue(formFields, "32.OtherMeansDesc", ""); //支付方式 - 其它(请注明)
  4863. SetFieldValue(formFields, "32.Sponsor", ""); //由赞助方(邀请人、公司或机构)支付,请注明
  4864. SetFieldValue(formFields, "32.Referred", ""); //参见第 30 及 31 项
  4865. SetFieldValue(formFields, "32.ReferredDesc", ""); //参见第 30 及 31 项(请注明)
  4866. SetFieldValue(formFields, "32.OtherSponsor", ""); //其它
  4867. SetFieldValue(formFields, "32.OtherSponsorDesc", ""); //其它(请注明)
  4868. SetFieldValue(formFields, "32.SponsorCash", ""); //赞助方式 - 现金
  4869. SetFieldValue(formFields, "32.SponsorAccommodation", ""); //赞助方式 - 提供住宿
  4870. SetFieldValue(formFields, "32.SponsorExpenses", ""); //赞助方式 - 支付旅程期间所有开支
  4871. SetFieldValue(formFields, "32.SponsorPrepaid", ""); //赞助方式 - 预缴交通
  4872. SetFieldValue(formFields, "32.ponsorOther", ""); //赞助方式 - 其它
  4873. SetFieldValue(formFields, "32.ponsorOtherDesc", ""); //赞助方式 - 其它(请注明)
  4874. SetFieldValue(formFields, "33.PlaceAndDate", DateTime.Now.ToString("yyyy-MM-dd")); //地点及日期
  4875. #endregion
  4876. filePaths.Add(outputPath);
  4877. //return outputPath;
  4878. }
  4879. catch (Exception ex)
  4880. {
  4881. return Ok(JsonView(false, $"生成PDF文件时出错:{ex.Message}"));
  4882. }
  4883. finally
  4884. {
  4885. // 按正确顺序关闭资源
  4886. stamper?.Close();
  4887. reader?.Close();
  4888. templateStream?.Close();
  4889. outputStream?.Close();
  4890. }
  4891. #endregion
  4892. }
  4893. break;
  4894. case 5: // 波兰
  4895. visaTypeName = $"波兰签证申请表";
  4896. currTempPath = $"{tempPath}{visaTypeName}.pdf";
  4897. var polandSavePath = $"{fileServerPath}{visaTypeName}/";
  4898. if (!Directory.Exists(polandSavePath)) Directory.CreateDirectory(polandSavePath);
  4899. if (!System.IO.File.Exists(currTempPath))
  4900. {
  4901. return Ok(JsonView(false, $"{currTempPath}模板不存在!"));
  4902. }
  4903. foreach (var custInfo in groupCustInfos)
  4904. {
  4905. EncryptionProcessor.DecryptProperties(custInfo);
  4906. var visaData = new VisaDateView() {
  4907. groupInfo = groupInfo,
  4908. idInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 773),
  4909. passportInfo = certInfos.FirstOrDefault(x => x.DcId == custInfo.Id && x.PassportType == 774),
  4910. custInfo = custInfo,
  4911. schoolInfos = schoolInfos.Where(x => x.DcId == custInfo.Id).ToList(),
  4912. familyInfos = familyInfos.Where(x => x.DcId == custInfo.Id).ToList(),
  4913. companyInfos = companyInfos.Where(x => x.DcId == custInfo.Id).ToList()
  4914. };
  4915. //生成文件
  4916. string outFilePath = CreatePolandVisaPdf(visaData, polandSavePath, currTempPath);
  4917. filePaths.Add(outFilePath);
  4918. }
  4919. break;
  4920. default:
  4921. return Ok(JsonView(false, "正在开发中,请等待。。。"));
  4922. }
  4923. //压缩文件
  4924. var zipFilePathName = $"{groupInfo.TeamName}({visaTypeName}).zip";
  4925. var zipFilePath = $"{fileServerPath}{zipFilePathName}";
  4926. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  4927. {
  4928. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  4929. {
  4930. foreach (string filePath in filePaths)
  4931. {
  4932. if (System.IO.File.Exists(filePath))
  4933. {
  4934. // 获取文件名
  4935. string fileName = Path.GetFileName(filePath);
  4936. // 将文件添加到ZIP归档中
  4937. zipArchive.CreateEntryFromFile(filePath, fileName);
  4938. }
  4939. }
  4940. }
  4941. }
  4942. url = $"{serverPath}{zipFilePathName}";
  4943. if (!string.IsNullOrEmpty(url))
  4944. {
  4945. return Ok(JsonView(true, url));
  4946. }
  4947. return Ok(JsonView(false, "操作失败!"));
  4948. }
  4949. #region iTextSharp pdf 设置值辅助方法
  4950. /// <summary>
  4951. /// 设置文本值
  4952. /// 辅助方法
  4953. /// </summary>
  4954. /// <param name="formFields"></param>
  4955. /// <param name="fieldName"></param>
  4956. /// <param name="value"></param>
  4957. private static void SetFieldValue(AcroFields formFields, string fieldName, string value)
  4958. {
  4959. if (formFields.Fields.ContainsKey(fieldName) && !string.IsNullOrEmpty(value))
  4960. {
  4961. formFields.SetField(fieldName, value);
  4962. }
  4963. }
  4964. /// <summary>
  4965. /// 创建PDF
  4966. /// </summary>
  4967. /// <param name="data"></param>
  4968. /// <param name="currSavePath"></param>
  4969. /// <param name="currTempPath"></param>
  4970. /// <returns></returns>
  4971. /// <exception cref="Exception"></exception>
  4972. private string CreatePolandVisaPdf(VisaDateView data, string currSavePath,string currTempPath)
  4973. {
  4974. var groupInfo = data.groupInfo;
  4975. var groupId = groupInfo.Id;
  4976. var idInfo = data.idInfo;
  4977. var passportInfo = data.passportInfo;
  4978. var custInfo = data.custInfo;
  4979. var currSchoolInfos = data.schoolInfos;
  4980. var currFamilyInfos = data.familyInfos;
  4981. var currCompanyInfos = data.companyInfos;
  4982. string outputPath = $"{currSavePath}{custInfo.LastName}{custInfo.FirstName}.pdf";
  4983. PdfReader reader = null;
  4984. FileStream templateStream = null;
  4985. FileStream outputStream = null;
  4986. PdfStamper stamper = null;
  4987. try
  4988. {
  4989. //读取模板文件
  4990. templateStream = new FileStream(currTempPath, FileMode.Open, FileAccess.Read, FileShare.Read);
  4991. reader = new PdfReader(templateStream);
  4992. //创建输出文件
  4993. outputStream = new FileStream(outputPath, FileMode.Create, FileAccess.Write);
  4994. stamper = new PdfStamper(reader, outputStream);
  4995. AcroFields formFields = stamper.AcroFields;
  4996. #region 设置文本值
  4997. SetFieldValue(formFields, "1.LastName", custInfo.LastName); //姓
  4998. SetFieldValue(formFields, "2.BirthLastName", custInfo.LastName); // 出生时姓氏
  4999. SetFieldValue(formFields, "3.FirstName", custInfo.FirstName); // 名
  5000. // 出生日期(日-月-年)
  5001. string idCard = idInfo.CertNo;
  5002. string birthday = string.Empty;
  5003. if (!string.IsNullOrEmpty(idCard))
  5004. {
  5005. string year = idCard.Substring(6, 4);
  5006. string month = idCard.Substring(10, 2);
  5007. string day = idCard.Substring(12, 2);
  5008. birthday = day + "-" + month + "-" + year;
  5009. }
  5010. SetFieldValue(formFields, "4.Birthday", birthday);
  5011. string currentNationality = custInfo.BirthProvince + custInfo.BirthCity;
  5012. SetFieldValue(formFields, "5.CurrentNationality", currentNationality); // 出生地
  5013. SetFieldValue(formFields, "6.CountryBirth", "中国"); // 出生国
  5014. SetFieldValue(formFields, "7.CurrentNationalityCountry", "中国"); // 现国籍
  5015. SetFieldValue(formFields, "7.NationalityBirth", ""); // 出生时国籍,如与现国籍不同
  5016. SetFieldValue(formFields, "7.OtherNationalities", ""); // 其他国籍
  5017. #region 性别处理
  5018. //清除性别
  5019. SetFieldValue(formFields, "8.Male", "Off"); // 性别 - 男
  5020. SetFieldValue(formFields, "8.Female", "Off"); // 性别 - 女
  5021. SetFieldValue(formFields, "8.Other", "Off"); // 性别 - 其他
  5022. //设置性别
  5023. if (custInfo.Sex == 0) //男
  5024. {
  5025. SetFieldValue(formFields, "8.Male", "Yes"); // 性别 - 男
  5026. }
  5027. else if (custInfo.Sex == 1) //女
  5028. {
  5029. SetFieldValue(formFields, "8.Female", "Yes"); // 性别 - 女
  5030. }
  5031. else //其他
  5032. {
  5033. SetFieldValue(formFields, "8.Other", "Yes"); // 性别 - 其他
  5034. }
  5035. #endregion
  5036. #region 婚姻状况处理
  5037. //清除婚姻状况
  5038. SetFieldValue(formFields, "9.Single", "Off"); // 婚姻状况 - 未婚
  5039. SetFieldValue(formFields, "9.Married", "Off"); // 婚姻状况 - 已婚
  5040. SetFieldValue(formFields, "9.RegisteredPartnership", "Off"); // 婚姻状况 - 注册伴侣关系
  5041. SetFieldValue(formFields, "9.Separated", "Off"); // 婚姻状况 - 分居
  5042. SetFieldValue(formFields, "9.Divorced", "Off"); // 婚姻状况 - 离婚
  5043. SetFieldValue(formFields, "9.Widow(er)", "Off"); // 婚姻状况 - 丧偶
  5044. SetFieldValue(formFields, "9.OtherCivilStatus", "Off"); // 婚姻状况 - 其它
  5045. SetFieldValue(formFields, "9.CivilStatusOther", ""); // 婚姻状况 - 其它(请注明)
  5046. //设置婚姻状况
  5047. switch (custInfo.Marriage)
  5048. {
  5049. case 1: // 未婚
  5050. SetFieldValue(formFields, "9.Single", "Yes");
  5051. break;
  5052. case 2: // 已婚
  5053. SetFieldValue(formFields, "9.Married", "Yes");
  5054. break;
  5055. case 3: // 离异
  5056. SetFieldValue(formFields, "9.Divorced", "Yes");
  5057. break;
  5058. case 4: // 离异
  5059. SetFieldValue(formFields, "9.Widow(er)", "Yes");
  5060. break;
  5061. }
  5062. #endregion
  5063. //亲权人(如是未成年申请人 )/合法监护人(姓名、住址,如与申请人不同) 电话号码、电子邮件及国籍
  5064. SetFieldValue(formFields, "10.ParentalAuthority", "");
  5065. SetFieldValue(formFields, "11.NationalIdentityNumber", idCard); //公民身份证号码
  5066. #region 护照(旅行证件类型)处理
  5067. //清除值
  5068. SetFieldValue(formFields, "12.OrdinaryPassport", "Off"); //旅行证件类型 - 普通护照
  5069. SetFieldValue(formFields, "12.DiplomaticPassport", "Off"); //旅行证件类型 - 外交护照
  5070. SetFieldValue(formFields, "12.ServicePassport", "Off"); //旅行证件类型 - 公务护照
  5071. SetFieldValue(formFields, "12.OfficialPassport", "Off"); //旅行证件类型 - 因公护照
  5072. SetFieldValue(formFields, "12.SpecialPassport", "Off"); //旅行证件类型 - 特殊护照
  5073. SetFieldValue(formFields, "12.OtherTravel", "Off"); //旅行证件类型 - 其它旅行证件
  5074. SetFieldValue(formFields, "12.OtherTravelDesc", ""); //旅行证件类型 - 其它旅行证件(请注明)
  5075. //设置值
  5076. SetFieldValue(formFields, "12.OrdinaryPassport", "Yes"); //旅行证件类型 - 普通护照
  5077. if (passportInfo != null)
  5078. {
  5079. SetFieldValue(formFields, "13.TravelNumber", passportInfo.CertNo); //旅行证件编号
  5080. SetFieldValue(formFields, "14.IssueDate", passportInfo.IssueDt?.ToString("yyyy-MM-dd") ?? ""); //签发日期
  5081. SetFieldValue(formFields, "15.ValidUntil", passportInfo.ExpiryDt?.ToString("yyyy-MM-dd") ?? ""); //有效期至
  5082. SetFieldValue(formFields, "16.IssuedCountry", passportInfo.Country); //签发(国)
  5083. }
  5084. #endregion
  5085. //如有家庭成员为欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的,请填写该家庭成员的个人信息
  5086. SetFieldValue(formFields, "17.LastName_om", ""); //姓
  5087. SetFieldValue(formFields, "17.FirstName_om", ""); //名
  5088. SetFieldValue(formFields, "17.BirthDate_om", ""); //出生日期(日-月-年)
  5089. SetFieldValue(formFields, "17.Nationality_om", ""); //国籍
  5090. SetFieldValue(formFields, "17.TravelNuber_om", ""); //旅行证件或身分证编号
  5091. //申请人与欧盟、欧洲经济区、瑞士或受益于退欧协议的英国公民的关系
  5092. SetFieldValue(formFields, "18.Spouse_om", ""); //配偶
  5093. SetFieldValue(formFields, "18.RegisteredPartnership_om", ""); //注册伴侣
  5094. SetFieldValue(formFields, "18.Child_om", ""); //子女
  5095. SetFieldValue(formFields, "18.DependentAscendant_om", ""); //受养人
  5096. SetFieldValue(formFields, "18.Grandchild_om", ""); //孙子女
  5097. SetFieldValue(formFields, "18.FamilyOther_om", ""); //其他
  5098. SetFieldValue(formFields, "18.FamilyOtherDesc_om", ""); //其他(说明)
  5099. //申请人住址及电子邮件
  5100. string applicantHomeAddress = $"{custInfo.Address} {custInfo.Email}";
  5101. SetFieldValue(formFields, "19.ApplicantHomeAddress", applicantHomeAddress); //申请人住址及电子邮件
  5102. SetFieldValue(formFields, "19.TelephoneNo", custInfo.Tel); //电话号码
  5103. //是否居住在现时国籍以外的国家
  5104. SetFieldValue(formFields, "20.AnotherCountryNo", "Yes"); //否
  5105. SetFieldValue(formFields, "20.AnotherCountryYes", ""); //是
  5106. SetFieldValue(formFields, "20.ResidencePermit", ""); //居住许可或同等证
  5107. SetFieldValue(formFields, "20.Number", ""); //编号
  5108. SetFieldValue(formFields, "20.ValidUntils", ""); //有效期至
  5109. SetFieldValue(formFields, "21.CurrentOccupation", custInfo.Job); //当前职业
  5110. //工作单位名称,地址和电话,学生填写学校名称及地址
  5111. var currCompanyInfo = currCompanyInfos.FirstOrDefault();
  5112. string employerInfoStr = $"{currCompanyInfo?.Company ?? ""} {currCompanyInfo?.CompanyAddress ?? ""} {currCompanyInfo?.Phone ?? ""}";
  5113. SetFieldValue(formFields, "22.EmployerInfo", employerInfoStr);
  5114. #region 旅行的目的
  5115. //清空值
  5116. SetFieldValue(formFields, "23.Tourism", "Off"); // 旅游
  5117. SetFieldValue(formFields, "23.Business", "Off"); // 商务
  5118. SetFieldValue(formFields, "23.VisitingFamily", "Off"); // 探亲访友
  5119. SetFieldValue(formFields, "23.Cultural", "Off"); // 文化
  5120. SetFieldValue(formFields, "23.Sports", "Off"); // 体育
  5121. SetFieldValue(formFields, "23.OfficialVisit", "Off"); // 官方访问
  5122. SetFieldValue(formFields, "23.MedicalReasons", "Off"); // 医疗
  5123. SetFieldValue(formFields, "23.Study", "Off"); // 学习
  5124. SetFieldValue(formFields, "23.AirportTransit", "Off"); // 机场过境
  5125. SetFieldValue(formFields, "23.Other", "Off"); // 其它
  5126. SetFieldValue(formFields, "23.OtherDesc", ""); // 其它 (请注明)
  5127. //设置值
  5128. if (groupInfo.VisitPurpose.contains("旅游")) SetFieldValue(formFields, "23.Tourism", "Yes"); //旅游
  5129. if (groupInfo.VisitPurpose.contains("商务")) SetFieldValue(formFields, "23.Business", "Yes"); //商务
  5130. if (groupInfo.VisitPurpose.contains("探亲访友")) SetFieldValue(formFields, "23.VisitingFamily", "Yes"); //探亲访友
  5131. if (groupInfo.VisitPurpose.contains("文化")) SetFieldValue(formFields, "23.Cultural", "Yes"); //文化
  5132. if (groupInfo.VisitPurpose.contains("体育")) SetFieldValue(formFields, "23.Sports", "Yes"); //体育
  5133. if (groupInfo.VisitPurpose.contains("官方访问")) SetFieldValue(formFields, "23.OfficialVisit", "Yes"); //官方访问
  5134. if (groupInfo.VisitPurpose.contains("医疗")) SetFieldValue(formFields, "23.MedicalReasons", "Yes"); //医疗
  5135. if (groupInfo.VisitPurpose.contains("学习")) SetFieldValue(formFields, "23.Study", "Yes"); //学习
  5136. if (groupInfo.VisitPurpose.contains("机场过境")) SetFieldValue(formFields, "23.AirportTransit", "Yes"); //机场过境
  5137. #endregion
  5138. SetFieldValue(formFields, "24.AdditionalInfo", ""); //有关停留原因的补充信息
  5139. string[] RD_country = new string[] { }; //接收处理的国家
  5140. string firstEntryLabel = string.Empty; //首入申根国标签
  5141. string membeDescLabel = string.Empty; //申根国目的地
  5142. string stopDays = string.Empty; //停留天数
  5143. if (!string.IsNullOrEmpty(groupInfo.VisitCountry))
  5144. {
  5145. List<string> SGGNames = new List<string>();//接收处理后的国家 是申根国
  5146. if (groupInfo.VisitCountry.Contains(","))
  5147. RD_country = groupInfo.VisitCountry.Split(',');
  5148. else if (groupInfo.VisitCountry.Contains(' '))
  5149. RD_country = groupInfo.VisitCountry.Split(' ');
  5150. else if (groupInfo.VisitCountry.Contains(","))
  5151. RD_country = groupInfo.VisitCountry.Split(',');
  5152. else if (groupInfo.VisitCountry.Contains("、"))
  5153. RD_country = groupInfo.VisitCountry.Split('、');
  5154. else if (groupInfo.VisitCountry.Contains("|"))
  5155. RD_country = groupInfo.VisitCountry.Split('|');
  5156. //判断是否是申根国家
  5157. for (int i = 0; i < RD_country.Length; i++)
  5158. {
  5159. if (RD_country[i].ToString() != null)
  5160. {
  5161. //在申根国家中筛选 该国家是否是申根国家
  5162. for (int j = 0; j < _shenGenGuos.Length; j++)
  5163. {
  5164. if (RD_country[i] == _shenGenGuos[j])
  5165. SGGNames.Add(_shenGenGuos[j]); //添加申根国
  5166. }
  5167. }
  5168. }
  5169. //目的地国是否有申根国
  5170. if (SGGNames.Count > 0)
  5171. {
  5172. firstEntryLabel = SGGNames.First();
  5173. membeDescLabel = string.Join(",", SGGNames.ToArray());
  5174. //接收生根国详细信息 存储顺序 起飞日期:Day 起飞时刻:StartTime 抵达日期:ArrivedDate 到达时刻:EndTime
  5175. List<SSGDetails> ListSSGDetails = new List<SSGDetails>();
  5176. //处理申根国家 预定到达时间 预定离开时间 预定停留天数
  5177. for (int i = 0; i < SGGNames.Count; i++)
  5178. {
  5179. //在相同的国家下 得到该航班的信息 //抵达时间 起飞日期:Day 起飞时刻:StartTime 到达时刻:EndTime 抵达日期:ArrivedDate 飞行时间:FlightTime 航司 Fliagtcode 入境口岸
  5180. var atbc = GeneralMethod.GetTableByBlackCode(groupId);
  5181. //ResidenceTime1 机票三字码信息
  5182. if (atbc != null)
  5183. {
  5184. string HL_Three = ""; //三字码 Three
  5185. for (int j = 0; j < atbc.Rows.Count; j++)
  5186. {
  5187. HL_Three = atbc.Rows[j]["Three"].ToString();
  5188. if (!string.IsNullOrEmpty(HL_Three))
  5189. {
  5190. string threeCodeTwo = HL_Three.Substring(3);
  5191. var tc = _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.Three == threeCodeTwo).First();
  5192. if (tc != null)
  5193. {
  5194. //首入申根国时间
  5195. if (SGGNames[i] == tc.Country)
  5196. {
  5197. SSGDetails SSGDetails = new SSGDetails()
  5198. {
  5199. Three = atbc.Rows[j]["Three"].ToString(), //三字码
  5200. Fliagtcode = atbc.Rows[j]["Fliagtcode"].ToString(), //航司
  5201. startDate = atbc.Rows[j]["Day"].ToString(), //整理起飞日期
  5202. startTime = atbc.Rows[j]["StartTime"].ToString(), //整理起飞时刻
  5203. endDate = atbc.Rows[j]["ArrivedDate"].ToString(), //整理抵达日期
  5204. endTime = atbc.Rows[j]["EndTime"].ToString() //整理抵达时刻
  5205. };
  5206. ListSSGDetails.Add(SSGDetails);
  5207. }
  5208. }
  5209. }
  5210. }
  5211. }
  5212. }
  5213. ListSSGDetails.Sort((a, b) => a.startDate.CompareTo(b.startDate));
  5214. //得到并计算出入境时间
  5215. if (ListSSGDetails != null)
  5216. {
  5217. string RuJingTime = ListSSGDetails.First().endDate + " " + ListSSGDetails.First().endTime.Substring(0, 2) + ":" + ListSSGDetails.First().endTime.Substring(2); //入境时间
  5218. string LiJingTime = ListSSGDetails[ListSSGDetails.Count - 1].startDate + " " + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(0, 2) + ":" + ListSSGDetails[ListSSGDetails.Count - 1].endTime.Substring(2); //离境时间
  5219. stopDays = Convert.ToDateTime(LiJingTime).Subtract(Convert.ToDateTime(RuJingTime)).Days.ToString();
  5220. }
  5221. }
  5222. }
  5223. SetFieldValue(formFields, "25.MembeDesc", membeDescLabel); //主要申根目的地 (以及其他申根目的地,如适用)
  5224. SetFieldValue(formFields, "26.FirstEntry", firstEntryLabel); //首入申根国
  5225. //申请入境次数
  5226. SetFieldValue(formFields, "27.SingleEntry", ""); //单次
  5227. SetFieldValue(formFields, "27.TwoEntries", ""); //两次
  5228. SetFieldValue(formFields, "27.MultipleEntries", ""); //多次
  5229. SetFieldValue(formFields, "27.IntendedDateIn", ""); //在申根地区预计首次停留的预计抵达日期
  5230. SetFieldValue(formFields, "27.IntendedDateOut", ""); //在申根地区预计首次停留之后的预计离开日期
  5231. //以往申根国签证是否有指纹记录
  5232. SetFieldValue(formFields, "28.No", ""); //否
  5233. SetFieldValue(formFields, "28.Yes", ""); //是
  5234. SetFieldValue(formFields, "28.KnownDate", ""); //如有,请写明日期
  5235. SetFieldValue(formFields, "28.KnownVisanumber", ""); //如有,请写明签证贴纸号码
  5236. //最后目的地之入境许可
  5237. SetFieldValue(formFields, "29.Issued", ""); //签发机关 Entry permit for the final country of destination, where applicable
  5238. SetFieldValue(formFields, "29.ValidFrom", ""); //有效期由
  5239. SetFieldValue(formFields, "29.Until", ""); //至
  5240. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  5241. //得到当前国家下的城市酒店信息
  5242. var hotelInfo = _sqlSugar.Queryable<Grp_HotelReservations>()
  5243. .Where(x => x.DiId == groupId)
  5244. //.Where(x => x.City.contains(city))
  5245. .First();
  5246. //酒店住址
  5247. if (hotelInfo != null)
  5248. {
  5249. SetFieldValue(formFields, "30.SurnameFirstName", hotelInfo?.HotelName ?? ""); //申根国的酒店
  5250. var otherInfo = $"{hotelInfo.HotelAddress}";
  5251. SetFieldValue(formFields, "30.HotelInfo", otherInfo); //邀请人/酒店/暂住居所的地址及电子邮件
  5252. SetFieldValue(formFields, "30.TelephoneNo", hotelInfo?.HotelTel ?? ""); //电话号码
  5253. }
  5254. //邀请公司或机构的名称及地址
  5255. var oa = _sqlSugar.Queryable<Res_OfficialActivities>()
  5256. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  5257. //.Where(x => x.Country.Contains(county))
  5258. //.Where(x => x.Area.Contains(city))
  5259. .First();
  5260. if (oa != null)
  5261. {
  5262. //申根国的邀请人姓名。如无邀请人,请填写申根国的酒店或暂住居所名称
  5263. SetFieldValue(formFields, "30.SurnameFirstName", oa?.Contact ?? ""); //申根国的酒店
  5264. SetFieldValue(formFields, "30.HotelInfo", oa?.Address ?? ""); //邀请人/酒店/暂住居所的地址及电子邮件
  5265. SetFieldValue(formFields, "30.TelephoneNo", oa?.Tel ?? ""); //电话号码
  5266. string nameAddressLabel = $"{oa.Client} {oa.Address}";
  5267. SetFieldValue(formFields, "31.NameAddress", nameAddressLabel); //邀请公司或机构的名称及地址
  5268. string surnameLabel = $"{oa.Contact} {oa.Tel}";
  5269. SetFieldValue(formFields, "31.Surname", surnameLabel); //邀请公司或机构的联系人姓名、地址、电话号码及电子邮件
  5270. SetFieldValue(formFields, "31.TelephoneNo", oa?.Tel ?? ""); //邀请公司或机构的电话
  5271. }
  5272. //申请人的旅费以及在国外停留期间的生活费用
  5273. SetFieldValue(formFields, "32.Applicant", ""); //由申请人支付
  5274. SetFieldValue(formFields, "32.Cash", ""); //支付方式 - 现金
  5275. SetFieldValue(formFields, "32.Traveller", ""); //支付方式 - 旅行支票
  5276. SetFieldValue(formFields, "32.CreditCard", ""); //支付方式 - 信用卡
  5277. SetFieldValue(formFields, "32.Prepaid", ""); //支付方式 - 预缴住宿
  5278. SetFieldValue(formFields, "32.Prepaid1", ""); //支付方式 - 预缴交通
  5279. SetFieldValue(formFields, "32.OtherMeans", ""); //支付方式 - 其它
  5280. SetFieldValue(formFields, "32.OtherMeansDesc", ""); //支付方式 - 其它(请注明)
  5281. SetFieldValue(formFields, "32.Sponsor", ""); //由赞助方(邀请人、公司或机构)支付,请注明
  5282. SetFieldValue(formFields, "32.Referred", ""); //参见第 30 及 31 项
  5283. SetFieldValue(formFields, "32.ReferredDesc", ""); //参见第 30 及 31 项(请注明)
  5284. SetFieldValue(formFields, "32.OtherSponsor", ""); //其它
  5285. SetFieldValue(formFields, "32.OtherSponsorDesc", ""); //其它(请注明)
  5286. SetFieldValue(formFields, "32.SponsorCash", ""); //赞助方式 - 现金
  5287. SetFieldValue(formFields, "32.SponsorAccommodation", ""); //赞助方式 - 提供住宿
  5288. SetFieldValue(formFields, "32.SponsorExpenses", ""); //赞助方式 - 支付旅程期间所有开支
  5289. SetFieldValue(formFields, "32.SponsorPrepaid", ""); //赞助方式 - 预缴交通
  5290. SetFieldValue(formFields, "32.ponsorOther", ""); //赞助方式 - 其它
  5291. SetFieldValue(formFields, "32.ponsorOtherDesc", ""); //赞助方式 - 其它(请注明)
  5292. //填表人与申请人不同
  5293. SetFieldValue(formFields, "33.WriteTableName", ""); //姓名
  5294. SetFieldValue(formFields, "33.WriteTableAddress", ""); //住址
  5295. SetFieldValue(formFields, "33.WriteTableTel", ""); //电话
  5296. SetFieldValue(formFields, "EndPlaceAndDate", DateTime.Now.ToString("yyyy-MM-dd")); //地点及日期
  5297. #endregion
  5298. }
  5299. catch (Exception ex)
  5300. {
  5301. throw new Exception($"生成PDF文件时出错: {ex.Message}", ex);
  5302. }
  5303. finally
  5304. {
  5305. // 按正确顺序关闭资源
  5306. stamper?.Close();
  5307. reader?.Close();
  5308. templateStream?.Close();
  5309. outputStream?.Close();
  5310. }
  5311. return outputPath;
  5312. }
  5313. #endregion
  5314. #region 文档下载辅助实体类
  5315. private class VisaDateView
  5316. {
  5317. /// <summary>
  5318. /// 团组信息
  5319. /// </summary>
  5320. public Grp_DelegationInfo groupInfo { get; set; }
  5321. /// <summary>
  5322. /// 身份证信息
  5323. /// </summary>
  5324. public Crm_CustomerCert idInfo { get; set; }
  5325. /// <summary>
  5326. /// 护照信息
  5327. /// </summary>
  5328. public Crm_CustomerCert passportInfo { get; set; }
  5329. /// <summary>
  5330. /// 客户信息
  5331. /// </summary>
  5332. public Crm_DeleClient custInfo { get; set; }
  5333. /// <summary>
  5334. /// 学校资料
  5335. /// </summary>
  5336. public List<Crm_VisaCustomerSchool> schoolInfos { get; set; }
  5337. /// <summary>
  5338. /// 家庭成员资料
  5339. /// </summary>
  5340. public List<Crm_VisaCustomerFamily> familyInfos { get; set; }
  5341. /// <summary>
  5342. /// 公司资料
  5343. /// </summary>
  5344. public List<Crm_VisaCustomerCompany> companyInfos { get; set; }
  5345. }
  5346. private class SSGDetails
  5347. {
  5348. public string Three { get; set; } //三字码
  5349. public string Fliagtcode { get; set; } //航司
  5350. public string startDate { get; set; } //首入申根国日期
  5351. public string startTime { get; set; } //首入申根国时间
  5352. public string endDate { get; set; } //离开申根国日期
  5353. public string endTime { get; set; } //离开申根国时间
  5354. }
  5355. #endregion
  5356. #endregion
  5357. /// <summary>
  5358. /// 根据团组Id获取签证客户信息List
  5359. /// </summary>
  5360. /// <param name="dto">请求dto</param>
  5361. /// <returns></returns>
  5362. [HttpPost]
  5363. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5364. public async Task<IActionResult> GetCrmByGroupId(ClientByGroupIdDto dto)
  5365. {
  5366. var data = await _groupRepository.GetCrmByGroupId(dto);
  5367. return Ok(JsonView(true, data.Code != 0 ? "暂无信息" : "操作成功", data.Data));
  5368. }
  5369. /// <summary>
  5370. /// IOS获取团组签证拍照上传进度01(团组列表)
  5371. /// </summary>
  5372. /// <param name="dto">请求dto</param>
  5373. /// <returns></returns>
  5374. [HttpPost]
  5375. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5376. public async Task<IActionResult> PostIOSVisaProgress(IOS_VisaDto dto)
  5377. {
  5378. if (dto == null)
  5379. {
  5380. return Ok(JsonView(false, "参数为空"));
  5381. }
  5382. DelegationVisaViewList visaList = _delegationVisaRep.GetDelegationList(dto);
  5383. return Ok(JsonView(visaList));
  5384. }
  5385. /// <summary>
  5386. /// IOS获取团组签证拍照上传进度02(团组签证详情\人员列表\国家)
  5387. /// </summary>
  5388. /// <returns></returns>
  5389. [HttpPost]
  5390. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5391. public async Task<ActionResult> PostIOSVisaProgressContent(IOS_VisaCustomerListDto dto)
  5392. {
  5393. if (dto == null)
  5394. {
  5395. return Ok(JsonView(false, "请求错误:"));
  5396. }
  5397. List<DelegationVisaProgressView> list = _delegationVisaRep.GetDelegationProgressList(dto.diId);
  5398. return Ok(JsonView(list));
  5399. }
  5400. /// <summary>
  5401. /// IOS获取团组签证拍照上传进度03(相册)
  5402. /// </summary>
  5403. /// <returns></returns>
  5404. [HttpPost]
  5405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5406. public async Task<ActionResult> PostIOSVisaProgressImageList(IOS_VisaImageListDto dto)
  5407. {
  5408. if (dto == null)
  5409. {
  5410. return Ok(JsonView(false, "请求错误:"));
  5411. }
  5412. List<VisaProgressImageView> list = _delegationVisaRep.GetVisaProgressImageList(dto.visaProgressCustomerId, dto.picType);
  5413. string url = AppSettingsHelper.Get("VisaProgressImageBaseUrl") + AppSettingsHelper.Get("VisaProgressImageFtpPath");
  5414. list.ForEach(s => s.url = url);
  5415. return Ok(JsonView(list));
  5416. }
  5417. /// <summary>
  5418. /// IOS获取团组签证拍照上传进度04(图片上传)
  5419. /// </summary>
  5420. /// <param name="dto"></param>
  5421. /// <returns></returns>
  5422. [HttpPost]
  5423. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5424. public async Task<ActionResult> PostIOSVisaProgressUploadImage(IOS_VisaUploadImageDto dto)
  5425. {
  5426. //string result = decodeBase64ToImage(dto.base64DataURL, dto.imageName);
  5427. //if (!string.IsNullOrEmpty(result))
  5428. //{
  5429. //}
  5430. //else {
  5431. // return Ok(JsonView(false, "上传失败"));
  5432. //}
  5433. var dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);
  5434. int sucNum = 0;
  5435. try
  5436. {
  5437. foreach (var item in dto.base64DataList)
  5438. {
  5439. string imageName = dto.imageName + ((DateTime.Now.Ticks - dt1970.Ticks) / 10000).ToString();
  5440. string result = DecodeBase64ToImage(item, imageName);
  5441. if (!string.IsNullOrEmpty(result))
  5442. {
  5443. var pic = new Grp_VisaProgressCustomerPicture
  5444. {
  5445. CreateUserId = dto.CreateUserId,
  5446. PicName = imageName,
  5447. PicPath = result,
  5448. VisaProgressCustomerId = dto.visaProgressCustomerId
  5449. };
  5450. int insertResult = await _delegationVisaRep.AddAsync<Grp_VisaProgressCustomerPicture>(pic);
  5451. if (insertResult > 0)
  5452. {
  5453. sucNum++;
  5454. }
  5455. }
  5456. }
  5457. }
  5458. catch (Exception ex)
  5459. {
  5460. return Ok(JsonView(false, ex.Message));
  5461. }
  5462. string msg = string.Format(@"成功上传{0}张", sucNum);
  5463. return Ok(JsonView(true, msg));
  5464. }
  5465. private string DecodeBase64ToImage(string base64DataURL, string imgName)
  5466. {
  5467. string filename = "";//声明一个string类型的相对路径
  5468. String base64 = base64DataURL.Substring(base64DataURL.IndexOf(",") + 1); //将‘,’以前的多余字符串删除
  5469. System.Drawing.Bitmap bitmap = null;//定义一个Bitmap对象,接收转换完成的图片
  5470. try//会有异常抛出,try,catch一下
  5471. {
  5472. byte[] arr = Convert.FromBase64String(base64);//将纯净资源Base64转换成等效的8位无符号整形数组
  5473. var ms = new System.IO.MemoryStream(arr);//转换成无法调整大小的MemoryStream对象
  5474. bitmap = new System.Drawing.Bitmap(ms);//将MemoryStream对象转换成Bitmap对象
  5475. var fileDir = AppSettingsHelper.Get("VisaProgressImageBasePath");
  5476. //文件名称
  5477. filename = "VisaProgress_" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_" + imgName + ".jpeg";//所要保存的相对路径及名字
  5478. //上传的文件的路径
  5479. string filePath = "";
  5480. if (!Directory.Exists(fileDir))
  5481. {
  5482. Directory.CreateDirectory(fileDir);
  5483. }
  5484. //上传的文件的路径
  5485. filePath = fileDir + filename;
  5486. //string url = HttpRuntime.AppDomainAppPath.ToString();
  5487. //string tmpRootDir = System.Web.HttpContext.Current.Server.MapPath(System.Web.HttpContext.Current.Request.ApplicationPath.ToString()); //获取程序根目录
  5488. //string imagesurl2 = tmpRootDir + filename; //转换成绝对路径
  5489. bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Jpeg);//保存到服务器路径
  5490. //bitmap.Save(filePath + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  5491. //bitmap.Save(filePath + ".gif", System.Drawing.Imaging.ImageFormat.Gif);
  5492. //bitmap.Save(filePath, System.Drawing.Imaging.ImageFormat.Png);
  5493. ms.Close();//关闭当前流,并释放所有与之关联的资源
  5494. bitmap.Dispose();
  5495. }
  5496. catch (Exception e)
  5497. {
  5498. string massage = e.Message;
  5499. Logs("IOS图片上传Error:" + massage);
  5500. //filename = e.Message;
  5501. }
  5502. return filename;//返回相对路径
  5503. }
  5504. /// <summary>
  5505. /// IOS获取团组签证拍照上传进度05(修改签证状态/通知)
  5506. /// </summary>
  5507. /// <param name="dto"></param>
  5508. /// <returns></returns>
  5509. [HttpPost]
  5510. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5511. public async Task<ActionResult> PostIOSVisaProgressChangeStatus(IOS_VisaChangeStatusDto dto)
  5512. {
  5513. if (dto == null)
  5514. {
  5515. return Ok(JsonView(false, "请求错误:"));
  5516. }
  5517. string msg = "参数错误";
  5518. if (dto.diId > 0 && dto.visaStatus > 0 && dto.visaStatus < 4)
  5519. {
  5520. try
  5521. {
  5522. //_delegationVisaRep.BeginTran();
  5523. var updCount = await _delegationVisaRep._sqlSugar.Updateable<Grp_VisaProgressCustomer>()
  5524. .SetColumns(it => it.WorkStatus == dto.visaStatus)
  5525. .Where(s => s.Id == dto.visaProgressCustomerId)
  5526. .ExecuteCommandAsync();
  5527. if (updCount > 0 && dto.publishCode == 1)
  5528. {
  5529. _delegationVisaRep.ChangeDataBase(DBEnum.OA2014DB); //切换到新OA后删除
  5530. string sqlDelegation = string.Format(@" Select * From DelegationInfo With(Nolock) Where Id = {0} ", dto.diId);
  5531. OA2021_DelegationInfo groupData = _sqlSugar.SqlQueryable<OA2021_DelegationInfo>(sqlDelegation).First();
  5532. //GroupInfoDto grpDto = new GroupInfoDto() { Id = dto.diId };
  5533. //var groupData = await _groupRepository.GetGroupInfo(grpDto);
  5534. _delegationVisaRep.ChangeDataBase(DBEnum.OA2023DB); //切换到新OA后删除
  5535. if (groupData == null)
  5536. {
  5537. _delegationVisaRep.RollbackTran();
  5538. }
  5539. string title = string.Format(@"[签证进度更新]");
  5540. string content = string.Format(@"测试文本");
  5541. bool rst = await _message.AddMsg(new MessageDto()
  5542. {
  5543. Type = MessageTypeEnum.GroupVisaProgressUpdate,
  5544. IssuerId = dto.publisher,
  5545. Title = title,
  5546. Content = content,
  5547. ReleaseTime = DateTime.Now,
  5548. UIdList = new List<int> {
  5549. 234
  5550. }
  5551. });
  5552. if (rst)
  5553. {
  5554. return Ok(JsonView(true, "发送通知成功"));
  5555. }
  5556. }
  5557. //_delegationVisaRep.CommitTran();
  5558. }
  5559. catch (Exception)
  5560. {
  5561. //_delegationVisaRep.RollbackTran();
  5562. }
  5563. }
  5564. return Ok(JsonView(true, msg));
  5565. }
  5566. #endregion
  5567. #endregion
  5568. #region 团组任务分配
  5569. /// <summary>
  5570. /// 团组任务分配初始化
  5571. /// </summary>
  5572. /// <returns></returns>
  5573. [HttpPost]
  5574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5575. public async Task<IActionResult> GetTaskAssignmen()
  5576. {
  5577. var groupData = await _taskAssignmentRep.GetTaskAssignmen();
  5578. if (groupData.Code != 0)
  5579. {
  5580. return Ok(JsonView(false, groupData.Msg));
  5581. }
  5582. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5583. }
  5584. /// <summary>
  5585. /// 团组任务分配查询
  5586. /// </summary>
  5587. /// <param name="dto"></param>
  5588. /// <returns></returns>
  5589. [HttpPost]
  5590. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5591. public async Task<IActionResult> TaskAssignmenQuery(TaskAssignmenQueryDto dto)
  5592. {
  5593. var groupData = await _taskAssignmentRep.TaskAssignmenQuery(dto);
  5594. if (groupData.Code != 0)
  5595. {
  5596. return Ok(JsonView(false, groupData.Msg));
  5597. }
  5598. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5599. }
  5600. /// <summary>
  5601. /// 团组任务分配操作
  5602. /// </summary>
  5603. /// <param name="dto"></param>
  5604. /// <returns></returns>
  5605. [HttpPost]
  5606. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5607. public async Task<IActionResult> GetTaskAssignmenOp(TaskAssignmenDto dto)
  5608. {
  5609. Result groupData = await _taskAssignmentRep.GetTaskAssignmenOp(dto);
  5610. if (groupData.Code != 0)
  5611. {
  5612. return Ok(JsonView(false, groupData.Msg));
  5613. }
  5614. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  5615. }
  5616. /// <summary>
  5617. /// 团组任务分配
  5618. /// 批量分配
  5619. /// 查询团组
  5620. /// </summary>
  5621. /// <param name="dto"></param>
  5622. /// <returns></returns>
  5623. [HttpPost]
  5624. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5625. public async Task<IActionResult> TaskAllocationGroupSelect(TaskAllocationGroupSelectDto dto)
  5626. {
  5627. //参数验证
  5628. if (dto.PortType < 1 || dto.PortType > 3) return Ok(JsonView(false, MsgTips.Port));
  5629. if (!DateTime.TryParse(dto.VisitBeginDt, out _) || !DateTime.TryParse(dto.VisitEndDt, out _))
  5630. return Ok(JsonView(false, "团组出访开始/结束日期格式不正确!"));
  5631. return Ok(await _taskAssignmentRep.TaskAllocationGroupSelect(dto));
  5632. }
  5633. /// <summary>
  5634. /// 团组任务分配
  5635. /// 批量分配
  5636. /// </summary>
  5637. /// <param name="dto"></param>
  5638. /// <returns></returns>
  5639. [HttpPost]
  5640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5641. public async Task<IActionResult> TaskAllocationBulkAdd(TaskAllocationBulkAddDto dto)
  5642. {
  5643. //参数验证
  5644. if (dto.UserIds.Length < 1) return Ok(JsonView(false, $"请选择分配人员!"));
  5645. if (dto.PermissionTypeIds.Length < 1) return Ok(JsonView(false, $"请选择分配类型!"));
  5646. if (dto.GroupIds.Length < 1) return Ok(JsonView(false, "请选择分配团组Id"));
  5647. if (dto.CurrUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId数组参数"));
  5648. return Ok(await _taskAssignmentRep.TaskAllocationBulkAdd(dto));
  5649. }
  5650. #endregion
  5651. #region 团组费用审核
  5652. /// <summary>
  5653. /// 费用审核
  5654. /// 团组列表 Page
  5655. /// </summary>
  5656. /// <param name="dto">团组列表请求dto</param>
  5657. /// <returns></returns>
  5658. [HttpPost]
  5659. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5660. public async Task<IActionResult> PostExpenseAuditGroupPageItems(ExpenseAuditGroupPageItemsDto dto)
  5661. {
  5662. #region 参数验证
  5663. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  5664. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  5665. #region 页面操作权限验证
  5666. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  5667. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  5668. #endregion
  5669. #endregion
  5670. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android/IOS
  5671. {
  5672. string sqlWhere = "WHERE gdi.IsDel = 0";
  5673. var parameters = new List<SugarParameter>();
  5674. // 状态条件(保持不变)
  5675. if (dto.IsSure >= 0)
  5676. {
  5677. sqlWhere += $" AND IsSure = {dto.IsSure}";
  5678. }
  5679. // 搜索条件
  5680. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  5681. {
  5682. var searchFields = new List<string>
  5683. {
  5684. "ssd.Name",
  5685. "TeamName",
  5686. "ClientName",
  5687. "su.CnName"
  5688. };
  5689. // 使用更宽松的配置
  5690. var config = new SearchConfig
  5691. {
  5692. EnableSmartSplitting = true,
  5693. RequireAllWordsForSplit = false,
  5694. MinSplitLength = 4
  5695. };
  5696. // 使用智能混合模式
  5697. var (searchCondition, searchParams) = AdvancedSearchHelper.BuildEnhancedSearchCondition(
  5698. dto.SearchCriteria,
  5699. searchFields,
  5700. "search_groupFee_",
  5701. SearchMode.AutoDetect,
  5702. CombinationMode.SmartMix,
  5703. config // 传入配置
  5704. );
  5705. if (!string.IsNullOrEmpty(searchCondition))
  5706. {
  5707. sqlWhere += $" AND ({searchCondition})";
  5708. parameters.AddRange(searchParams);
  5709. }
  5710. }
  5711. // 基础查询sql
  5712. string sql = $@"
  5713. SELECT Row_Number, Id, SalesQuoteNo, TourCode, TeamTypeId, TeamType,
  5714. TeamName, ClientName, ClientUnit, TeamLevId, TeamLev, VisitDate,
  5715. VisitDays, VisitPNumber, JietuanOperator, IsSure, CreateTime
  5716. FROM (
  5717. SELECT ROW_NUMBER() OVER (ORDER BY gdi.VisitDate DESC) AS Row_Number,
  5718. gdi.Id, gdi.SalesQuoteNo, gdi.TourCode,
  5719. ssd1.Id AS TeamLevId, ssd1.Name AS TeamLev,
  5720. gdi.TeamName, gdi.ClientName, gdi.ClientUnit,
  5721. ssd.Id AS TeamTypeId, ssd.Name AS TeamType,
  5722. gdi.VisitDate, gdi.VisitDays, gdi.VisitPNumber,
  5723. su.CnName AS JietuanOperator, gdi.IsSure, gdi.CreateTime
  5724. FROM Grp_DelegationInfo gdi
  5725. LEFT JOIN Sys_SetData ssd ON gdi.TeamDid = ssd.Id
  5726. LEFT JOIN Sys_SetData ssd1 ON gdi.TeamLevSId = ssd1.Id
  5727. LEFT JOIN Sys_Users su ON gdi.JietuanOperator = su.Id
  5728. {sqlWhere}
  5729. ) AS temp";
  5730. RefAsync<int> total = 0;
  5731. var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql)
  5732. .AddParameters(parameters.ToArray())
  5733. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  5734. var _view = new
  5735. {
  5736. PageFuncAuth = pageFunAuthView,
  5737. Data = _DelegationList
  5738. };
  5739. return Ok(JsonView(true, "查询成功!", _view, total));
  5740. }
  5741. else
  5742. {
  5743. return Ok(JsonView(false, "查询失败"));
  5744. }
  5745. }
  5746. /// <summary>
  5747. /// 获取团组费用审核
  5748. /// </summary>
  5749. /// <param name="_dto"></param>
  5750. /// <returns></returns>
  5751. [HttpPost]
  5752. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  5753. public async Task<IActionResult> PostSearchGrpCreditCardPayment(Search_GrpCreditCardPaymentDto _dto)
  5754. {
  5755. try
  5756. {
  5757. #region 参数验证
  5758. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  5759. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  5760. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  5761. #region 页面操作权限验证
  5762. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  5763. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  5764. #endregion
  5765. #endregion
  5766. var _view = new Grp_CreditCardPaymentView();
  5767. var clientNameList = GetSimplClientList(_dto.DiId);
  5768. #region 费用清单
  5769. var exp = Expressionable.Create<Grp_CreditCardPayment>();
  5770. exp.AndIF(_dto.AuditStatus != -1, it => it.IsAuditGM == _dto.AuditStatus);
  5771. exp.AndIF(_dto.Label != -1, it => it.CTable == _dto.Label);
  5772. var entityList = _groupRepository.Query<Grp_CreditCardPayment>(s => s.DIId == _dto.DiId && s.IsDel == 0 && s.CreateUserId > 0).Where(exp.ToExpression()).ToList();
  5773. var detailList = new List<Grp_CreditCardPaymentDetailView>();
  5774. var ccpCurrencyPrices = new List<CreditCardPaymentCurrencyPriceItem>();
  5775. /*
  5776. * 76://酒店预订
  5777. */
  5778. var _HotelReservations = await _groupRepository.Query<Grp_HotelReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5779. var _HotelReservationsContents = await _groupRepository.Query<Grp_HotelReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5780. /*
  5781. * 79://车/导游地接
  5782. */
  5783. var _CarTouristGuideGroundReservations = await _groupRepository.Query<Grp_CarTouristGuideGroundReservations>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5784. var _CarTouristGuideGroundReservationsContent = await _groupRepository.Query<Grp_CarTouristGuideGroundReservationsContent>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5785. /*
  5786. * 80: //签证
  5787. */
  5788. var _VisaInfos = await _groupRepository.Query<Grp_VisaInfo>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5789. /*
  5790. *81: //邀请/公务活动
  5791. */
  5792. var _InvitationOfficialActivities = await _groupRepository.Query<Grp_InvitationOfficialActivities>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5793. /*
  5794. * 82: //团组客户保险
  5795. */
  5796. var _Customers = await _groupRepository.Query<Grp_Customers>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5797. /*
  5798. * Lable = 85 机票预订
  5799. */
  5800. var p_AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5801. /*
  5802. * 85 机票预定
  5803. */
  5804. var _AirTicketReservations = await _groupRepository.Query<Grp_AirTicketReservations>(s => s.DIId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5805. /*
  5806. * 98 其他款项
  5807. */
  5808. var _DecreasePayments = await _groupRepository.Query<Grp_DecreasePayments>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5809. /*
  5810. * 285:收款退还
  5811. */
  5812. var _PaymentRefundAndOtherMoneys = await _groupRepository.Query<Fin_PaymentRefundAndOtherMoney>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5813. /*
  5814. * 1015: //超支费用
  5815. */
  5816. var _GroupExtraCosts = await _groupRepository.Query<Fin_GroupExtraCost>(s => s.DiId == _dto.DiId && s.IsDel == 0).ToListAsync();
  5817. var initDatas = await _groupRepository.Query<Sys_SetData>(s => s.IsDel == 0).ToListAsync();
  5818. /*
  5819. * 币种信息
  5820. */
  5821. var currencyItems = initDatas.Where(s => s.STid == 66).ToList();
  5822. /*
  5823. * 车/导游地接 费用类型
  5824. */
  5825. var carFeeTypeItems = initDatas.Where(s => s.STid == 17).ToList();
  5826. /*
  5827. * 车/导游地接 费用类型
  5828. */
  5829. var carFeeItems = initDatas.Where(s => s.STid == 83).ToList();
  5830. var cityData = await _groupRepository.Query<Grp_NationalTravelFee>(s => s.IsDel == 0).ToListAsync();
  5831. /*
  5832. * 用户信息
  5833. */
  5834. var userItems = await _groupRepository._sqlSugar.Queryable<Sys_Users>().ToListAsync();
  5835. /*
  5836. * 费用模块
  5837. */
  5838. var sdPriceName = initDatas.Where(s => s.Id == _dto.Label).First();
  5839. string priceModule = string.Empty;
  5840. if (sdPriceName != null)
  5841. {
  5842. priceModule = sdPriceName.Name;
  5843. }
  5844. /*
  5845. * 成本信息
  5846. */
  5847. var groupCost = _groupRepository.Query<Grp_GroupCostParameter>(s => s.DiId == _dto.DiId && s.IsDel == 0).First();
  5848. decimal _groupRate = 0.0000M;
  5849. string _groupCurrencyCode = "-";
  5850. if (groupCost != null)
  5851. {
  5852. _groupRate = groupCost.Rate;
  5853. if (int.TryParse(groupCost.Currency, out int _currency))
  5854. {
  5855. _groupCurrencyCode = currencyItems.Find(it => it.Id == _currency)?.Name ?? "-";
  5856. }
  5857. else _groupCurrencyCode = groupCost.Currency;
  5858. }
  5859. string costContentSql = $"Select * From Grp_GroupCost";
  5860. var groupCostDetails = _sqlSugar.SqlQueryable<GroupCostAuditView>(costContentSql).Where(x => x.IsDel == 0 && x.Diid == _dto.DiId).ToList();
  5861. //处理日期为空的天数
  5862. for (int i = 0; i < groupCostDetails.Count; i++)
  5863. if (i != 0)
  5864. if (string.IsNullOrEmpty(groupCostDetails[i].Date))
  5865. groupCostDetails[i].Date = groupCostDetails[i - 1].Date;
  5866. /*
  5867. * 处理详情数据
  5868. */
  5869. foreach (var entity in entityList)
  5870. {
  5871. var _detail = new Grp_CreditCardPaymentDetailView
  5872. {
  5873. Id = entity.Id,
  5874. PriceName = priceModule,
  5875. PayType = initDatas.Find(it => it.Id == entity.PayDId)?.Name ?? "-"
  5876. };
  5877. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  5878. else _detail.CardType = initDatas.Find(it => it.Id == entity.CTDId)?.Name ?? "-";
  5879. //处理金额
  5880. if (entity.CTable == 1015)
  5881. {
  5882. var czInfo = _GroupExtraCosts.Find(x => entity.CId == x.Id);
  5883. if (czInfo != null)
  5884. {
  5885. entity.PayMoney = czInfo.Price * czInfo.PriceCount;
  5886. entity.RMBPrice = czInfo.Price * czInfo.PriceCount * entity.DayRate;
  5887. }
  5888. }
  5889. /*
  5890. * 应付款金额
  5891. */
  5892. var sdPaymentCurrency_WaitPay = currencyItems.Where(s => s.Id == entity.PaymentCurrency).FirstOrDefault();
  5893. string PaymentCurrency_WaitPay = "Unknown";
  5894. string hotelCurrncyCode = "Unknown";
  5895. string hotelCurrncyName = "Unknown";
  5896. if (sdPaymentCurrency_WaitPay != null)
  5897. {
  5898. PaymentCurrency_WaitPay = sdPaymentCurrency_WaitPay.Name;
  5899. hotelCurrncyCode = sdPaymentCurrency_WaitPay.Name;
  5900. hotelCurrncyName = sdPaymentCurrency_WaitPay.Remark;
  5901. if (hotelCurrncyCode.Equals("CNY"))
  5902. {
  5903. entity.DayRate = 1.0000M;
  5904. }
  5905. }
  5906. _detail.WaitPay = entity.PayMoney.ConvertToDecimal1().ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  5907. /*
  5908. * 此次付款金额
  5909. */
  5910. decimal CurrPayStr = 0.00M,
  5911. OriginalCurrPay = 0.00M;
  5912. if (entity.PayPercentage == 0)
  5913. {
  5914. if (entity.PayThenMoney != 0)
  5915. CurrPayStr = (entity.PayThenMoney * entity.DayRate).ConvertToDecimal1();
  5916. }
  5917. else
  5918. {
  5919. if (entity.PayMoney != 0)
  5920. {
  5921. CurrPayStr = (entity.PayMoney * entity.PayPercentage / 100 * entity.DayRate).ConvertToDecimal1();
  5922. }
  5923. }
  5924. //if (_dto.Label == 79)
  5925. //{
  5926. // string original = string.Empty;
  5927. // if (hotelCurrncyCode.Equals("CNY"))
  5928. // {
  5929. // OriginalCurrPay = CurrPayStr;
  5930. // _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  5931. // }
  5932. // else
  5933. // {
  5934. // OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  5935. // //760 EUR(7600.00 CNY)
  5936. // _detail.CurrPay = $"{OriginalCurrPay.ToString("#0.00")} {hotelCurrncyCode}({CurrPayStr.ToString("#0.00")} CNY)";
  5937. // }
  5938. //}
  5939. //else _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  5940. string original = string.Empty;
  5941. if (hotelCurrncyCode.Equals("CNY"))
  5942. {
  5943. OriginalCurrPay = CurrPayStr;
  5944. _detail.CurrPay = CurrPayStr.ToString("#0.00") + " CNY";
  5945. }
  5946. else
  5947. {
  5948. OriginalCurrPay = ((entity.PayMoney / 100) * entity.PayPercentage).ConvertToDecimal1();
  5949. //760 EUR(7600.00 CNY)
  5950. _detail.CurrPay = $"{OriginalCurrPay:#0.00} {hotelCurrncyCode}({CurrPayStr:#0.00} CNY)";
  5951. }
  5952. /*
  5953. * 剩余尾款
  5954. */
  5955. decimal BalanceStr = 0;
  5956. if (CurrPayStr != 0)
  5957. {
  5958. if (entity.PayMoney - (CurrPayStr / entity.DayRate) < 0.01M)
  5959. BalanceStr = 0;
  5960. else
  5961. BalanceStr = (entity.PayMoney - CurrPayStr / entity.DayRate).ConvertToDecimal1();
  5962. }
  5963. _detail.Balance = BalanceStr.ToString("#0.00") + " " + PaymentCurrency_WaitPay;
  5964. /*
  5965. * Bus名称
  5966. */
  5967. _detail.BusName = "待增加";
  5968. /*
  5969. *费用所属
  5970. */
  5971. switch (entity.CTable)
  5972. {
  5973. case 76://酒店预订
  5974. Grp_HotelReservations hotelReservations = _HotelReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  5975. if (hotelReservations != null)
  5976. {
  5977. DateTime checkIn = Convert.ToDateTime(hotelReservations.CheckInDate),
  5978. checkOut = Convert.ToDateTime(hotelReservations.CheckOutDate);
  5979. int hotel_days = (int)(checkOut - checkIn).TotalDays;
  5980. string roomFeeStr = "", roomFeestr1 = "";
  5981. //是否比较房型价格
  5982. //bool __isSingle = false, __isDouble = false, __isSuite = false, __isOther = false;
  5983. //roomFeeStr += $"<br/><span style='width:70px;display: inline-block;'></span>";
  5984. roomFeeStr += $"<br/>";
  5985. var roomTotal = 0.00M;
  5986. if (hotelReservations.SingleRoomPrice > 0)
  5987. {
  5988. var fee = hotelReservations.SingleRoomPrice * hotelReservations.SingleRoomCount * hotel_days;
  5989. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>单间:{hotelReservations.SingleRoomPrice:#0.00} * {hotelReservations.SingleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5990. //__isSingle = true;
  5991. roomTotal += fee;
  5992. }
  5993. if (hotelReservations.DoubleRoomPrice > 0)
  5994. {
  5995. var fee = hotelReservations.DoubleRoomPrice * hotelReservations.DoubleRoomCount * hotel_days;
  5996. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>双人间:{hotelReservations.DoubleRoomPrice:#0.00} * {hotelReservations.DoubleRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  5997. // __isDouble = true;
  5998. roomTotal += fee;
  5999. }
  6000. if (hotelReservations.SuiteRoomPrice > 0)
  6001. {
  6002. var fee = hotelReservations.SuiteRoomPrice * hotelReservations.SuiteRoomCount * hotel_days;
  6003. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>套房:{hotelReservations.SuiteRoomPrice:#0.00} * {hotelReservations.SuiteRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  6004. //__isSuite = true;
  6005. roomTotal += fee;
  6006. }
  6007. if (hotelReservations.OtherRoomPrice > 0)
  6008. {
  6009. var fee = hotelReservations.OtherRoomPrice * hotelReservations.OtherRoomCount * hotel_days;
  6010. roomFeestr1 += $"<span style='width:70px;display: inline-block;'></span>其他:{hotelReservations.OtherRoomPrice:#0.00} * {hotelReservations.OtherRoomCount}间 * {hotel_days}晚 = {fee:#0.00}<br/>";
  6011. //__isOther = true;
  6012. roomTotal += fee;
  6013. }
  6014. if (roomFeestr1.Length > 0) roomFeeStr += roomFeestr1 + $"<span style='width:70px;display: inline-block;'></span>房费总金额:{roomTotal:#0.00}";
  6015. else roomFeeStr += " 0.00 * 0";
  6016. decimal governmentRentFee = 0.00M, cityTaxFee = 0.00M, breakfastFee = 0.00M, roomFee = 0.00M;
  6017. string governmentRentBool = "否", cityTaxBool = "否", breakfastBool = "否", roomBool = "否";
  6018. string governmentRentCode = "", governmentRentName = "", cityTaxCode = "", cityTaxName = "", breakfastCode = "", breakfastName = "", roomCode = "", roomName = "";
  6019. var _HotelReservationsContents1 = _HotelReservationsContents.Where(it => it.HrId == hotelReservations.Id).ToList();
  6020. /*
  6021. * 费用类型
  6022. * 1:房费
  6023. * 2:早餐
  6024. * 3:地税
  6025. * 4:城市税
  6026. * </summary>
  6027. */
  6028. //地税
  6029. var governmentRentData = _HotelReservationsContents1.Find(it => it.PriceType == 3);
  6030. if (governmentRentData != null)
  6031. {
  6032. governmentRentBool = governmentRentData.IsOppay == 1 ? "是" : "否";
  6033. governmentRentFee = governmentRentData.Price;
  6034. var governmentRentCurrData = currencyItems.Find(s => s.Id == governmentRentData.Currency);
  6035. if (governmentRentCurrData != null)
  6036. {
  6037. governmentRentCode = governmentRentCurrData.Name;
  6038. governmentRentName = $"({governmentRentCurrData.Remark})";
  6039. }
  6040. }
  6041. //城市税
  6042. var cityTaxData = _HotelReservationsContents1.Find(it => it.PriceType == 4);
  6043. if (cityTaxData != null)
  6044. {
  6045. cityTaxBool = cityTaxData.IsOppay == 1 ? "是" : "否";
  6046. cityTaxFee = cityTaxData.Price;
  6047. var cityTaxCurrData = currencyItems.Find(s => s.Id == cityTaxData.Currency);
  6048. if (cityTaxCurrData != null)
  6049. {
  6050. cityTaxCode = cityTaxCurrData.Name;
  6051. cityTaxName = $"({cityTaxCurrData.Remark})";
  6052. }
  6053. }
  6054. //酒店早餐
  6055. var breakfastData = _HotelReservationsContents1.Find(it => it.PriceType == 2);
  6056. if (breakfastData != null)
  6057. {
  6058. breakfastBool = breakfastData.IsOppay == 1 ? "是" : "否";
  6059. breakfastFee = breakfastData.Price;
  6060. var breakfastCurrData = currencyItems.Find(s => s.Id == breakfastData.Currency);
  6061. if (breakfastCurrData != null)
  6062. {
  6063. breakfastCode = breakfastCurrData.Name;
  6064. breakfastName = $"({breakfastCurrData.Remark})";
  6065. }
  6066. }
  6067. //房间费用
  6068. var roomData = _HotelReservationsContents1.Find(it => it.PriceType == 1);
  6069. if (roomData != null)
  6070. {
  6071. _detail.PayType = initDatas.Find(it => it.Id == roomData.PayDId)?.Name ?? "-";
  6072. if (_detail.PayType.Equals("现金")) _detail.CardType = "-";
  6073. else _detail.CardType = initDatas.Find(it => it.Id == roomData.CTDId)?.Name ?? "-";
  6074. roomBool = roomData.IsOppay == 1 ? "是" : "否";
  6075. roomFee = roomData.Price;
  6076. var roomCurrData = currencyItems.Find(s => s.Id == roomData.Currency);
  6077. if (roomCurrData != null)
  6078. {
  6079. roomCode = roomCurrData.Name;
  6080. roomName = $"({roomCurrData.Remark})";
  6081. }
  6082. }
  6083. string hotelCostTitalStr = "<span style='font-weight:800;'>成本信息</span><br/>";
  6084. string hotelCostStr = "";
  6085. decimal hotelCsotTotal = 0.00M;
  6086. if (groupCost != null)
  6087. {
  6088. if (int.TryParse(groupCost.Currency, out int currencyId)) groupCost.Currency = currencyItems.Find(s => s.Id == currencyId)?.Name ?? "-";
  6089. hotelCostStr += $"{groupCost.Currency}(汇率:{groupCost.Rate:#0.0000})<br/>";
  6090. }
  6091. if (checkOut > checkIn) checkOut = checkOut.AddDays(-1);
  6092. var hotelCostDetails = groupCostDetails.Where(x => Convert.ToDateTime(x.Date) >= checkIn && Convert.ToDateTime(x.Date) <= checkOut).ToList();
  6093. string hotelCost_day = "";
  6094. var hotelCostDetails1 = hotelCostDetails.GroupBy(x => x.Date);
  6095. foreach (var item in hotelCostDetails1)
  6096. {
  6097. hotelCsotTotal += item.Sum(x => x.HotelSingleRoomFee) + item.Sum(x => x.HotelDoubleRoomFee) + item.Sum(x => x.HotelSuiteRoomFee) + item.Sum(x => x.HotelSuiteFee);
  6098. hotelCost_day += @$"{item.First()?.Date ?? "-"}";
  6099. if (item.Sum(x => x.HotelSingleRoomFee) != 0) hotelCost_day += @$" 单间:{item.Sum(x => x.HotelSingleRoomFee):#0.00}";
  6100. //else { if (__isSingle) hotelCost_day += @$" 单间:0.00"; }
  6101. if (item.Sum(x => x.HotelDoubleRoomFee) != 0) hotelCost_day += @$" 双人间:{item.Sum(x => x.HotelDoubleRoomFee):#0.00}";
  6102. //else { if (__isDouble) hotelCost_day += @$" 双人间:0.00"; }
  6103. if (item.Sum(x => x.HotelSuiteRoomFee) != 0) hotelCost_day += @$" 小套房/豪华套房:{item.Sum(x => x.HotelSuiteRoomFee):#0.00}";
  6104. //else { if (__isSuite) hotelCost_day += @$" 小套房/豪华套房:0.00"; }
  6105. if (item.Sum(x => x.HotelSuiteFee) != 0) hotelCost_day += @$" 套房:{item.Sum(x => x.HotelSuiteFee):#0.00}";
  6106. //else { if (__isOther) hotelCost_day += @$" 套房:0.00"; }
  6107. hotelCost_day += @$"<br/>";
  6108. }
  6109. string hotelBreakfastStr = "", hotelGovernmentRentStr = "", hotelCityTaxStr = "";
  6110. if (breakfastFee > 0) hotelBreakfastStr = $"酒店早餐: {breakfastFee:#0.00} {breakfastCode} {breakfastName} 当时汇率 {breakfastData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{breakfastBool}<br/><br/>";
  6111. if (governmentRentFee > 0) hotelGovernmentRentStr = $"地税: {governmentRentFee:#0.00} {governmentRentCode} {governmentRentName} 当时汇率 {governmentRentData?.Rate:#0.0000} <br/>是否由地接或其他人代付:{governmentRentBool}<br/><br/>";
  6112. if (cityTaxFee > 0) hotelCityTaxStr = $"城市税: {cityTaxFee:#0.00} {cityTaxCode} {cityTaxName} 当时汇率 {cityTaxData?.Rate:#0.0000)} <br/>是否由地接或其他人代付:{cityTaxBool}<br/>";
  6113. string hotelCostTotalStr = "";// $"&nbsp;&nbsp;成本合计:{hotelCsotTotal.ToString("#0.00")}<br/>";
  6114. _detail.PriceMsgContent = $"{hotelCostTitalStr}{hotelCostStr}{hotelCostTotalStr}{hotelCost_day}<br/>" +
  6115. $"<span style='font-weight:800;'>{hotelReservations.HotelName} [{hotelReservations.CheckInDate} - {hotelReservations.CheckOutDate}]</span><br/>" +
  6116. $"酒店费用总额:{_detail.WaitPay} ({hotelCurrncyName})<br/>" +
  6117. $"房间说明: {hotelReservations.Remark} <br/>" +
  6118. $"房间费用: {roomCode} {roomName} 当时汇率:{roomData?.Rate.ToString("#0.0000")}{roomFeeStr} <br/>是否由地接或其他人代付:{roomBool}<br/><br/>" +
  6119. $"{hotelBreakfastStr}" +
  6120. $"{hotelGovernmentRentStr}" +
  6121. $"{hotelCityTaxStr}";
  6122. _detail.PriceNameContent = hotelReservations.HotelName;
  6123. }
  6124. break;
  6125. case 79://车/导游地接
  6126. Grp_CarTouristGuideGroundReservations touristGuideGroundReservations = _CarTouristGuideGroundReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  6127. if (touristGuideGroundReservations != null)
  6128. {
  6129. if (!string.IsNullOrEmpty(touristGuideGroundReservations.BusName))
  6130. {
  6131. _detail.BusName = touristGuideGroundReservations.BusName;
  6132. }
  6133. _detail.PriceNameContent = touristGuideGroundReservations.PriceName;
  6134. //bool isInt = int.TryParse(touristGuideGroundReservations.Area, out int cityId);
  6135. //if (isInt)
  6136. //{
  6137. // var cityInfo = cityData.Find(it => it.Id == cityId);
  6138. // if (cityInfo != null)
  6139. // {
  6140. // string nameContent = $@"{cityInfo.Country}-{cityInfo.City}";
  6141. // var carFeeItem = carFeeItems.Find(it => it.Id == touristGuideGroundReservations.PriceType);
  6142. // if (carFeeItem != null)
  6143. // {
  6144. // nameContent += $@"({carFeeItem.Name})";
  6145. // }
  6146. // _detail.PriceNameContent = nameContent;
  6147. // }
  6148. //}
  6149. //else
  6150. //{
  6151. // _detail.PriceNameContent = touristGuideGroundReservations.Area;
  6152. //}
  6153. var touristGuideGroundReservationsContents =
  6154. _CarTouristGuideGroundReservationsContent.Where(s => s.CTGGRId == touristGuideGroundReservations.Id && s.IsDel == 0 && s.Price != 0).ToList();
  6155. var opContent_sb = new StringBuilder();
  6156. string contetTitle = $"<span style='font-weight:800;'>{touristGuideGroundReservations.PriceName}({touristGuideGroundReservations.ServiceStartTime} - {touristGuideGroundReservations.ServiceEndTime})</span><br/>";
  6157. opContent_sb.AppendLine(contetTitle);
  6158. foreach (var item in touristGuideGroundReservationsContents)
  6159. {
  6160. string typeName = "Unknown";
  6161. string carCurrencyCode = "Unknown";
  6162. string carCurrencyName = "Unknown";
  6163. var carTypeData = carFeeTypeItems.Where(s => s.Id == item.SId && s.IsDel == 0).FirstOrDefault();
  6164. if (carTypeData != null) typeName = carTypeData.Name;
  6165. var currencyData = currencyItems.Where(s => s.Id == item.Currency && s.IsDel == 0).FirstOrDefault();
  6166. if (currencyData != null)
  6167. {
  6168. carCurrencyCode = currencyData.Name;
  6169. carCurrencyName = currencyData.Remark;
  6170. }
  6171. //op、成本 币种是否一致 (币种一致只比较金额:2025-04-18)
  6172. bool IsCurrencyAgreement = false;
  6173. if (carCurrencyCode.Equals(_groupCurrencyCode)) IsCurrencyAgreement = true;
  6174. string opCostStr = string.Empty;
  6175. decimal opCostTypePrice = 0.00M;
  6176. #region 处理成本各项费用
  6177. var opDate = item.DatePrice?.ToString("yyyy-MM-dd");
  6178. var opCost = groupCostDetails.Where(x => x.Date.Equals(opDate)).ToList();
  6179. decimal aduitOPFeeCNY = 0.00M, //费用审核 op费用
  6180. costOPFeeCNY = 0.00M, //团组成本 op费用
  6181. opPayPercentage = entity.PayPercentage == 0.00M ? 1.00M : entity.PayPercentage / 100M; //费用审核 op付款百分比
  6182. if (opCost.Count > 0)
  6183. {
  6184. switch (item.SId)
  6185. {
  6186. case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //91车费
  6187. //case 982: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //982 车超时费 -- 暂无
  6188. case 92: opCostTypePrice = opCost.Sum(x => x.GuideFee); break; //92 导游费
  6189. case 94: opCostTypePrice = opCost.Sum(x => x.GuideScenicFee); break; //94 导游景点费
  6190. case 95: opCostTypePrice = opCost.Sum(x => x.GuideTipFee); break; //95 导游小费
  6191. case 983: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //983 导游餐补
  6192. case 984: opCostTypePrice = opCost.Sum(x => x.GuideMealFee); break; //984 导游房补
  6193. case 985: opCostTypePrice = opCost.Sum(x => x.GuideRoomFee); break; //985 导游交通
  6194. //case 96: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //96 接送机费 -- 暂无
  6195. //case 97: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //97 其他费用 -- 暂无
  6196. case 979: opCostTypePrice = opCost.Sum(x => x.DriverFee); break; //979 司机工资
  6197. case 980: opCostTypePrice = opCost.Sum(x => x.DriverTipFee); break; //980 司机小费
  6198. case 981: opCostTypePrice = opCost.Sum(x => x.DriverMealFee); break; //981 司机餐补
  6199. case 988: opCostTypePrice = opCost.Sum(x => x.ClientBreakfastFee); break; //988 客户早餐费用
  6200. case 93: opCostTypePrice = opCost.Sum(x => x.ClientDinnerFee); break; //93 客户午餐费用
  6201. case 989: opCostTypePrice = opCost.Sum(x => x.ClientLunchFee); break; //989 客户晚餐费用
  6202. case 990: opCostTypePrice = opCost.Sum(x => x.ScenicTicketFee); break; //990 景点门票费
  6203. case 991: opCostTypePrice = opCost.Sum(x => x.DrinkSnackFruitFee); break; //991 饮料/零食/水果
  6204. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //992 住补费用 -- 暂无
  6205. case 994: opCostTypePrice = opCost.Sum(x => x.TranslatorFee); break; //994 翻译费
  6206. case 1059: opCostTypePrice = opCost.Sum(x => x.GuideOverTimeFee); break; //1059 导游超时费用
  6207. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1070 尾款金额
  6208. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1071 其他额外费用
  6209. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1073 翻译超时费
  6210. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1074 早餐超支费用
  6211. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1075 午餐超支费用
  6212. //case 91: opCostTypePrice = opCost.Sum(x => x.CarFee); break; //1076 晚餐超支费用
  6213. }
  6214. opCostStr = $"&nbsp;&nbsp;/&nbsp;&nbsp;成本:{opCostTypePrice:#0.00} {_groupCurrencyCode}(汇率:{_groupRate:#0.0000})";
  6215. costOPFeeCNY = opCostTypePrice * _groupRate;
  6216. if (!IsCurrencyAgreement) opCostStr += $" ≈ {costOPFeeCNY:#0.00} CNY";
  6217. }
  6218. #endregion
  6219. string opTypeStr = $"{typeName}:{item.Price:#0.00} {carCurrencyCode}(汇率:{entity.DayRate:#0.0000})";
  6220. aduitOPFeeCNY = item.Price * entity.DayRate;
  6221. if (!IsCurrencyAgreement) opTypeStr += $" ≈ {aduitOPFeeCNY:#0.0000} CNY";
  6222. var opContent = $"日期:{item.DatePrice?.ToString("yyyy-MM-dd") ?? "-"}<br/>" +
  6223. $"{opTypeStr} {opCostStr}<br/>" +
  6224. $"明细:{item.PriceContent ?? "-"}<br/>" +
  6225. $"备注:{item.Remark ?? "-"}<br/><br/>";
  6226. if (entity.IsAuditGM != 3) //状态 != 自动审核
  6227. {
  6228. if (IsCurrencyAgreement)
  6229. {
  6230. if (item.Price > opCostTypePrice)
  6231. {
  6232. opContent_sb.Append("<span style='color:red;'>");
  6233. opContent_sb.Append(opContent);
  6234. opContent_sb.Append("</span>");
  6235. opContent_sb.AppendLine();
  6236. }
  6237. else
  6238. {
  6239. opContent_sb.Append(opContent);
  6240. opContent_sb.AppendLine();
  6241. }
  6242. }
  6243. else
  6244. {
  6245. //验证是否超成本 按付款比例计算
  6246. if (aduitOPFeeCNY * opPayPercentage > costOPFeeCNY * opPayPercentage)
  6247. {
  6248. opContent_sb.Append("<span style='color:red;'>");
  6249. opContent_sb.Append(opContent);
  6250. opContent_sb.Append("</span>");
  6251. opContent_sb.AppendLine();
  6252. }
  6253. else
  6254. {
  6255. opContent_sb.Append(opContent);
  6256. opContent_sb.AppendLine();
  6257. }
  6258. }
  6259. }
  6260. else
  6261. {
  6262. opContent_sb.Append(opContent);
  6263. opContent_sb.AppendLine();
  6264. }
  6265. }
  6266. _detail.PriceMsgContent = opContent_sb.ToString();
  6267. }
  6268. break;
  6269. case 80: //签证
  6270. Grp_VisaInfo visaInfo = _VisaInfos.Where(s => s.Id == entity.CId).FirstOrDefault();
  6271. if (visaInfo != null)
  6272. {
  6273. string visaName = GetClientNameStr1(clientNameList, visaInfo.VisaClient);
  6274. _detail.PriceNameContent = visaInfo.VisaDescription;
  6275. _detail.PriceMsgContent = $"签证描述:{visaName}<br/> 备注:{visaInfo.Remark}";
  6276. }
  6277. break;
  6278. case 81: //邀请/公务活动
  6279. Grp_InvitationOfficialActivities _ioa = _InvitationOfficialActivities.Where(s => s.Id == entity.CId).FirstOrDefault();
  6280. if (_ioa != null)
  6281. {
  6282. string inviteCurrName = "Unknown", //邀请费用币种 Name
  6283. inviteCurrCode = "Unknown", //邀请费用币种 Code
  6284. sendCurrName = "Unknown", //快递费用币种 Name
  6285. sendCurrCode = "Unknown", //快递费用币种 Code
  6286. eventsCurrName = "Unknown", //公务活动费币种 Name
  6287. eventsCurrCode = "Unknown", //公务活动费币种 Code
  6288. translateCurrName = "Unknown", //公务翻译费 Name
  6289. translateCurrCode = "Unknown"; //公务翻译费 Code
  6290. #region 处理费用币种
  6291. var inviteCurrData = currencyItems.Where(s => s.Id == _ioa.InviteCurrency && s.IsDel == 0).FirstOrDefault();
  6292. if (inviteCurrData != null)
  6293. {
  6294. inviteCurrName = inviteCurrData.Remark;
  6295. inviteCurrCode = inviteCurrData.Name;
  6296. }
  6297. var sendCurrData = currencyItems.Where(s => s.Id == _ioa.SendCurrency && s.IsDel == 0).FirstOrDefault();
  6298. if (sendCurrData != null)
  6299. {
  6300. sendCurrName = sendCurrData.Remark;
  6301. sendCurrCode = sendCurrData.Name;
  6302. }
  6303. var eventsCurrData = currencyItems.Where(s => s.Id == _ioa.EventsCurrency && s.IsDel == 0).FirstOrDefault();
  6304. if (eventsCurrData != null)
  6305. {
  6306. eventsCurrName = eventsCurrData.Remark;
  6307. eventsCurrCode = eventsCurrData.Name;
  6308. }
  6309. var translateCurrData = currencyItems.Where(s => s.Id == _ioa.TranslateCurrency && s.IsDel == 0).FirstOrDefault();
  6310. if (translateCurrData != null)
  6311. {
  6312. translateCurrName = translateCurrData.Remark;
  6313. translateCurrCode = translateCurrData.Name;
  6314. }
  6315. #endregion
  6316. _detail.PriceNameContent = _ioa.InviterArea;
  6317. //2025-09-08 商邀费用名称更改:单项费用不等于0,则在名称后面最加费用类型名称。
  6318. List<string> priceExpNames = new List<string>();
  6319. if (_ioa.InviteCost != 0.00M) priceExpNames.Add("邀请费");
  6320. if (_ioa.SendCost != 0.00M) priceExpNames.Add("快递费");
  6321. if (_ioa.EventsCost != 0.00M) priceExpNames.Add("公务活动费");
  6322. if (_ioa.TranslateCost != 0.00M) priceExpNames.Add("公务翻译费");
  6323. if (priceExpNames != null && priceExpNames.Count > 0)
  6324. {
  6325. _detail.PriceNameContent += $"({string.Join("+", priceExpNames)})";
  6326. }
  6327. _detail.PriceMsgContent = $@"邀请费用:{_ioa.InviteCost:#0.00} {inviteCurrCode}({inviteCurrName})<br/>" +
  6328. $@"快递费用:{_ioa.SendCost:#0.00} {sendCurrCode}({sendCurrName})<br/>" +
  6329. $@"公务活动费:{_ioa.EventsCost:#0.00} {eventsCurrCode}({eventsCurrName})<br/>" +
  6330. $@"公务翻译费:{_ioa.TranslateCost:#0.00} {translateCurrCode}({translateCurrName})<br/>" +
  6331. $@"备注:" + _ioa.Remark + "<br/>";
  6332. }
  6333. break;
  6334. case 82: //团组客户保险
  6335. Grp_Customers customers = _Customers.Where(s => s.Id == entity.CId && s.IsDel == 0).FirstOrDefault();
  6336. if (customers != null)
  6337. {
  6338. _detail.PriceNameContent = GetClientNameStr(clientNameList, customers.ClientName);
  6339. _detail.PriceMsgContent = "备注:" + customers.Remark + "<br/>";
  6340. }
  6341. break;
  6342. case 85: //机票预订
  6343. Grp_AirTicketReservations jpRes = _AirTicketReservations.Where(s => s.Id == entity.CId).FirstOrDefault();
  6344. if (jpRes != null)
  6345. {
  6346. string FlightsDescription = jpRes.FlightsDescription;
  6347. string PriceDescription = jpRes.PriceDescription;
  6348. _detail.PriceMsgContent = "航班号:" + jpRes.FlightsCode + "<br/>城市A-B:" + jpRes.FlightsCity + "<br/>航班描述:" + FlightsDescription.Replace("\r\n", "<br />") + "<br/>" + "价格描述:" + PriceDescription;
  6349. _detail.PriceNameContent = "(" + jpRes.FlightsCode + ")";
  6350. }
  6351. break;
  6352. case 98://其他款项
  6353. Grp_DecreasePayments gdpRes = _DecreasePayments.Where(s => s.Id == entity.CId).FirstOrDefault();
  6354. if (gdpRes != null)
  6355. {
  6356. //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/";
  6357. //if (!string.IsNullOrEmpty(gdpRes.FilePath))
  6358. //{
  6359. // _detail.FileUrl = $"{urlBase}{gdpRes.FilePath}";
  6360. //}
  6361. _detail.PriceMsgContent = "备注:" + gdpRes.Remark;
  6362. _detail.PriceNameContent = gdpRes.PriceName;
  6363. }
  6364. break;
  6365. case 285://收款退还
  6366. Fin_PaymentRefundAndOtherMoney refundAndOtherMoney = _PaymentRefundAndOtherMoneys.Where(s => s.Id == entity.CId).FirstOrDefault();
  6367. if (refundAndOtherMoney != null)
  6368. {
  6369. _detail.PriceMsgContent = "备注:" + refundAndOtherMoney.Remark;
  6370. _detail.PriceNameContent = refundAndOtherMoney.PriceName;
  6371. }
  6372. break;
  6373. case 751://酒店早餐
  6374. break;
  6375. case 1015://超支费用
  6376. Fin_GroupExtraCost groupExtraCost = _GroupExtraCosts.Where(s => s.Id == entity.CId).FirstOrDefault();
  6377. if (groupExtraCost != null)
  6378. {
  6379. _detail.PriceNameContent = groupExtraCost.PriceName;
  6380. _detail.PriceMsgContent = "备注:" + groupExtraCost.Remark;
  6381. }
  6382. break;
  6383. default:
  6384. break;
  6385. }
  6386. /*
  6387. * 申请人
  6388. */
  6389. string operatorName = " - ";
  6390. var _opUser = userItems.Where(s => s.Id == entity.CreateUserId).FirstOrDefault();
  6391. if (_opUser != null)
  6392. {
  6393. operatorName = _opUser.CnName;
  6394. }
  6395. _detail.OperatorName = operatorName;
  6396. /*
  6397. * 审核人
  6398. */
  6399. string auditOperatorName = " - ";
  6400. if (entity.IsAuditGM != 0)
  6401. {
  6402. if (entity.AuditGMOperate == 0) auditOperatorName = " - ";
  6403. else if (entity.AuditGMOperate == 4) auditOperatorName = "自动审核";
  6404. else
  6405. {
  6406. var _adUser = userItems.Where(s => s.Id == entity.AuditGMOperate).FirstOrDefault();
  6407. if (_adUser != null)
  6408. {
  6409. auditOperatorName = _adUser.CnName;
  6410. }
  6411. }
  6412. }
  6413. _detail.AuditOperatorName = auditOperatorName;
  6414. /*
  6415. * 超预算比例
  6416. */
  6417. string overBudgetStr = "";
  6418. if (entity.ExceedBudget == -1) overBudgetStr = sdPriceName.Name + "尚无预算";
  6419. else if (entity.ExceedBudget == 0)
  6420. {
  6421. if (entity.CTable == 76 || entity.CTable == 79)
  6422. {
  6423. if (entity.IsAuditGM == 3) overBudgetStr = "未超预算";
  6424. else overBudgetStr = _feeAuditRep.IsOverBudget(entity.CTable, entity.DIId, entity.CId);
  6425. }
  6426. else
  6427. {
  6428. overBudgetStr = "未超预算";
  6429. }
  6430. }
  6431. else overBudgetStr = entity.ExceedBudget.ToString("P");
  6432. _detail.OverBudget = overBudgetStr;
  6433. decimal auditFee = 0.00M; //已审核金额 人名币
  6434. decimal auditedFeeOriginal = 0.00M; ////已审核金额 原始
  6435. decimal unAuditFeeCNY = 0.00M; //未审核款项 原始
  6436. decimal unAuditFeeOriginal = 0.00M; //未审核款项 人名币
  6437. if (entity.IsAuditGM == 1 || entity.IsAuditGM == 3)
  6438. {
  6439. auditedFeeOriginal = entity.PayMoney;
  6440. auditFee = CurrPayStr;
  6441. }
  6442. else if (entity.IsAuditGM == 0)
  6443. {
  6444. unAuditFeeCNY = CurrPayStr;
  6445. unAuditFeeOriginal = OriginalCurrPay;
  6446. OriginalCurrPay = 0.00M;
  6447. }
  6448. /*
  6449. * 费用总计
  6450. */
  6451. ccpCurrencyPrices.Add(new CreditCardPaymentCurrencyPriceItem()
  6452. {
  6453. CurrencyId = entity.PaymentCurrency,
  6454. CurrencyName = PaymentCurrency_WaitPay,
  6455. AmountPayable = entity.PayMoney,
  6456. ThisPayment = OriginalCurrPay,
  6457. BalancePayment = BalanceStr,
  6458. AuditedFunds = auditFee,
  6459. AuditedFundsOriginal = auditedFeeOriginal,
  6460. UnAuditFundsCNY = unAuditFeeCNY,
  6461. UnAuditFundsOriginal = unAuditFeeOriginal
  6462. });
  6463. _detail.IsAuditGM = entity.IsAuditGM;
  6464. detailList.Add(_detail);
  6465. }
  6466. #endregion
  6467. _view.DetailList = new List<Grp_CreditCardPaymentDetailView>(detailList);
  6468. /*
  6469. * 下方描述处理
  6470. */
  6471. var nonDuplicat = ccpCurrencyPrices.Where((x, i) => ccpCurrencyPrices.FindIndex(z => z.CurrencyId == x.CurrencyId) == i).ToList();//Lambda表达式去重
  6472. var ccpCurrencyPrice = nonDuplicat.Where(it => it.CurrencyId == 836).FirstOrDefault();
  6473. if (ccpCurrencyPrice != null)
  6474. {
  6475. int CNYIndex = nonDuplicat.IndexOf(ccpCurrencyPrice);
  6476. nonDuplicat.MoveItemAtIndexToFront(CNYIndex);
  6477. }
  6478. else
  6479. {
  6480. nonDuplicat = nonDuplicat.OrderBy(it => it.CurrencyId).ToList();
  6481. }
  6482. string amountPayableStr = string.Format(@"应付款总金额: ");
  6483. string thisPaymentStr = string.Format(@"此次付款总金额: ");
  6484. string balancePaymentStr = string.Format(@"目前剩余尾款总金额: ");
  6485. string auditedFundsStr = string.Format(@"已审费用总额: ");
  6486. string unAuditedFundsStr = string.Format(@"未审费用总额: ");
  6487. foreach (var item in nonDuplicat)
  6488. {
  6489. var currencyName = item.CurrencyName;
  6490. var strs = ccpCurrencyPrices.Where(it => it.CurrencyId == item.CurrencyId).ToList();
  6491. if (strs.Count > 0)
  6492. {
  6493. decimal amountPayable = strs.Sum(it => it.AmountPayable);
  6494. decimal thisPayment = ccpCurrencyPrices.Sum(it => it.ThisPayment);
  6495. decimal balancePayment = strs.Sum(it => it.BalancePayment);
  6496. amountPayableStr += string.Format(@"{0}{1}&nbsp;|", amountPayable.ToString("#0.00"), currencyName);
  6497. //单独处理此次付款金额
  6498. thisPaymentStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  6499. balancePaymentStr += string.Format(@"{0}{1}&nbsp;|", balancePayment.ToString("#0.00"), currencyName);
  6500. //单独处理已审核费用
  6501. //if (item.CurrencyId == 836) //人民币
  6502. //{
  6503. // decimal auditedFunds = ccpCurrencyPrices.Sum(it => it.AuditedFunds);
  6504. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", auditedFunds.ToString("#0.00"), currencyName);
  6505. //}
  6506. //else
  6507. //{
  6508. // auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.AmountPayable), currencyName);
  6509. //}
  6510. if (currencyName.Equals("CNY"))
  6511. {
  6512. //已审核费用
  6513. auditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.ThisPayment).ToString("#0.00"), currencyName);
  6514. //未审核费用
  6515. unAuditedFundsStr += string.Format(@"{0}{1}&nbsp;|", strs.Sum(x => x.UnAuditFundsOriginal).ToString("#0.00"), currencyName);
  6516. }
  6517. else
  6518. {
  6519. //已审核费用
  6520. 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"));
  6521. //未审核费用
  6522. 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"));
  6523. }
  6524. }
  6525. }
  6526. _view.TotalStr1 = amountPayableStr[..^1];
  6527. _view.TotalStr2 = thisPaymentStr[..^1];
  6528. _view.TotalStr3 = balancePaymentStr[..^1];
  6529. _view.TotalStr4 = $"{auditedFundsStr[..^1]}<br/>{unAuditedFundsStr[..^1]}";
  6530. //_view.TotalStr5 = unAuditedFundsStr.Substring(0, unAuditedFundsStr.Length - 1);
  6531. var _view1 = new
  6532. {
  6533. PageFuncAuth = pageFunAuthView,
  6534. Data = _view
  6535. };
  6536. return Ok(JsonView(_view1));
  6537. }
  6538. catch (Exception ex)
  6539. {
  6540. return Ok(JsonView(false, ex.Message));
  6541. }
  6542. }
  6543. /// <summary>
  6544. /// 费用审核
  6545. /// 修改团组费用审核状态
  6546. /// </summary>
  6547. /// <param name="_dto">参数Json字符串</param>
  6548. /// <returns></returns>
  6549. [HttpPost]
  6550. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6551. public async Task<IActionResult> PostAuditGrpCreditCardPayment(Edit_GrpCreditCardPaymentDto _dto)
  6552. {
  6553. #region 参数验证
  6554. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  6555. if (_dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  6556. #endregion
  6557. #region 页面操作权限验证
  6558. var pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  6559. if (pageFunAuthView.AuditAuth == 0) return Ok(JsonView(false, "您没有审核权限"));
  6560. #endregion
  6561. List<string> idList = _dto.CreditIdStr.Split(',').ToList();
  6562. Grp_CreditCardPayment _detail = _mapper.Map<Grp_CreditCardPayment>(_dto);
  6563. DateTime dtNow = DateTime.Now;
  6564. _groupRepository.BeginTran();
  6565. int rst = 0;
  6566. var creditDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && idList.Contains(it.Id.ToString())).ToList();
  6567. var creditTypeDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 16).ToList();
  6568. var creditCurrencyDatas = _grpScheduleRep._sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  6569. var groupDatas = _grpScheduleRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).ToList();
  6570. var msgDatas = new List<dynamic>();
  6571. var dic_ccp_user = new Dictionary<int, int>() { };
  6572. foreach (var item in idList)
  6573. {
  6574. int CreditId = int.Parse(item);
  6575. var result = await _grpScheduleRep._sqlSugar.Updateable<Grp_CreditCardPayment>()
  6576. .SetColumns(it => it.IsAuditGM == _dto.AuditCode)
  6577. .SetColumns(it => it.AuditGMOperate == _dto.UserId)
  6578. .SetColumns(it => it.AuditGMDate == dtNow.ToString("yyyy-MM-dd HH:mm:ss"))
  6579. .Where(s => s.Id == CreditId)
  6580. .ExecuteCommandAsync();
  6581. if (result < 1)
  6582. {
  6583. rst = -1;
  6584. _groupRepository.RollbackTran();
  6585. return Ok(JsonView(false, "操作失败并回滚!"));
  6586. }
  6587. var creditData = creditDatas.Where(it => it.Id == CreditId).FirstOrDefault();
  6588. if (creditData != null)
  6589. {
  6590. #region 应用通知配置
  6591. try
  6592. {
  6593. dic_ccp_user.Add(creditData.Id, creditData.CreateUserId);
  6594. }
  6595. catch (Exception ex)
  6596. {
  6597. }
  6598. #endregion
  6599. string auditStr = _dto.AuditCode == 1 ? "已通过" : _dto.AuditCode == 2 ? "未通过" : "未审核";
  6600. string groupNameStr = string.Empty;
  6601. var groupData = groupDatas.Where(it => it.Id == creditData.DIId).FirstOrDefault();
  6602. if (groupData != null) groupNameStr = groupData.TeamName;
  6603. string creditTypeStr = string.Empty;
  6604. var creditTypeData = creditTypeDatas.Where(it => it.Id == creditData.CTable).FirstOrDefault();
  6605. if (creditTypeData != null) creditTypeStr = creditTypeData.Name;
  6606. string creditCurrency = string.Empty;
  6607. var creditCurrencyData = creditCurrencyDatas.Where(it => it.Id == creditData.PaymentCurrency).FirstOrDefault();
  6608. if (creditCurrencyData != null) creditCurrency = creditCurrencyData.Name;
  6609. if (creditCurrency.Equals("CNY"))
  6610. {
  6611. creditData.DayRate = 1.0000M;
  6612. }
  6613. if (creditData.PayPercentage == 0.00M)
  6614. {
  6615. creditData.PayPercentage = 100M;
  6616. }
  6617. decimal CNYPrice = (creditData.PayMoney * (creditData.PayPercentage / 100)) * creditData.DayRate;
  6618. string msgTitle = $"[{groupNameStr}({creditTypeStr})]的费用申请";
  6619. string msgContent = "";
  6620. if (creditCurrency.Equals("CNY"))
  6621. {
  6622. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY) {auditStr}!";
  6623. }
  6624. else
  6625. {
  6626. msgContent = $"[{groupNameStr}({creditTypeStr})]费用申请(金额:{CNYPrice:0.00} CNY({creditData.PayMoney:0.00} {creditCurrency})) {auditStr}!";
  6627. }
  6628. msgDatas.Add(new { DiId = creditData.DIId, UserId = creditData.CreateUserId, MsgTitle = msgTitle, MsgContent = msgContent });
  6629. }
  6630. }
  6631. if (rst == 0)
  6632. {
  6633. _groupRepository.CommitTran();
  6634. foreach (var item in msgDatas)
  6635. {
  6636. //发送消息
  6637. GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupExpenseAudit, item.MsgTitle, item.MsgContent, new List<int>() { item.UserId }, item.DiId);
  6638. }
  6639. #region 应用推送
  6640. try
  6641. {
  6642. foreach (var ccpId in dic_ccp_user.Keys)
  6643. {
  6644. var templist = new List<string>() { dic_ccp_user[ccpId].ToString() };
  6645. await AppNoticeLibrary.SendUserMsg_GroupStatus_AuditFee(ccpId, templist, QiyeWeChatEnum.CaiWuChat);
  6646. }
  6647. }
  6648. catch (Exception)
  6649. {
  6650. }
  6651. #endregion
  6652. return Ok(JsonView(true, "操作成功!"));
  6653. }
  6654. return Ok(JsonView(false, "操作失败!"));
  6655. }
  6656. /// <summary>
  6657. /// 费用审核
  6658. /// 其他款项 文件下载
  6659. /// </summary>
  6660. /// <param name="id">其他款项 主键编号</param>
  6661. /// <returns></returns>
  6662. [HttpGet("{id}")]
  6663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6664. public async Task<IActionResult> FeeAuditOtherFileDownlaod([Range(1, int.MaxValue, ErrorMessage = "请传入有效的ID")] int id)
  6665. {
  6666. //网站域名
  6667. 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/";
  6668. var otherInfo = await _decreasePaymentsRep._sqlSugar
  6669. .Queryable<Grp_DecreasePayments>()
  6670. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.Id == id)
  6671. .Where(((x, y) => x.IsDel == 0 && y.IsDel == 0))
  6672. .Select((x, y) => new
  6673. {
  6674. x.Id,
  6675. x.FilePath
  6676. })
  6677. .FirstAsync();
  6678. if (otherInfo != null && !string.IsNullOrEmpty(otherInfo.FilePath.Trim()))
  6679. {
  6680. var url = $"{baseUrl}{otherInfo.FilePath}";
  6681. return Ok(JsonView(true, "操作成功!", url));
  6682. }
  6683. return Ok(JsonView(false, "暂无附件"));
  6684. }
  6685. #endregion
  6686. #region 机票费用录入
  6687. /// <summary>
  6688. /// 机票录入当前登录人可操作团组
  6689. /// </summary>
  6690. /// <param name="dto"></param>
  6691. /// <returns></returns>
  6692. [HttpPost]
  6693. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6694. public async Task<IActionResult> AirTicketResSelect(AirTicketResDto dto)
  6695. {
  6696. try
  6697. {
  6698. Result groupData = await _airTicketResRep.AirTicketResSelect(dto);
  6699. if (groupData.Code != 0)
  6700. {
  6701. return Ok(JsonView(false, groupData.Msg));
  6702. }
  6703. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6704. }
  6705. catch (Exception ex)
  6706. {
  6707. return Ok(JsonView(false, ex.Message));
  6708. }
  6709. }
  6710. /// <summary>
  6711. /// 机票费用录入列表
  6712. /// </summary>
  6713. /// <param name="dto"></param>
  6714. /// <returns></returns>
  6715. [HttpPost]
  6716. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6717. public async Task<IActionResult> AirTicketResList(AirTicketResDto dto)
  6718. {
  6719. try
  6720. {
  6721. Result groupData = await _airTicketResRep.AirTicketResList(dto);
  6722. if (groupData.Code != 0)
  6723. {
  6724. return Ok(JsonView(false, groupData.Msg));
  6725. }
  6726. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6727. }
  6728. catch (Exception ex)
  6729. {
  6730. return Ok(JsonView(false, ex.Message));
  6731. throw;
  6732. }
  6733. }
  6734. /// <summary>
  6735. /// 根据id查询费用录入信息
  6736. /// </summary>
  6737. /// <param name="dto"></param>
  6738. /// <returns></returns>
  6739. [HttpPost]
  6740. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6741. public async Task<IActionResult> AirTicketResById(AirTicketResByIdDto dto)
  6742. {
  6743. Result groupData = await _airTicketResRep.AirTicketResById(dto);
  6744. if (groupData.Code != 0)
  6745. {
  6746. return Ok(JsonView(false, groupData.Msg));
  6747. }
  6748. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6749. }
  6750. /// <summary>
  6751. /// 机票费用录入操作(Status:1.新增,2.修改)
  6752. /// </summary>
  6753. /// <param name="dto"></param>
  6754. /// <returns></returns>
  6755. [HttpPost]
  6756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6757. public async Task<IActionResult> OpAirTicketRes(AirTicketResOpDto dto)
  6758. {
  6759. Result groupData = await _airTicketResRep.OpAirTicketRes(dto, _setDataRep.PostCurrencyByDiid);
  6760. if (groupData.Code != 0)
  6761. {
  6762. return Ok(JsonView(false, groupData.Msg));
  6763. }
  6764. #region 应用推送
  6765. try
  6766. {
  6767. var diId = dto.AirTicketResOpData.DiId;
  6768. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  6769. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  6770. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  6771. //自动审核
  6772. //var autoAdit1 = await _feeAuditRep.FeeAutomaticAudit(5, diId, dataId); //机票费用合计方式
  6773. (bool status, string auditMsg) = await AirTicketResAutoAudit(diId, dataId); //KIMI-AI识别INIT方式
  6774. _logger.LogInformation("【机票费用自动审核(KIMI-AI识别INIT)】请求参数:{RequstData} 返回结果:是否执行:{IsExecute}; 结果消息:{ResponseMsg};",
  6775. $"GroupId:{diId};airId:{dataId};",
  6776. status,
  6777. auditMsg);
  6778. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  6779. //2024-10-21 新增LZ UID
  6780. var userIds = new List<int>() { 21 };
  6781. string title = $"系统通知";
  6782. string content = "";
  6783. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  6784. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  6785. if (dto.Status == 1) content = $"[新增-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6786. else if (dto.Status == 2) content = $"[更新-机票费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  6787. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  6788. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "85" };
  6789. await APNsTools.iOS_PushNotifications1("051", $"机票费用审核", "", content, true, "ExpenseAuditWebView", h5);
  6790. }
  6791. catch (Exception ex)
  6792. {
  6793. }
  6794. #endregion
  6795. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  6796. }
  6797. /// <summary>
  6798. /// 机票费用自动审核 AI识别方式
  6799. /// </summary>
  6800. /// <returns></returns>
  6801. private async Task<(bool, string)> AirTicketResAutoAudit(int diId, int dataId)
  6802. {
  6803. var ecoTypeIds = new List<int>() {
  6804. 459, //超经舱
  6805. 460, //经济舱
  6806. 1430, //公务舱(实际经济舱)
  6807. 1432, //头等舱(实际经济舱)
  6808. };
  6809. var bizTypeIds = new List<int>() {
  6810. 457, //头等舱
  6811. 458, //公务舱
  6812. 1431, //头等舱(实际公务舱)
  6813. };
  6814. var auditFeeTypeIds = new List<int>() { };
  6815. auditFeeTypeIds.AddRange(ecoTypeIds);
  6816. auditFeeTypeIds.AddRange(bizTypeIds);
  6817. int currModule = 85;
  6818. var airInfo = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  6819. .InnerJoin<Grp_CreditCardPayment>((x, y) => x.Id == y.CId && y.CTable == currModule && y.IsDel == 0)
  6820. .Where((x, y) => x.Id == dataId && x.IsDel == 0 && auditFeeTypeIds.Contains(x.CType))
  6821. .Select((x, y) => new
  6822. {
  6823. x.Id,
  6824. CcpId = y.Id,
  6825. x.FlightsDate,
  6826. x.PrePrice,
  6827. x.CType,
  6828. x.ClientNum,
  6829. x.DIId
  6830. })
  6831. .FirstAsync();
  6832. if (airInfo == null) return (false, "机票信息为空或费用类型不在自动审核范围内,不可自动审核!");
  6833. var groupDetails = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.IsDel == 0 && x.Id == diId);
  6834. if (groupDetails == null) return (false, "团组信息为空,不可自动审核!");
  6835. var groupCostInfo = await _sqlSugar.Queryable<Grp_GroupCostParameter>().FirstAsync(x => x.IsDel == 0 && x.DiId == diId);
  6836. if (groupCostInfo == null) return (false, "团组成本信息未填写!");
  6837. var groupCostContents = await _sqlSugar
  6838. .SqlQueryable<GroupCostAuditView>($"Select * From Grp_GroupCost")
  6839. .Where(x => x.IsDel == 0 && x.Diid == diId)
  6840. .ToListAsync();
  6841. if (groupCostContents.Count < 1) return (false, "团组成本信息未填写!");
  6842. //处理 成本详细信息日期为空 填装费用信息
  6843. var airFeeLabel = new StringBuilder();
  6844. airFeeLabel.AppendLine("费用成本:");
  6845. for (int i = 0; i < groupCostContents.Count; i++)
  6846. {
  6847. if (string.IsNullOrEmpty(groupCostContents[i].Date))
  6848. {
  6849. int index = i - 1;
  6850. if (index >= 0)
  6851. {
  6852. groupCostContents[i].Date = groupCostContents[index].Date;
  6853. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  6854. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  6855. }
  6856. }
  6857. else
  6858. {
  6859. var dtBool = DateTime.TryParse(groupCostContents[i].Date, out DateTime _dateTime);
  6860. if (dtBool) groupCostContents[i].CurrTime = _dateTime;
  6861. }
  6862. var item = groupCostContents[i];
  6863. airFeeLabel.AppendLine($"{item.Date}");
  6864. airFeeLabel.AppendLine($"{item.ITIN.Replace("\n", " ")}");
  6865. }
  6866. airFeeLabel.AppendLine($"注:费用:位置:航班号或者航班时间后面; 组成:经济舱/公务舱;");
  6867. airFeeLabel.AppendLine($"取出“{airInfo.FlightsDate}”费用金额,按照经济舱/公务舱格式返回,如果不存在的话则返回0.00/0.00,只返回金额格式文本;不需要其他文字描述;");
  6868. //访问Kimi AI 返回价格结果
  6869. var msgs = new List<SeedMessages>()
  6870. {
  6871. new ()
  6872. {
  6873. Role = KimiRole.user,
  6874. Content = airFeeLabel.ToString()
  6875. }
  6876. };
  6877. var client = new KiMiApiClient();
  6878. var kimiApiResult = await client.SeedMessage(msgs);
  6879. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  6880. string clients = kimiApiResult_JObject["content"].ToString();
  6881. decimal ecoPri_kimiAI = 0.00M,
  6882. bizPri_kimiAI = 0.00M;
  6883. //单个价格: 经济舱价格
  6884. if (decimal.TryParse(clients, out ecoPri_kimiAI)) { }
  6885. //价格文本包含/:/前经济舱价格 /后公务舱价格
  6886. if (clients.Contains('/'))
  6887. {
  6888. var priArray = clients.Split('/');
  6889. decimal.TryParse(priArray[0], out ecoPri_kimiAI); //
  6890. decimal.TryParse(priArray[1], out bizPri_kimiAI); //经济舱价格
  6891. }
  6892. else return (false, "价格文本不存在价格或KIMI-AI未识别出价格,不可自动审核!");
  6893. var isAutoAudit = false;
  6894. //价格验证处理
  6895. //经济舱
  6896. if (ecoTypeIds.Contains(airInfo.CType))
  6897. {
  6898. if (airInfo.PrePrice <= ecoPri_kimiAI) isAutoAudit = true;
  6899. }
  6900. //公务舱
  6901. else if (bizTypeIds.Contains(airInfo.CType))
  6902. {
  6903. if (airInfo.PrePrice <= bizPri_kimiAI) isAutoAudit = true;
  6904. }
  6905. else return (false, "该舱位类型不在自动审核范围内,不可自动审核!");
  6906. //是否执行自动审核
  6907. if (isAutoAudit)
  6908. {
  6909. var auditStatus = await _sqlSugar.Updateable<Grp_CreditCardPayment>()
  6910. .SetColumns(x => x.IsAuditGM == 3)
  6911. .SetColumns(x => x.AuditGMOperate == 4)
  6912. .SetColumns(x => x.AuditGMDate == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  6913. .Where(x => x.Id == airInfo.CcpId)
  6914. .ExecuteCommandAsync();
  6915. if (auditStatus > 0) return (true, "机票自动审核(KIMI-AI识别方式)执行成功!");
  6916. }
  6917. return (false, "当前费用超过成本费用,不可自动审核!");
  6918. }
  6919. /// <summary>
  6920. /// 机票费用录入
  6921. /// 自动审核测试 - AI 识别
  6922. /// </summary>
  6923. /// <param name="groupId"></param>
  6924. /// <param name="Id"></param>
  6925. /// <returns></returns>
  6926. [HttpPost]
  6927. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6928. public async Task<IActionResult> AirTicketResAutoAuditTest(int groupId, int Id)
  6929. {
  6930. (bool status, string msg) = await AirTicketResAutoAudit(groupId, Id);
  6931. return Ok(JsonView(status, msg));
  6932. }
  6933. /// <summary>
  6934. /// 根据舱位类型查询接团客户名单信息
  6935. /// </summary>
  6936. /// <param name="dto"></param>
  6937. /// <returns></returns>
  6938. [HttpPost]
  6939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6940. public async Task<IActionResult> TankType(AirTicketResByIdDto dto)
  6941. {
  6942. try
  6943. {
  6944. List<Crm_GroupCustomer> crm_Groups = _sqlSugar.Queryable<Crm_GroupCustomer>().Where(a => a.IsDel == 0 && a.AirType == dto.Id).ToList();
  6945. if (crm_Groups.Count != 0)
  6946. {
  6947. var Customer = new List<dynamic>();
  6948. foreach (var item in crm_Groups)
  6949. {
  6950. var data = new
  6951. {
  6952. item.Id,
  6953. item.Pinyin,
  6954. Name = item.LastName + item.FirstName
  6955. };
  6956. Customer.Add(data);
  6957. }
  6958. return Ok(JsonView(true, "查询成功!", Customer));
  6959. }
  6960. return Ok(JsonView(true, "暂无数据", crm_Groups));
  6961. }
  6962. catch (Exception ex)
  6963. {
  6964. return Ok(JsonView(false, "程序错误!"));
  6965. throw;
  6966. }
  6967. }
  6968. /// <summary>
  6969. /// 根据团号获取客户信息
  6970. /// </summary>
  6971. /// <param name="dto"></param>
  6972. /// <returns></returns>
  6973. [HttpPost]
  6974. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  6975. public IActionResult QueryClientInfoByDIID(QueryClientInfoByDIIDDto dto)
  6976. {
  6977. var jw = JsonView(false);
  6978. if (dto.DIID < 1)
  6979. {
  6980. jw.Msg += "请输入正确的diid";
  6981. return Ok(jw);
  6982. }
  6983. var arr = GetSimplClientList(dto.DIID);
  6984. jw = JsonView(true, "获取成功!", arr);
  6985. return Ok(jw);
  6986. }
  6987. private List<SimplClientInfo> GetSimplClientList(int diId)
  6988. {
  6989. 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);
  6990. List<SimplClientInfo> arr = _sqlSugar.SqlQueryable<SimplClientInfo>(sql).ToList();
  6991. foreach (var item in arr)
  6992. {
  6993. EncryptionProcessor.DecryptProperties(item);
  6994. }
  6995. return arr;
  6996. }
  6997. private static string GetClientNameStr(List<SimplClientInfo> list, string origin)
  6998. {
  6999. string result = origin;
  7000. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  7001. {
  7002. string[] temparr = origin.Split(',');
  7003. string fistrStr = temparr[0];
  7004. int count = temparr.Length;
  7005. bool success = int.TryParse(fistrStr, out int tempId);
  7006. if (success)
  7007. {
  7008. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  7009. if (tempInfo != null)
  7010. {
  7011. if (count > 1)
  7012. {
  7013. result = string.Format(@"{0}{1}等{2}人", tempInfo.LastName, tempInfo.FirstName, count);
  7014. }
  7015. else
  7016. {
  7017. result = string.Format(@"{0}{1}", tempInfo.LastName, tempInfo.FirstName);
  7018. }
  7019. }
  7020. }
  7021. }
  7022. return result;
  7023. }
  7024. private static string GetClientNameStr1(List<SimplClientInfo> list, string origin)
  7025. {
  7026. string result = origin;
  7027. if (Regex.Match(origin, @"\d+,?").Value.Length > 0)
  7028. {
  7029. string[] temparr = origin.Split(',');
  7030. result = "";
  7031. foreach (var item in temparr)
  7032. {
  7033. bool success = int.TryParse(item, out int tempId);
  7034. if (success)
  7035. {
  7036. SimplClientInfo tempInfo = list.FirstOrDefault(s => s.Id == tempId);
  7037. if (tempInfo != null)
  7038. {
  7039. result += string.Format(@"{0}{1}、", tempInfo.LastName, tempInfo.FirstName);
  7040. }
  7041. }
  7042. }
  7043. }
  7044. if (result.Length > 0) result = result.Substring(0, result.Length - 1);
  7045. return result;
  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> DelAirTicketRes(DelBaseDto dto)
  7055. {
  7056. try
  7057. {
  7058. var res = await _airTicketResRep.SoftDeleteByIdAsync<Grp_AirTicketReservations>(dto.Id.ToString(), dto.DeleteUserId);
  7059. if (res)
  7060. {
  7061. var result = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.CTable == 85).SetColumns(a => new Grp_CreditCardPayment()
  7062. {
  7063. IsDel = 1,
  7064. DeleteUserId = dto.DeleteUserId,
  7065. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  7066. }).ExecuteCommandAsync();
  7067. return Ok(JsonView(true, "删除成功!"));
  7068. }
  7069. return Ok(JsonView(false, "删除失败!"));
  7070. }
  7071. catch (Exception ex)
  7072. {
  7073. return Ok(JsonView(false, "程序错误!"));
  7074. throw;
  7075. }
  7076. }
  7077. /// <summary>
  7078. /// 导出机票录入报表
  7079. /// </summary>
  7080. /// <param name="dto"></param>
  7081. /// <returns></returns>
  7082. [HttpPost]
  7083. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7084. public async Task<IActionResult> DeriveAirTicketRes(AirTicketResDto dto)
  7085. {
  7086. try
  7087. {
  7088. Result groupData = await _airTicketResRep.DeriveAirTicketRes(dto);
  7089. if (groupData.Code != 0)
  7090. {
  7091. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  7092. }
  7093. else
  7094. {
  7095. List<AirTicketReservationsPayView> AirTicketReservations = groupData.Data.GetType().GetProperty("AirTicketRes").GetValue(groupData.Data);
  7096. if (AirTicketReservations.Count != 0)
  7097. {
  7098. Grp_DelegationInfo DelegationInfo = groupData.Data.GetType().GetProperty("Delegation").GetValue(groupData.Data);
  7099. Sys_Users _Users = groupData.Data.GetType().GetProperty("Users").GetValue(groupData.Data);
  7100. string diCode = DelegationInfo != null ? DelegationInfo.TourCode : "XXX";
  7101. string diName = DelegationInfo != null ? DelegationInfo.TeamName : "XXX";
  7102. var designer = new WorkbookDesigner
  7103. {
  7104. Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/机票预订费用报表模板.xlsx")
  7105. };
  7106. decimal countCost = 0;
  7107. foreach (var item in AirTicketReservations)
  7108. {
  7109. #region 处理客人姓名
  7110. string clientNames = _tourClientListRep.ResolveCustomerName(item.ClientName);
  7111. item.ClientName = clientNames;
  7112. #endregion
  7113. if (item.BankType == "其他")
  7114. {
  7115. item.BankNo = "--";
  7116. }
  7117. else
  7118. {
  7119. if (!string.IsNullOrEmpty(item.BankType))
  7120. {
  7121. item.BankNo = $"{item.BankType}:{item.BankNo?[..3]}";
  7122. }
  7123. }
  7124. item.PrePrice = System.Decimal.Round(item.PrePrice, 2);
  7125. item.Price = System.Decimal.Round(item.Price, 2);
  7126. countCost += Convert.ToDecimal(item.Price);
  7127. }
  7128. designer.SetDataSource("Export", AirTicketReservations);
  7129. designer.SetDataSource("ExportDiCode", diCode);
  7130. designer.SetDataSource("ExportDiName", diName);
  7131. designer.SetDataSource("ExportOpUserName", _Users.CnName);
  7132. designer.SetDataSource("ExportCountCost", countCost + "(" + AirTicketReservations[0].CurrencyStr);
  7133. designer.Process();
  7134. string fileName = ("AirfareStatement/" + diName + "机票费用报表" + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx").Replace(":", "");
  7135. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
  7136. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  7137. return Ok(JsonView(true, "成功", url = rst));
  7138. }
  7139. else
  7140. {
  7141. return Ok(JsonView(StatusCodes.Status400BadRequest, "暂无数据!", ""));
  7142. }
  7143. }
  7144. }
  7145. catch (Exception ex)
  7146. {
  7147. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  7148. throw;
  7149. }
  7150. }
  7151. private Dictionary<string, string> transDic = new Dictionary<string, string>();
  7152. /// <summary>
  7153. /// 行程单导出
  7154. /// </summary>
  7155. /// <param name="dto"></param>
  7156. /// <returns></returns>
  7157. [HttpPost]
  7158. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7159. public async Task<IActionResult> ItineraryAirTicketRes(ItineraryAirTicketResDto dto)
  7160. {
  7161. try
  7162. {
  7163. Result groupData = await _airTicketResRep.ItineraryAirTicketRes(dto);
  7164. if (groupData.Code != 0)
  7165. {
  7166. return Ok(JsonView(StatusCodes.Status400BadRequest, groupData.Msg, ""));
  7167. }
  7168. else
  7169. {
  7170. List<AirTicketReservationsView> _AirTicketReservations = groupData.Data;
  7171. if (dto.Language == "CN")
  7172. {
  7173. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_CN.docx");
  7174. var builder = new DocumentBuilder(doc);
  7175. int tableIndex = 0;//表格索引
  7176. //得到文档中的第一个表格
  7177. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  7178. foreach (var item in _AirTicketReservations)
  7179. {
  7180. #region 处理固定数据
  7181. string[] FlightsCode = item.FlightsCode.Split('/');
  7182. if (FlightsCode.Length != 0)
  7183. {
  7184. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7185. if (_AirCompany != null)
  7186. {
  7187. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  7188. }
  7189. else
  7190. {
  7191. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7192. }
  7193. }
  7194. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7195. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7196. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7197. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7198. string name = "";
  7199. foreach (string clientName in nameArray)
  7200. {
  7201. if (!name.Contains(clientName))
  7202. {
  7203. name += clientName + ",";
  7204. }
  7205. }
  7206. if (!string.IsNullOrWhiteSpace(name))
  7207. {
  7208. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  7209. }
  7210. else
  7211. {
  7212. table.Range.Bookmarks["ClientName"].Text = "--";
  7213. }
  7214. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7215. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7216. table.Range.Bookmarks["JointTicket"].Text = "--";
  7217. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7218. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7219. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7220. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7221. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7222. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7223. #endregion
  7224. #region 循环数据处理
  7225. var airs = new List<AirInfo>();
  7226. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  7227. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  7228. for (int i = 0; i < FlightsCode.Length; i++)
  7229. {
  7230. var air = new AirInfo();
  7231. string[] tempstr = DayArray[i]
  7232. .Replace("\r\n", string.Empty)
  7233. .Replace("\\r\\n", string.Empty)
  7234. .TrimStart().TrimEnd()
  7235. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  7236. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  7237. string starCity = "";
  7238. if (star_Three != null)
  7239. {
  7240. starCity = star_Three.AirPort;
  7241. }
  7242. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  7243. string EndCity = "";
  7244. if (End_Three != null)
  7245. {
  7246. EndCity = End_Three.AirPort;
  7247. }
  7248. air.Destination = starCity + "/" + EndCity;
  7249. air.Flight = FlightsCode[i];
  7250. air.SeatingClass = item.CTypeName;
  7251. string dateTime = tempstr[2];
  7252. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  7253. air.FlightDate = DateTemp;
  7254. air.DepartureTime = tempstr[5];
  7255. air.LandingTime = tempstr[6];
  7256. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  7257. air.TicketStatus = "--";
  7258. air.Luggage = "--";
  7259. air.DepartureTerminal = "--";
  7260. air.LandingTerminal = "--";
  7261. airs.Add(air);
  7262. }
  7263. int row = 13;
  7264. for (int i = 0; i < airs.Count; i++)
  7265. {
  7266. if (airs.Count > 2)
  7267. {
  7268. for (int j = 0; j < airs.Count - 2; j++)
  7269. {
  7270. var CopyRow = table.Rows[12].Clone(true);
  7271. table.Rows.Add(CopyRow);
  7272. }
  7273. }
  7274. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  7275. int index = 0;
  7276. foreach (PropertyInfo property in properties)
  7277. {
  7278. string value = property.GetValue(airs[i]).ToString();
  7279. Cell ishcel0 = table.Rows[row].Cells[index];
  7280. var p = new Paragraph(doc);
  7281. string s = value;
  7282. p.AppendChild(new Run(doc, s));
  7283. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  7284. ishcel0.AppendChild(p);
  7285. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  7286. index++;
  7287. }
  7288. row++;
  7289. }
  7290. #endregion
  7291. var lastParagraph = new Paragraph(doc);
  7292. //第一个表格末尾加段落
  7293. table.ParentNode.InsertAfter(lastParagraph, table);
  7294. //复制第一个表格
  7295. Table cloneTable = (Table)table.Clone(true);
  7296. //在文档末尾段落后面加入复制的表格
  7297. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  7298. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  7299. {
  7300. int rownewsIndex = 13;
  7301. for (int i = 0; i < 2; i++)
  7302. {
  7303. var CopyRow = table.Rows[12].Clone(true);
  7304. table.Rows.RemoveAt(13);
  7305. table.Rows.Add(CopyRow);
  7306. rownewsIndex++;
  7307. }
  7308. }
  7309. else
  7310. {
  7311. table.Rows.RemoveAt(12);
  7312. }
  7313. cloneTable.Rows.RemoveAt(12);
  7314. }
  7315. if (_AirTicketReservations.Count != 0)
  7316. {
  7317. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  7318. if (FlightsCode.Length != 0)
  7319. {
  7320. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7321. if (_AirCompany != null)
  7322. {
  7323. table.Range.Bookmarks["AirlineCompany"].Text = _AirCompany.CnName;
  7324. }
  7325. else
  7326. {
  7327. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7328. }
  7329. }
  7330. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7331. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7332. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7333. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7334. string name = "";
  7335. foreach (string clientName in nameArray)
  7336. {
  7337. if (!name.Contains(clientName))
  7338. {
  7339. name += clientName + ",";
  7340. }
  7341. }
  7342. if (!string.IsNullOrWhiteSpace(name))
  7343. {
  7344. table.Range.Bookmarks["ClientName"].Text = name.Substring(0, name.Length - 1);
  7345. }
  7346. else
  7347. {
  7348. table.Range.Bookmarks["ClientName"].Text = "--";
  7349. }
  7350. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7351. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7352. table.Range.Bookmarks["JointTicket"].Text = "--";
  7353. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7354. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7355. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7356. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7357. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7358. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7359. }
  7360. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  7361. //保存合并后的文档
  7362. string fileName = "AirItinerary/电子客票中文行程单_CN.docx";
  7363. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  7364. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  7365. return Ok(JsonView(true, "成功!", rst));
  7366. }
  7367. else
  7368. {
  7369. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/电子客票行程单模板_EN.docx");
  7370. var builder = new DocumentBuilder(doc);
  7371. int tableIndex = 0;//表格索引
  7372. //得到文档中的第一个表格
  7373. Table table = (Table)doc.GetChild(NodeType.Table, tableIndex, true);
  7374. var texts = new List<string>();
  7375. foreach (var item in _AirTicketReservations)
  7376. {
  7377. string[] FlightsCode = item.FlightsCode.Split('/');
  7378. if (FlightsCode.Length != 0)
  7379. {
  7380. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7381. if (_AirCompany != null)
  7382. {
  7383. if (!transDic.ContainsKey(_AirCompany.CnName))
  7384. {
  7385. transDic.Add(_AirCompany.CnName, _AirCompany.EnName);
  7386. }
  7387. }
  7388. else
  7389. {
  7390. if (!transDic.ContainsKey("--"))
  7391. {
  7392. transDic.Add("--", "--");
  7393. }
  7394. }
  7395. }
  7396. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7397. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7398. string name = "";
  7399. foreach (string clientName in nameArray)
  7400. {
  7401. name += clientName + ",";
  7402. }
  7403. if (!texts.Contains(name))
  7404. {
  7405. texts.Add(name);
  7406. }
  7407. var airs = new List<AirInfo>();
  7408. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  7409. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  7410. for (int i = 0; i < FlightsCode.Length; i++)
  7411. {
  7412. var air = new AirInfo();
  7413. string[] tempstr = DayArray[i]
  7414. .Replace("\r\n", string.Empty)
  7415. .Replace("\\r\\n", string.Empty)
  7416. .TrimStart().TrimEnd()
  7417. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  7418. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  7419. if (star_Three != null)
  7420. {
  7421. if (!transDic.ContainsKey(star_Three.AirPort))
  7422. {
  7423. transDic.Add(star_Three.AirPort, star_Three.AirPort_En);
  7424. }
  7425. }
  7426. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  7427. if (End_Three != null)
  7428. {
  7429. if (!transDic.ContainsKey(End_Three.AirPort))
  7430. {
  7431. transDic.Add(End_Three.AirPort, End_Three.AirPort_En);
  7432. }
  7433. }
  7434. if (!texts.Contains(item.CTypeName))
  7435. {
  7436. texts.Add(item.CTypeName);
  7437. }
  7438. }
  7439. }
  7440. List<TranslateResult> transData = await _airTicketResRep.ReTransBatch(texts, "en");
  7441. if (transData.Count > 0)
  7442. {
  7443. foreach (TranslateResult item in transData)
  7444. {
  7445. if (!transDic.ContainsKey(item.Query))
  7446. {
  7447. transDic.Add(item.Query, item.Translation);
  7448. }
  7449. }
  7450. }
  7451. foreach (var item in _AirTicketReservations)
  7452. {
  7453. #region 处理固定数据
  7454. string[] FlightsCode = item.FlightsCode.Split('/');
  7455. if (FlightsCode.Length != 0)
  7456. {
  7457. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7458. if (_AirCompany != null)
  7459. {
  7460. string str = "--";
  7461. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  7462. if (!string.IsNullOrEmpty(translateResult))
  7463. {
  7464. str = translateResult;
  7465. str = _airTicketResRep.Processing(str);
  7466. }
  7467. table.Range.Bookmarks["AirlineCompany"].Text = str;
  7468. }
  7469. else
  7470. {
  7471. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7472. }
  7473. }
  7474. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7475. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7476. string[] nameArray = Regex.Split(item.ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7477. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7478. string names = "";
  7479. foreach (string clientName in nameArray)
  7480. {
  7481. names += clientName + ",";
  7482. }
  7483. if (!string.IsNullOrWhiteSpace(names))
  7484. {
  7485. string str = "--";
  7486. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  7487. if (!string.IsNullOrEmpty(translateResult))
  7488. {
  7489. str = translateResult;
  7490. str = _airTicketResRep.Processing(str);
  7491. }
  7492. table.Range.Bookmarks["ClientName"].Text = str;
  7493. }
  7494. else
  7495. {
  7496. table.Range.Bookmarks["ClientName"].Text = "--";
  7497. }
  7498. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7499. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7500. table.Range.Bookmarks["JointTicket"].Text = "--";
  7501. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7502. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7503. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7504. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7505. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7506. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7507. #endregion
  7508. #region 循环数据处理
  7509. var airs = new List<AirInfo>();
  7510. string[] DayArray = Regex.Split(item.FlightsDescription, "\\d+\\.", RegexOptions.IgnoreCase);
  7511. DayArray = DayArray.Where(s => s != " " && s != "" && !string.IsNullOrEmpty(s)).ToArray();
  7512. for (int i = 0; i < FlightsCode.Length; i++)
  7513. {
  7514. var air = new AirInfo();
  7515. string[] tempstr = DayArray[i]
  7516. .Replace("\r\n", string.Empty)
  7517. .Replace("\\r\\n", string.Empty)
  7518. .TrimStart().TrimEnd()
  7519. .Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  7520. Res_ThreeCode star_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(0, 3));
  7521. string starCity = "";
  7522. if (star_Three != null)
  7523. {
  7524. string str2 = "--";
  7525. string translateResult2 = transDic.Where(s => s.Key == star_Three.AirPort).FirstOrDefault().Value;
  7526. if (!string.IsNullOrEmpty(translateResult2))
  7527. {
  7528. str2 = translateResult2;
  7529. str2 = _airTicketResRep.Processing(str2);
  7530. }
  7531. starCity = str2;
  7532. }
  7533. Res_ThreeCode End_Three = _sqlSugar.Queryable<Res_ThreeCode>().First(a => a.Three == tempstr[3].Substring(3, 3));
  7534. string EndCity = "";
  7535. if (End_Three != null)
  7536. {
  7537. string str1 = "--";
  7538. string translateResult1 = transDic.Where(s => s.Key == End_Three.AirPort).FirstOrDefault().Value;
  7539. if (!string.IsNullOrEmpty(translateResult1))
  7540. {
  7541. str1 = translateResult1;
  7542. str1 = _airTicketResRep.Processing(str1);
  7543. }
  7544. EndCity = str1;
  7545. }
  7546. air.Destination = starCity + "/" + EndCity;
  7547. air.Flight = FlightsCode[i];
  7548. string str = "--";
  7549. string translateResult = transDic.Where(s => s.Key == item.CTypeName).FirstOrDefault().Value;
  7550. if (!string.IsNullOrEmpty(translateResult))
  7551. {
  7552. str = translateResult;
  7553. str = _airTicketResRep.Processing(str);
  7554. }
  7555. air.SeatingClass = str;
  7556. string dateTime = tempstr[2];
  7557. string DateTemp = dateTime.Substring(2, 5).ToUpper();
  7558. air.FlightDate = DateTemp;
  7559. air.DepartureTime = tempstr[5];
  7560. air.LandingTime = tempstr[6];
  7561. air.ValidityPeriod = DateTemp + "/" + DateTemp;
  7562. air.TicketStatus = "--";
  7563. air.Luggage = "--";
  7564. air.DepartureTerminal = "--";
  7565. air.LandingTerminal = "--";
  7566. airs.Add(air);
  7567. }
  7568. int row = 13;
  7569. for (int i = 0; i < airs.Count; i++)
  7570. {
  7571. if (airs.Count > 2)
  7572. {
  7573. for (int j = 0; j < airs.Count - 2; j++)
  7574. {
  7575. var CopyRow = table.Rows[12].Clone(true);
  7576. table.Rows.Add(CopyRow);
  7577. }
  7578. }
  7579. PropertyInfo[] properties = airs[i].GetType().GetProperties();
  7580. int index = 0;
  7581. foreach (PropertyInfo property in properties)
  7582. {
  7583. string value = property.GetValue(airs[i]).ToString();
  7584. Cell ishcel0 = table.Rows[row].Cells[index];
  7585. var p = new Paragraph(doc);
  7586. string s = value;
  7587. p.AppendChild(new Run(doc, s));
  7588. p.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
  7589. ishcel0.AppendChild(p);
  7590. ishcel0.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;//垂直居中对齐
  7591. //ishcel0.CellFormat.VerticalAlignment=
  7592. index++;
  7593. }
  7594. row++;
  7595. }
  7596. #endregion
  7597. var lastParagraph = new Paragraph(doc);
  7598. //第一个表格末尾加段落
  7599. table.ParentNode.InsertAfter(lastParagraph, table);
  7600. //复制第一个表格
  7601. Table cloneTable = (Table)table.Clone(true);
  7602. //在文档末尾段落后面加入复制的表格
  7603. table.ParentNode.InsertAfter(cloneTable, lastParagraph);
  7604. if (item != _AirTicketReservations[_AirTicketReservations.Count - 1])
  7605. {
  7606. int rownewsIndex = 13;
  7607. for (int i = 0; i < 2; i++)
  7608. {
  7609. var CopyRow = table.Rows[12].Clone(true);
  7610. table.Rows.RemoveAt(13);
  7611. table.Rows.Add(CopyRow);
  7612. rownewsIndex++;
  7613. }
  7614. }
  7615. else
  7616. {
  7617. table.Rows.RemoveAt(12);
  7618. }
  7619. cloneTable.Rows.RemoveAt(12);
  7620. }
  7621. if (_AirTicketReservations.Count != 0)
  7622. {
  7623. string[] FlightsCode = _AirTicketReservations[0].FlightsCode.Split('/');
  7624. if (FlightsCode.Length != 0)
  7625. {
  7626. Res_AirCompany _AirCompany = _sqlSugar.Queryable<Res_AirCompany>().First(a => a.ShortCode == FlightsCode[0].Substring(0, 2));
  7627. if (_AirCompany != null)
  7628. {
  7629. string str = "--";
  7630. string translateResult = transDic.Where(s => s.Key == _AirCompany.CnName).FirstOrDefault().Value;
  7631. if (!string.IsNullOrEmpty(translateResult))
  7632. {
  7633. str = translateResult;
  7634. str = _airTicketResRep.Processing(str);
  7635. }
  7636. table.Range.Bookmarks["AirlineCompany"].Text = str;
  7637. }
  7638. else
  7639. {
  7640. table.Range.Bookmarks["AirlineCompany"].Text = "--";
  7641. }
  7642. }
  7643. table.Range.Bookmarks["AirlineRecordCode"].Text = "--";
  7644. table.Range.Bookmarks["ReservationRecordCode"].Text = "--";
  7645. string[] nameArray = Regex.Split(_AirTicketReservations[0].ClientName, "\\d+\\.", RegexOptions.IgnoreCase);
  7646. nameArray = nameArray.Where(str => str != "" && str != " " && !string.IsNullOrEmpty(str)).ToArray();
  7647. string names = "";
  7648. foreach (string clientName in nameArray)
  7649. {
  7650. names += clientName + ",";
  7651. }
  7652. if (!string.IsNullOrWhiteSpace(names))
  7653. {
  7654. string str = "--";
  7655. string translateResult = transDic.Where(s => s.Key == names).FirstOrDefault().Value;
  7656. if (!string.IsNullOrEmpty(translateResult))
  7657. {
  7658. str = translateResult;
  7659. str = _airTicketResRep.Processing(str);
  7660. }
  7661. table.Range.Bookmarks["ClientName"].Text = str;
  7662. }
  7663. else
  7664. {
  7665. table.Range.Bookmarks["ClientName"].Text = "--";
  7666. }
  7667. table.Range.Bookmarks["TicketNumber"].Text = "--";
  7668. table.Range.Bookmarks["IdentificationCode"].Text = "--";
  7669. table.Range.Bookmarks["JointTicket"].Text = "--";
  7670. table.Range.Bookmarks["TimeIssue"].Text = "--";
  7671. table.Range.Bookmarks["DrawingAgent"].Text = "--";
  7672. table.Range.Bookmarks["NavigationCode"].Text = "--";
  7673. table.Range.Bookmarks["AgentsAddress"].Text = "--";
  7674. table.Range.Bookmarks["AgentPhone"].Text = "--";
  7675. table.Range.Bookmarks["AgentFacsimile"].Text = "--";
  7676. }
  7677. doc.MailMerge.Execute(new[] { "PageCount" }, new object[] { doc.PageCount });
  7678. //保存合并后的文档
  7679. string fileName = "AirItinerary/电子客票英文行程单_EN.docx";
  7680. string rst = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + fileName;
  7681. doc.Save(AppSettingsHelper.Get("WordBasePath") + fileName);
  7682. return Ok(JsonView(true, "成功!", rst));
  7683. }
  7684. }
  7685. }
  7686. catch (Exception ex)
  7687. {
  7688. return Ok(JsonView(StatusCodes.Status400BadRequest, "程序错误!", ""));
  7689. throw;
  7690. }
  7691. }
  7692. #endregion
  7693. #region 团组增减款项 --> 其他款项
  7694. /// <summary>
  7695. /// 团组增减款项下拉框绑定
  7696. /// </summary>
  7697. /// <param name="dto"></param>
  7698. /// <returns></returns>
  7699. [HttpPost]
  7700. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7701. public async Task<IActionResult> DecreasePaymentsSelect(DecreasePaymentsDto dto)
  7702. {
  7703. #region 参数验证
  7704. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7705. if (dto.CTId < 1) return Ok(JsonView(false, "请传入有效的CTId参数!"));
  7706. #endregion
  7707. return Ok(await _decreasePaymentsRep.DecreasePaymentsSelect(dto));
  7708. }
  7709. /// <summary>
  7710. /// 根据团组Id查询团组增减款项
  7711. /// </summary>
  7712. /// <param name="dto"></param>
  7713. /// <returns></returns>
  7714. [HttpPost]
  7715. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7716. public async Task<IActionResult> DecreasePaymentsList(DecreasePaymentsListDto dto)
  7717. {
  7718. #region 参数验证
  7719. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  7720. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  7721. #endregion
  7722. return Ok(await _decreasePaymentsRep.DecreasePaymentsList(dto));
  7723. }
  7724. /// <summary>
  7725. /// 团组增减款项操作(Status:1.新增,2.修改)
  7726. /// </summary>
  7727. /// <param name="dto"></param>
  7728. /// <returns></returns>
  7729. [HttpPost]
  7730. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7731. public async Task<IActionResult> OpDecreasePayments(DecreasePaymentsOpDto dto)
  7732. {
  7733. JsonView groupData = await _decreasePaymentsRep.OpDecreasePayments(dto);
  7734. if (groupData.Code != 200)
  7735. {
  7736. return Ok(JsonView(false, groupData.Msg));
  7737. }
  7738. #region 应用推送
  7739. //int otherId = (int)groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  7740. //int ccpId = (int)groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  7741. //int sign = (int)groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  7742. int otherId = Convert.ToInt32(groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null) ?? 0);
  7743. int ccpId = Convert.ToInt32(groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null) ?? 0);
  7744. int sign = Convert.ToInt32(groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null) ?? 0);
  7745. bool recheck = Convert.ToBoolean(groupData.Data.GetType().GetProperty("recheck").GetValue(groupData.Data, null) ?? "True");
  7746. if (recheck)
  7747. {
  7748. //自动审核
  7749. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(3, dto.DiId, otherId);
  7750. }
  7751. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  7752. //2024-10-21 新增LZ UID
  7753. var userIds = new List<int>() { 21 };
  7754. string title = $"系统通知";
  7755. string content = "";
  7756. var diId = dto.DiId;
  7757. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  7758. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  7759. if (dto.Status == 1) content = $"[新增-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7760. else if (dto.Status == 2) content = $"[更新-其他款项({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  7761. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  7762. //await APNsTools.iOS_PushNotifications1("051", $"其他款项费用审核", "", content);
  7763. #endregion
  7764. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  7765. }
  7766. /// <summary>
  7767. /// 团组增减款项操作 删除
  7768. /// </summary>
  7769. /// <param name="dto"></param>
  7770. /// <returns></returns>
  7771. [HttpPost]
  7772. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7773. public async Task<IActionResult> DelDecreasePayments(DelBaseDto dto)
  7774. {
  7775. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  7776. if (dto.DeleteUserId < 1) return Ok(JsonView(false, "请传入有效的DeleteUserId参数!"));
  7777. var res = await _decreasePaymentsRep._Del(dto.Id, dto.DeleteUserId);
  7778. if (res.Code == 0) return Ok(JsonView(true, "删除成功!"));
  7779. return Ok(JsonView(false, res?.Msg ?? "删除失败!"));
  7780. }
  7781. /// <summary>
  7782. /// 根据团组增减款项Id查询
  7783. /// </summary>
  7784. /// <param name="dto"></param>
  7785. /// <returns></returns>
  7786. [HttpPost]
  7787. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7788. public async Task<IActionResult> QueryDecreasePaymentsById(DecreasePaymentsByIdDto dto)
  7789. {
  7790. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的数据Id!"));
  7791. return Ok(await _decreasePaymentsRep.QueryDecreasePaymentsById(dto));
  7792. }
  7793. /// <summary>
  7794. /// 查询供应商名称
  7795. /// </summary>
  7796. /// <param name="dto"></param>
  7797. /// <returns></returns>
  7798. [HttpPost]
  7799. public IActionResult QueryAssociateSupplier(AssociateSupplierDto dto)
  7800. {
  7801. var dbResult = _sqlSugar.Queryable<Grp_DecreasePayments>()
  7802. .Where(x => x.SupplierName.Contains(dto.param) && x.IsDel == 0).ToList()
  7803. ?? new List<Grp_DecreasePayments>();
  7804. dbResult = dbResult.Distinct(new
  7805. ProductComparer()).ToList();
  7806. var jw = JsonView(true, "success", dbResult.OrderByDescending(x => x.Id).Select(x => new
  7807. {
  7808. x.Id,
  7809. x.SupplierAddress,
  7810. x.SupplierArea,
  7811. x.SupplierContact,
  7812. x.SupplierContactNumber,
  7813. x.SupplierEmail,
  7814. x.SupplierName,
  7815. x.SupplierSocialAccount,
  7816. x.SupplierTypeId,
  7817. }).ToList());
  7818. return Ok(jw);
  7819. }
  7820. /// <summary>
  7821. /// 团组增减款项 OTA匹配
  7822. /// </summary>
  7823. /// <param name="file"></param>
  7824. /// <returns></returns>
  7825. [HttpPost]
  7826. public async Task<IActionResult> DecreasePaymentsOTAMate(IFormFile file)
  7827. {
  7828. if (file.Length < 1) return Ok(JsonView(false, "请上传文件!"));
  7829. string fileName = file.FileName;
  7830. if (!fileName.EndsWith(".xlsx") && !fileName.EndsWith(".xls"))
  7831. {
  7832. return Ok(JsonView(false, "请上传Excel文件!"));
  7833. }
  7834. //D:\FTP\File\OA2023\Office\GrpFile\团组增减款项相关文件\团组其他款项(OTA)
  7835. var path = @$"{AppSettingsHelper.Get("GrpFileBasePath")}团组增减款项相关文件/团组其他款项(OTA)";
  7836. if (!Directory.Exists(path))
  7837. {
  7838. Directory.CreateDirectory(path);
  7839. }
  7840. var filePath = @$"{path}/{fileName}";
  7841. //保存文件
  7842. using (FileStream fs = System.IO.File.Create(filePath))
  7843. {
  7844. file.CopyTo(fs);
  7845. fs.Flush();
  7846. }
  7847. if (!System.IO.File.Exists(filePath)) return Ok(JsonView(false, "文件不存在!"));
  7848. //读取ExcelFile
  7849. DataTable dt = ConvertExcelToDataTable(filePath);
  7850. if (dt == null) return Ok(JsonView(false, $"您上传的Excel工作表没有内容,请检查!!!"));
  7851. dt.TableName = "TB";
  7852. //修改table列名
  7853. dt.Columns[0].ColumnName = "OrderNo"; // 订单号
  7854. dt.Columns[1].ColumnName = "OTAOrderNo"; // OTA订单号
  7855. dt.Columns[2].ColumnName = "PackageName"; // 套餐名
  7856. dt.Columns[3].ColumnName = "IsPay"; // 是否支付
  7857. dt.Columns[4].ColumnName = "IsShipments"; // 是否发货
  7858. dt.Columns[5].ColumnName = "IsSendBack"; // 是否寄回
  7859. dt.Columns[6].ColumnName = "OpUser"; // 使用人信息
  7860. dt.Columns[7].ColumnName = "OrderTime"; // 下单时间
  7861. dt.Columns[8].ColumnName = "UseTime"; // 使用时间
  7862. dt.Columns[9].ColumnName = "Quantity"; // 台数
  7863. dt.Columns[10].ColumnName = "Days"; // 租赁天数
  7864. dt.Columns[11].ColumnName = "QuantityShipped";// 发货数量
  7865. dt.Columns[12].ColumnName = "TotalPrice"; // 总金额
  7866. dt.Columns[13].ColumnName = "GroupName"; // 团组名称
  7867. dt.Columns[14].ColumnName = "OATotalPrice"; // OA金额
  7868. var otaOrderNos = new List<string>();
  7869. foreach (DataRow item in dt.Rows)
  7870. {
  7871. otaOrderNos.Add(item["OTAOrderNo"].ToString());
  7872. }
  7873. var oaDatas = await _sqlSugar.Queryable<Grp_DecreasePayments>()
  7874. .LeftJoin<Grp_DelegationInfo>((dp, di) => dp.DiId == di.Id)
  7875. .Where((dp, di) => dp.IsDel == 0 && dp.PriceName.Contains("wifi") || otaOrderNos.Contains(dp.OTAOrderNo))
  7876. .Select((dp, di) => new
  7877. {
  7878. dp.PriceName,
  7879. dp.OTAOrderNo,
  7880. dp.FeeTotal,
  7881. di.TeamName,
  7882. })
  7883. .ToListAsync();
  7884. foreach (DataRow item in dt.Rows)
  7885. {
  7886. var otaOrderNo = item["OTAOrderNo"].ToString();
  7887. var oaData = oaDatas.Find(x => !string.IsNullOrEmpty(x.OTAOrderNo) && x.OTAOrderNo.Contains(otaOrderNo));
  7888. if (oaData == null) continue;
  7889. item["GroupName"] = oaData.TeamName;
  7890. item["OATotalPrice"] = oaData.FeeTotal.ToString("#0.00");
  7891. }
  7892. string fileName1 = $"OTA_WIFI费用{DateTime.Now:yyyyMMddHHmmss}.xls";
  7893. var pairs = new Dictionary<string, object>();
  7894. var datas = new List<DataTable>
  7895. {
  7896. dt
  7897. };
  7898. url = AsposeHelper.ExpertExcelToModel("WIFI费用清单-模板.xlsx", $"GrpFile/团组增减款项相关文件/团组其他款项(OTA)", fileName1, pairs, datas);
  7899. return Ok(JsonView(true, "操作成功", new { url }));
  7900. }
  7901. #region
  7902. private static DataTable ConvertExcelToDataTable(string excelFilePath)
  7903. {
  7904. // 创建Workbook对象
  7905. var workbook = new Workbook(excelFilePath);
  7906. // 获取第一个工作表
  7907. var worksheet = workbook.Worksheets[0];
  7908. // 将工作表转换为DataTable
  7909. DataTable dataTable = worksheet.Cells.ExportDataTable(1, 0, worksheet.Cells.MaxDataRow + 1, worksheet.Cells.MaxDataColumn + 1);
  7910. return dataTable;
  7911. }
  7912. #endregion
  7913. /// <summary>
  7914. /// 世运会数据
  7915. /// </summary>
  7916. /// <returns></returns>
  7917. [HttpGet]
  7918. public IActionResult WorldGamesData()
  7919. {
  7920. var setData = _sqlSugar.Queryable<Grp_GamesBudgetMaster>().Where(x => x.IsDel == 0).ToList();
  7921. var groupMenu = setData.GroupBy(x => x.T0);
  7922. var resultArr = new List<DecreasePaymentsWorldGamesDataView>();
  7923. foreach (var item in groupMenu)
  7924. {
  7925. resultArr.Add(new DecreasePaymentsWorldGamesDataView
  7926. {
  7927. Data = new SetDataView
  7928. {
  7929. Name = item.Key
  7930. },
  7931. Child = item.Select(x => x.CalculationContent).ToList() ?? new List<string>()
  7932. });
  7933. }
  7934. return Ok(JsonView(true, "success", resultArr));
  7935. }
  7936. #endregion
  7937. #region 文件上传、删除
  7938. /// <summary>
  7939. /// region 文件上传 可以带参数
  7940. /// </summary>
  7941. /// <param name="file"></param>
  7942. /// <returns></returns>
  7943. [HttpPost]
  7944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  7945. public async Task<IActionResult> UploadProject(IFormFile file)
  7946. {
  7947. //var TypeName = Request.Headers["TypeName"].ToString();
  7948. //if (file == null) return Ok(JsonView(false, "文件不存在!"));
  7949. //var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7950. ////文件名称
  7951. //string projectFileName = file.FileName;
  7952. ////上传的文件的路径
  7953. //string filePath = $"{fileDir}/{projectFileName}";
  7954. //if (TypeName == "A")//A代表团组增减款项
  7955. //{
  7956. // filePath = fileDir + $@"\团组增减款项相关文件";
  7957. // if (!Directory.Exists(filePath))
  7958. // {
  7959. // Directory.CreateDirectory(filePath);
  7960. // }
  7961. // //上传的文件的路径
  7962. // filePath += $@"\{projectFileName}";
  7963. //}
  7964. //else if (TypeName == "B")//B代表商邀相关文件
  7965. //{
  7966. // //上传的文件的路径
  7967. // filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  7968. // if (!Directory.Exists(filePath))
  7969. // {
  7970. // Directory.CreateDirectory(filePath);
  7971. // }
  7972. // //上传的文件的路径
  7973. // filePath = $@"\{projectFileName}";
  7974. //}
  7975. //try
  7976. //{
  7977. // using (FileStream fs = System.IO.File.Create(filePath))
  7978. // {
  7979. // file.CopyTo(fs);
  7980. // fs.Flush();
  7981. // }
  7982. //}
  7983. //catch (Exception ex)
  7984. //{
  7985. // return Ok(JsonView(false, $"文件上传失败! Error:{ex.Message}"));
  7986. //}
  7987. //return Ok(JsonView(true, "上传成功!", projectFileName));
  7988. try
  7989. {
  7990. var TypeName = Request.Headers["TypeName"].ToString();
  7991. if (file != null)
  7992. {
  7993. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  7994. //文件名称
  7995. string projectFileName = file.FileName;
  7996. //上传的文件的路径
  7997. string filePath = $"{fileDir}/{projectFileName}";
  7998. if (TypeName == "A")//A代表团组增减款项
  7999. {
  8000. if (!Directory.Exists(fileDir))
  8001. {
  8002. Directory.CreateDirectory(fileDir);
  8003. }
  8004. //上传的文件的路径
  8005. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  8006. }
  8007. else if (TypeName == "B")//B代表商邀相关文件
  8008. {
  8009. if (!Directory.Exists(fileDir))
  8010. {
  8011. Directory.CreateDirectory(fileDir);
  8012. }
  8013. //上传的文件的路径
  8014. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  8015. }
  8016. using (FileStream fs = System.IO.File.Create(filePath))
  8017. {
  8018. file.CopyTo(fs);
  8019. fs.Flush();
  8020. }
  8021. return Ok(JsonView(true, "上传成功!", projectFileName));
  8022. }
  8023. else
  8024. {
  8025. return Ok(JsonView(false, "上传失败!"));
  8026. }
  8027. }
  8028. catch (Exception ex)
  8029. {
  8030. return Ok(JsonView(false, ex.Message));
  8031. }
  8032. }
  8033. /// <summary>
  8034. /// 删除指定文件
  8035. /// </summary>
  8036. /// <param name="dto"></param>
  8037. /// <returns></returns>
  8038. [HttpPost]
  8039. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8040. public async Task<IActionResult> DelFile(DelFileDto dto)
  8041. {
  8042. try
  8043. {
  8044. var TypeName = Request.Headers["TypeName"].ToString();
  8045. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  8046. string filePath = "";
  8047. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  8048. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  8049. int id = 0;
  8050. if (TypeName == "A")
  8051. {
  8052. filePath = fileDir + "/团组增减款项相关文件/" + dto.fileName;
  8053. // 删除该文件
  8054. System.IO.File.Delete(filePath);
  8055. id = await _sqlSugar.Updateable<Grp_DecreasePayments>()
  8056. .Where(a => a.Id == dto.Id)
  8057. .SetColumns(a => new Grp_DecreasePayments { FilePath = "" })
  8058. .ExecuteCommandAsync();
  8059. }
  8060. else if (TypeName == "B")
  8061. {
  8062. filePath = fileDir + "/商邀相关文件/" + dto.fileName;
  8063. // 删除该文件
  8064. System.IO.File.Delete(filePath);
  8065. var info = await _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(x => x.Id == dto.Id && x.IsDel == 0).FirstAsync();
  8066. if (info != null)
  8067. {
  8068. string[] files = Array.Empty<string>();
  8069. if (!string.IsNullOrEmpty(info.Attachment))
  8070. {
  8071. try
  8072. {
  8073. files = JsonConvert.DeserializeObject<string[]>(info.Attachment);
  8074. }
  8075. catch (Exception)
  8076. {
  8077. files = new List<string>() { info.Attachment }.ToArray();
  8078. }
  8079. }
  8080. if (files.Length > 0)
  8081. {
  8082. var files1 = files.Where(x => !x.Equals(dto.fileName)).ToArray();
  8083. string filePath2 = string.Empty;
  8084. if (files1.Length > 0)
  8085. {
  8086. filePath2 = JsonConvert.SerializeObject(files1);
  8087. }
  8088. id = await _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  8089. .Where(a => a.Id == dto.Id)
  8090. .SetColumns(a => new Grp_InvitationOfficialActivities { Attachment = filePath2 })
  8091. .ExecuteCommandAsync();
  8092. }
  8093. }
  8094. }
  8095. if (id != 0)
  8096. {
  8097. return Ok(JsonView(true, "成功!"));
  8098. }
  8099. else
  8100. {
  8101. return Ok(JsonView(false, "失败!"));
  8102. }
  8103. }
  8104. catch (Exception ex)
  8105. {
  8106. return Ok(JsonView(false, "程序错误!"));
  8107. throw;
  8108. }
  8109. }
  8110. /// <summary>
  8111. /// 文件上传多个文件 可以带参数
  8112. /// </summary>
  8113. /// <param name="files"></param>
  8114. /// <returns></returns>
  8115. [HttpPost]
  8116. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8117. public async Task<IActionResult> UploadProjects(IFormFile[] files)
  8118. {
  8119. try
  8120. {
  8121. var TypeName = Request.Headers["TypeName"].ToString();
  8122. if (string.IsNullOrEmpty(TypeName)) return Ok(JsonView(false, "请选择选组对应模块!"));
  8123. if (files.Length < 1) return Ok(JsonView(false, "请选择文件!"));
  8124. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  8125. var filePahts = new List<string>();
  8126. foreach (var file in files)
  8127. {
  8128. //文件名称
  8129. string projectFileName = file.FileName;
  8130. //上传的文件的路径
  8131. string filePath = $"{fileDir}/{projectFileName}";
  8132. if (TypeName == "A")//A代表团组增减款项
  8133. {
  8134. if (!Directory.Exists(fileDir))
  8135. {
  8136. Directory.CreateDirectory(fileDir);
  8137. }
  8138. //上传的文件的路径
  8139. filePath = fileDir + $@"\团组增减款项相关文件\{projectFileName}";
  8140. }
  8141. else if (TypeName == "B")//B代表商邀相关文件
  8142. {
  8143. if (!Directory.Exists(fileDir))
  8144. {
  8145. Directory.CreateDirectory(fileDir);
  8146. }
  8147. //上传的文件的路径
  8148. filePath = fileDir + $@"\商邀相关文件\{projectFileName}";
  8149. }
  8150. using (FileStream fs = System.IO.File.Create(filePath))
  8151. {
  8152. file.CopyTo(fs);
  8153. fs.Flush();
  8154. }
  8155. filePahts.Add(projectFileName);
  8156. }
  8157. return Ok(JsonView(true, "上传成功!", filePahts));
  8158. }
  8159. catch (Exception ex)
  8160. {
  8161. return Ok(JsonView(false, ex.Message));
  8162. }
  8163. }
  8164. #endregion
  8165. #region 商邀费用录入
  8166. /// <summary>
  8167. /// 根据团组Id查询商邀费用列表
  8168. /// </summary>
  8169. /// <param name="dto"></param>
  8170. /// <returns></returns>
  8171. [HttpPost]
  8172. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8173. public async Task<IActionResult> InvitationOfficialActivitiesList(InvitationOfficialActivitiesListDto dto)
  8174. {
  8175. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesList(dto);
  8176. if (groupData.Code != 0)
  8177. {
  8178. return Ok(JsonView(false, groupData.Msg));
  8179. }
  8180. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8181. }
  8182. /// <summary>
  8183. /// 商邀费用列表
  8184. /// 下载文件
  8185. /// </summary>
  8186. /// <param name="id"></param>
  8187. /// <returns></returns>
  8188. [HttpGet("{id}")]
  8189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8190. public async Task<IActionResult> InvitationOfficialActivitiesListDownFile(int id)
  8191. {
  8192. if (id < 1) return Ok(JsonView(false, "请传入有效的Id!"));
  8193. var info = await _InvitationOfficialActivitiesRep.Query(x => x.Id == id).FirstAsync();
  8194. if (info == null) return Ok(JsonView(false, "数据不存在!"));
  8195. if (string.IsNullOrEmpty(info.Attachment)) return Ok(JsonView(false, "文件不存在!"));
  8196. var filePaths = new List<string>();
  8197. var filePathBase = @$"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/";
  8198. try
  8199. {
  8200. filePaths = JsonConvert.DeserializeObject<List<string>>(info.Attachment);
  8201. }
  8202. catch (Exception ex)
  8203. {
  8204. filePaths.Add(info.Attachment);
  8205. }
  8206. if (filePaths != null && filePaths.Count < 1) return Ok(JsonView(false, "文件不存在!"));
  8207. for (int i = 0; i < filePaths.Count; i++)
  8208. {
  8209. filePaths[i] = $"{filePathBase}{filePaths[i]}";
  8210. }
  8211. var zipFilePathGuid = $"{Guid.NewGuid()}.zip";
  8212. var zipFilePath = $"{AppSettingsHelper.Get("GrpFileBasePath")}/商邀相关文件/{zipFilePathGuid}";
  8213. using (var zipFileStream = new FileStream(zipFilePath, FileMode.Create))
  8214. {
  8215. using (var zipArchive = new ZipArchive(zipFileStream, ZipArchiveMode.Create))
  8216. {
  8217. foreach (string filePath in filePaths)
  8218. {
  8219. if (System.IO.File.Exists(filePath))
  8220. {
  8221. // 获取文件名
  8222. string fileName = Path.GetFileName(filePath);
  8223. // 将文件添加到ZIP归档中
  8224. zipArchive.CreateEntryFromFile(filePath, fileName);
  8225. }
  8226. }
  8227. }
  8228. }
  8229. return Ok(JsonView(new { url = @$"{AppSettingsHelper.Get("OfficeBaseUrl")}{AppSettingsHelper.Get("GrpFileFtpPath")}/商邀相关文件/{zipFilePathGuid}" }));
  8230. }
  8231. /// <summary>
  8232. /// 商邀费用 Info Page 基础数据源
  8233. /// </summary>
  8234. /// <returns></returns>
  8235. [HttpPost]
  8236. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8237. public async Task<IActionResult> InvitationOfficialActivityInitBasicData()
  8238. {
  8239. try
  8240. {
  8241. Result groupData = await _InvitationOfficialActivitiesRep.InitBasicData();
  8242. if (groupData.Code != 0)
  8243. {
  8244. return Ok(JsonView(false, groupData.Msg));
  8245. }
  8246. return Ok(JsonView(true, "操作成功", groupData.Data));
  8247. }
  8248. catch (Exception ex)
  8249. {
  8250. return Ok(JsonView(false, ex.Message));
  8251. throw;
  8252. }
  8253. }
  8254. /// <summary>
  8255. /// 根据商邀费用ID查询C表和商邀费用数据
  8256. /// </summary>
  8257. /// <param name="dto"></param>
  8258. /// <returns></returns>
  8259. [HttpPost]
  8260. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8261. public async Task<IActionResult> InvitationOfficialActivitiesById(InvitationOfficialActivitiesByIdDto dto)
  8262. {
  8263. try
  8264. {
  8265. Result groupData = await _InvitationOfficialActivitiesRep.InvitationOfficialActivitiesById(dto);
  8266. if (groupData.Code != 0)
  8267. {
  8268. return Ok(JsonView(false, groupData.Msg));
  8269. }
  8270. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8271. }
  8272. catch (Exception ex)
  8273. {
  8274. return Ok(JsonView(false, ex.Message));
  8275. throw;
  8276. }
  8277. }
  8278. /// <summary>
  8279. /// 商邀费用录入操作(Status:1.新增,2.修改)
  8280. /// </summary>
  8281. /// <param name="dto"></param>
  8282. /// <returns></returns>
  8283. [HttpPost]
  8284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8285. public async Task<IActionResult> OpInvitationOfficialActivities(OpInvitationOfficialActivitiesDto dto)
  8286. {
  8287. Result groupData = await _InvitationOfficialActivitiesRep.OpInvitationOfficialActivities(dto, _setDataRep.PostCurrencyByDiid);
  8288. if (groupData.Code != 0)
  8289. {
  8290. return Ok(JsonView(false, groupData.Msg));
  8291. }
  8292. #region 应用推送
  8293. try
  8294. {
  8295. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  8296. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  8297. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  8298. //2024-10-21 新增LZ UID
  8299. var userIds = new List<int>() { 21 };
  8300. string title = $"系统通知";
  8301. string content = "";
  8302. var diId = dto.DiId;
  8303. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  8304. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  8305. if (dto.Status == 1) content = $"[新增-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8306. else if (dto.Status == 2) content = $"[更新-商邀费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  8307. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  8308. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "81" };
  8309. await APNsTools.iOS_PushNotifications1("051", $"商邀费用审核", "", content, true, "ExpenseAuditWebView", h5);
  8310. }
  8311. catch (Exception ex)
  8312. {
  8313. }
  8314. #endregion
  8315. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  8316. }
  8317. /// <summary>
  8318. /// 商邀删除
  8319. /// </summary>
  8320. /// <param name="dto"></param>
  8321. /// <returns></returns>
  8322. [HttpPost]
  8323. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  8324. public async Task<IActionResult> DelInvitationOfficialActivities(DelBaseDto dto)
  8325. {
  8326. try
  8327. {
  8328. _sqlSugar.BeginTran();
  8329. var res1 = _sqlSugar.Updateable<Grp_InvitationOfficialActivities>()
  8330. .SetColumns(it => new Grp_InvitationOfficialActivities()
  8331. {
  8332. IsDel = 1,
  8333. DeleteUserId = dto.DeleteUserId,
  8334. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8335. })
  8336. .Where(it => it.Id == dto.Id)
  8337. .ExecuteCommand();
  8338. if (res1 > 0)
  8339. {
  8340. int _diId = 0;
  8341. var _ioaInfo = _sqlSugar.Queryable<Grp_InvitationOfficialActivities>().Where(it => it.Id == dto.Id).First();
  8342. if (_ioaInfo != null)
  8343. {
  8344. _diId = _ioaInfo.DiId;
  8345. }
  8346. var res2 = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  8347. .SetColumns(a => new Grp_CreditCardPayment()
  8348. {
  8349. IsDel = 1,
  8350. DeleteUserId = dto.DeleteUserId,
  8351. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  8352. })
  8353. .Where(a => a.CId == dto.Id && a.DIId == _diId && a.CTable == 81)
  8354. .ExecuteCommand();
  8355. if (res2 > 0)
  8356. {
  8357. _sqlSugar.CommitTran();
  8358. return Ok(JsonView(true, "删除成功!"));
  8359. }
  8360. }
  8361. _sqlSugar.RollbackTran();
  8362. return Ok(JsonView(false, "删除失败"));
  8363. }
  8364. catch (Exception ex)
  8365. {
  8366. _sqlSugar.RollbackTran();
  8367. return Ok(JsonView(false, ex.Message));
  8368. }
  8369. }
  8370. #endregion
  8371. #region 票据上传
  8372. /// <summary>
  8373. /// 团组模块文件上传
  8374. /// </summary>
  8375. /// <param name="dto"></param>
  8376. /// <returns></returns>
  8377. [HttpPost]
  8378. public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
  8379. {
  8380. var jw = JsonView(false);
  8381. long M = 1024 * 1024;
  8382. if (dto.Files == null || dto.Files.Count == 0)
  8383. {
  8384. jw.Msg = "无文件信息!";
  8385. return Ok(jw);
  8386. }
  8387. if (dto.Files.Sum(x => x.Length) > 20 * M)
  8388. {
  8389. jw.Msg = "文件大小超过20M!";
  8390. return Ok(jw);
  8391. }
  8392. //var nameSp = dto.File.FileName.Split(".");
  8393. //if (nameSp.Length < 2)
  8394. //{
  8395. // jw.Msg = "拓展名称有误!";
  8396. // return Ok(jw);
  8397. //}
  8398. //var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
  8399. //if (!existsName.Contains(nameSp[1].ToUpper()))
  8400. //{
  8401. // jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
  8402. // return Ok(jw);
  8403. //}
  8404. var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
  8405. if (Ctable == null)
  8406. {
  8407. jw.Msg = "Ctable指向有误!";
  8408. return Ok(jw);
  8409. }
  8410. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  8411. if (groupInfo == null)
  8412. {
  8413. jw.Msg = "团组信息不存在!";
  8414. return Ok(jw);
  8415. }
  8416. Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
  8417. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8418. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  8419. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8420. var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
  8421. var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
  8422. try
  8423. {
  8424. if (!Directory.Exists(fileBase))
  8425. {
  8426. Directory.CreateDirectory(fileBase);
  8427. }
  8428. var saveArr = new List<Grp_GroupModelFile>();
  8429. foreach (var fileStream in dto.Files)
  8430. {
  8431. var fileName = fileStream.FileName;
  8432. string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
  8433. string extension = Path.GetExtension(fileName);
  8434. int counter = 0;
  8435. //文件重命名验证
  8436. string newFilePath;
  8437. string currFileName;
  8438. do
  8439. {
  8440. string newFileName;
  8441. if (counter == 0) newFileName = $"{fileNameWithoutExtension}{extension}";
  8442. else newFileName = $"{fileNameWithoutExtension} ({counter}){extension}";
  8443. currFileName = newFileName;
  8444. newFilePath = Path.Combine(fileBase, newFileName);
  8445. counter++;
  8446. } while (System.IO.File.Exists(newFilePath));
  8447. var saveFilePath = fileBase + "\\" + currFileName;
  8448. var file = new Grp_GroupModelFile()
  8449. {
  8450. Cid = dto.Cid,
  8451. CreateTime = DateTime.Now,
  8452. CreateUserId = dto.Userid,
  8453. Ctable = dto.Ctable,
  8454. Diid = dto.Diid,
  8455. IsDel = 0,
  8456. FilePath = saveFilePath,
  8457. FileName = currFileName
  8458. };
  8459. using (FileStream fs = System.IO.File.Create(saveFilePath))
  8460. {
  8461. fileStream.CopyTo(fs);
  8462. fs.Flush();
  8463. }
  8464. saveArr.Add(file);
  8465. }
  8466. var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(saveArr).ExecuteCommand();
  8467. //url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
  8468. jw = JsonView(true, "保存成功!", new
  8469. {
  8470. count = addResult,
  8471. filesName = saveArr.Select(x => x.FileName)
  8472. });
  8473. }
  8474. catch (Exception ex)
  8475. {
  8476. jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
  8477. {
  8478. count = 0,
  8479. filesName = Array.Empty<string>(),
  8480. });
  8481. }
  8482. return Ok(jw);
  8483. }
  8484. /// <summary>
  8485. /// 查询各模块已保存文件
  8486. /// </summary>
  8487. /// <param name="dto"></param>
  8488. /// <returns></returns>
  8489. [HttpPost]
  8490. public IActionResult QueryGroupModelFile(QueryGroupModelFileDto dto)
  8491. {
  8492. var expression = Expressionable.Create<Grp_GroupModelFile>()
  8493. .AndIF(dto.UserId != -1, x => x.CreateUserId == dto.UserId);
  8494. var visaIds = _sqlSugar.Queryable<Sys_Users>().Where(x => x.JobPostId == 26).Select(x => x.Id).ToList();
  8495. if (visaIds.Contains(dto.UserId) && dto.Ctable == 80)
  8496. {
  8497. expression = Expressionable.Create<Grp_GroupModelFile>()
  8498. .And(x => visaIds.Contains(x.CreateUserId));
  8499. }
  8500. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>()
  8501. .Where(x => x.IsDel == 0 && x.Cid == dto.Cid && x.Ctable == dto.Ctable && x.Diid == dto.Diid)
  8502. .Where(expression.ToExpression())
  8503. .ToList();
  8504. //.ToPageList(pagenumber, pageSize, ref totalCount, ref totalPage)
  8505. return Ok(JsonView(true, "success", dbQuery.Select(x => new
  8506. {
  8507. x.FileName,
  8508. x.Id,
  8509. Url = AppSettingsHelper.Get("GrpFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("GrpFileBasePath"), AppSettingsHelper.Get("GrpFileFtpPath")),
  8510. CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH-mm"),
  8511. })));
  8512. }
  8513. /// <summary>
  8514. /// 下载该团组下的所有文件
  8515. /// </summary>
  8516. /// <param name="dto"></param>
  8517. /// <returns></returns>
  8518. [HttpPost]
  8519. public IActionResult ExportGroupZip(ExportGroupZipDto dto)
  8520. {
  8521. var jw = JsonView(false);
  8522. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  8523. if (groupInfo == null)
  8524. {
  8525. jw.Msg = "团组信息不存在!";
  8526. return Ok(jw);
  8527. }
  8528. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  8529. var isModule = Convert.ToBoolean(dto.isModule);
  8530. var Zips = new Dictionary<string, Stream>();
  8531. var io = new IOOperatorHelper();
  8532. if (isModule)
  8533. {
  8534. var moduleGroup = dbQuery.GroupBy(x => x.Ctable);
  8535. foreach (var moduleArr in moduleGroup)
  8536. {
  8537. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == moduleArr.Key && x.IsDel == 0);
  8538. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  8539. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8540. var chiZips = new Dictionary<string, Stream>();
  8541. foreach (var item in moduleArr)
  8542. {
  8543. if (System.IO.File.Exists(item.FilePath))
  8544. {
  8545. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  8546. {
  8547. byte[] bytes = new byte[fileStream.Length];
  8548. fileStream.Read(bytes, 0, bytes.Length);
  8549. fileStream.Close();
  8550. Stream stream = new MemoryStream(bytes);
  8551. chiZips.Add(item.FileName, stream);
  8552. }
  8553. }
  8554. }
  8555. if (chiZips.Count > 0)
  8556. {
  8557. var byts = io.ConvertZipStream(chiZips);
  8558. Stream stream = new MemoryStream(byts);
  8559. Zips.Add(key.Name + "_.zip", stream);
  8560. }
  8561. }
  8562. }
  8563. else
  8564. {
  8565. foreach (var item in dbQuery)
  8566. {
  8567. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  8568. {
  8569. byte[] bytes = new byte[fileStream.Length];
  8570. fileStream.Read(bytes, 0, bytes.Length);
  8571. fileStream.Close();
  8572. var stream = new MemoryStream(bytes);
  8573. while (Zips.ContainsKey(item.FileName))
  8574. {
  8575. item.FileName = new Random().Next(100) + "_" + item.FileName;
  8576. }
  8577. Zips.Add(item.FileName, stream);
  8578. }
  8579. }
  8580. }
  8581. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  8582. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8583. if (Zips.Count > 0)
  8584. {
  8585. var byts = io.ConvertZipStream(Zips);
  8586. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  8587. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_.Zip");
  8588. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_.zip" });
  8589. }
  8590. else
  8591. {
  8592. jw.Msg = "暂无生成文件!";
  8593. }
  8594. return Ok(jw);
  8595. }
  8596. /// <summary>
  8597. /// 下载该团组下此模块的所有文件
  8598. /// </summary>
  8599. /// <param name="dto"></param>
  8600. /// <returns></returns>
  8601. [HttpPost]
  8602. public IActionResult ExportGroupByModule(ExportGroupByModuleDto dto)
  8603. {
  8604. var jw = JsonView(false);
  8605. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  8606. if (groupInfo == null)
  8607. {
  8608. jw.Msg = "团组信息不存在!";
  8609. return Ok(jw);
  8610. }
  8611. var dbQuery = _sqlSugar.Queryable<Grp_GroupModelFile>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid && x.Ctable == dto.Ctable).ToList();
  8612. var key = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.Ctable
  8613. && x.IsDel == 0);
  8614. if (key == null)
  8615. {
  8616. jw.Msg = "Ctable指向错误!";
  8617. return Ok(jw);
  8618. }
  8619. key.Name = Regex.Replace(key.Name, @"[^\w\.@-]", "",
  8620. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8621. groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
  8622. RegexOptions.None, TimeSpan.FromSeconds(1.5));
  8623. var io = new IOOperatorHelper();
  8624. var Zips = new Dictionary<string, Stream>();
  8625. foreach (var item in dbQuery)
  8626. {
  8627. if (System.IO.File.Exists(item.FilePath))
  8628. {
  8629. using (var fileStream = new FileStream(item.FilePath, FileMode.Open, FileAccess.Read))
  8630. {
  8631. byte[] bytes = new byte[fileStream.Length];
  8632. fileStream.Read(bytes, 0, bytes.Length);
  8633. fileStream.Close();
  8634. var stream = new MemoryStream(bytes);
  8635. while (Zips.ContainsKey(item.FileName))
  8636. {
  8637. item.FileName = new Random().Next(100) + "_" + item.FileName;
  8638. }
  8639. Zips.Add(item.FileName, stream);
  8640. }
  8641. }
  8642. }
  8643. if (Zips.Count > 0)
  8644. {
  8645. var byts = io.ConvertZipStream(Zips);
  8646. var path = "\\GroupModelFiles\\" + groupInfo.TeamName;
  8647. io.ByteToFile(byts, AppSettingsHelper.Get("GrpFileBasePath") + $"{path}\\{groupInfo.TeamName}_{key.Name}_.Zip");
  8648. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("GrpFileBaseUrl") + $"{AppSettingsHelper.Get("GrpFileFtpPath")}{path}\\{groupInfo.TeamName}_{key.Name}_.Zip" });
  8649. }
  8650. else
  8651. {
  8652. jw.Msg = "暂无生成文件!";
  8653. }
  8654. return Ok(jw);
  8655. }
  8656. /// <summary>
  8657. /// 删除该团组下的指定文件
  8658. /// </summary>
  8659. /// <param name="dto"></param>
  8660. /// <returns></returns>
  8661. [HttpPost]
  8662. public IActionResult DeleteGroupFile(DeleteGroupFileDto dto)
  8663. {
  8664. var jw = JsonView(false);
  8665. var sing = _sqlSugar.Queryable<Grp_GroupModelFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  8666. if (sing == null)
  8667. {
  8668. jw.Msg = "暂无";
  8669. return Ok(jw);
  8670. }
  8671. if (System.IO.File.Exists(sing.FilePath))
  8672. {
  8673. try
  8674. {
  8675. System.IO.File.Delete(sing.FilePath);
  8676. }
  8677. catch (Exception ex)
  8678. {
  8679. jw.Msg = "删除失败!" + ex.Message;
  8680. return Ok(jw);
  8681. }
  8682. }
  8683. sing.IsDel = 1;
  8684. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  8685. sing.DeleteUserId = dto.UserId;
  8686. _sqlSugar.Updateable<Grp_GroupModelFile>(sing).ExecuteCommand();
  8687. jw = JsonView(true, "删除成功!");
  8688. return Ok(jw);
  8689. }
  8690. #endregion
  8691. #region 共享文件上传
  8692. /// <summary>
  8693. /// 超支通知推送
  8694. /// </summary>
  8695. /// <param name="dto"></param>
  8696. /// <returns></returns>
  8697. [HttpPost]
  8698. public async Task<IActionResult> qyWeChatNotification(qyWeChatNotificationDto dto)
  8699. {
  8700. //81 邀请/公务活动
  8701. var syCTable = new List<int> { 81 };
  8702. //76 酒店预订
  8703. //79 车/导游地接
  8704. //85 机票预订
  8705. var gjCTable = new List<int> { 76, 79, 85 };
  8706. var jw = JsonView(false);
  8707. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.IsDel == 0 && x.Id == dto.Diid);
  8708. if (di == null)
  8709. {
  8710. jw.Msg = "团组信息不存在!";
  8711. return Ok(jw);
  8712. }
  8713. var user = _sqlSugar.Queryable<Sys_Users>().First(x => x.IsDel == 0 && x.Id == dto.UserId);
  8714. if (user == null)
  8715. {
  8716. jw.Msg = "用户信息不存在!";
  8717. return Ok(jw);
  8718. }
  8719. if (syCTable.Contains(dto.CTable))
  8720. {
  8721. await AppNoticeLibrary.SendChatMsg_ExpenseOverrunsChat(dto.Diid, dto.UserId, dto.CTable, QiyeWeChatEnum.ExpenseOverrunsChat02);
  8722. }
  8723. else if (gjCTable.Contains(dto.CTable))
  8724. {
  8725. await AppNoticeLibrary.SendChatMsg_ExpenseOverrunsChat(dto.Diid, dto.UserId, dto.CTable, QiyeWeChatEnum.ExpenseOverrunsChat01);
  8726. }
  8727. else
  8728. {
  8729. jw.Msg = "CTABLE类型有误!";
  8730. }
  8731. jw = JsonView(true, "推送成功!", "");
  8732. return Ok(jw);
  8733. }
  8734. /// <summary>
  8735. /// 共享文件数据初始化
  8736. /// </summary>
  8737. /// <returns></returns>
  8738. [HttpGet]
  8739. public async Task<IActionResult> SharedFileInit(int userid, int portType)
  8740. {
  8741. var marketingDepartmentIds = new List<int> { 6, 26, 27, 28 };
  8742. var isMarketingDepartment = _sqlSugar.Queryable<Sys_Users>()
  8743. .Where(x => x.IsDel == 0 && marketingDepartmentIds.Contains(x.DepId))
  8744. .Select(x => x.Id)
  8745. .ToList()
  8746. .Contains(userid);
  8747. var dropDownType = _sqlSugar.Queryable<Sys_SetData>()
  8748. .Where(x => x.STid == 111 && x.IsDel == 0)
  8749. .Select(x => new
  8750. {
  8751. x.Name,
  8752. x.Id,
  8753. }).ToList();
  8754. if (isMarketingDepartment)
  8755. {
  8756. dropDownType = dropDownType.Where(x => x.Id == 1412).ToList();
  8757. }
  8758. if (portType == 1)
  8759. {
  8760. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  8761. var dropDownGroupList = _sqlSugar.Queryable<Grp_DelegationInfo>()
  8762. .Where(x => x.IsDel == 0)
  8763. .OrderByDescending(x => x.VisitDate)
  8764. .Select(x => new
  8765. {
  8766. x.TeamName,
  8767. x.Id,
  8768. x.CityId,
  8769. })
  8770. .ToList()
  8771. .Select(x =>
  8772. {
  8773. var provinceId = x.CityId;
  8774. var isDefualtVal = true;
  8775. if (provinceId > 0)
  8776. {
  8777. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  8778. if (parentId != null)
  8779. {
  8780. isDefualtVal = false;
  8781. provinceId = (int)parentId;
  8782. }
  8783. }
  8784. if (isDefualtVal)
  8785. {
  8786. provinceId = 122; //默认四川
  8787. }
  8788. return new
  8789. {
  8790. x.TeamName,
  8791. x.Id,
  8792. provinceId,
  8793. };
  8794. })
  8795. .ToList();
  8796. return Ok(JsonView(true, "SUCCESS!", new
  8797. {
  8798. dropDownType,
  8799. dropDownGroupList,
  8800. isMarketingDepartment
  8801. }));
  8802. }
  8803. else if (portType == 2 || portType == 3)
  8804. {
  8805. return Ok(JsonView(true, "SUCCESS!", new
  8806. {
  8807. dropDownType,
  8808. isMarketingDepartment
  8809. }));
  8810. }
  8811. else
  8812. {
  8813. return Ok(JsonView(false, "portType有误!"));
  8814. }
  8815. }
  8816. /// <summary>
  8817. /// 共享文件上传
  8818. /// </summary>
  8819. /// <param name="dto"></param>
  8820. /// <returns></returns>
  8821. [HttpPost]
  8822. public IActionResult SharedFileUpload([FromForm] SharedFileUploadDto dto)
  8823. {
  8824. var isGroup = new List<int> { 1412 };
  8825. if (isGroup.Contains(dto.FileType) && dto.Diid < 1)
  8826. {
  8827. return Ok(JsonView(false, "该文件需要关联团组!"));
  8828. }
  8829. if (dto.Files == null || dto.Files.Count == 0)
  8830. {
  8831. return Ok(JsonView(false, "无文件信息!"));
  8832. }
  8833. if (dto.Files.Sum(x => x.Length) > 20 * 1024 * 1024)
  8834. {
  8835. return Ok(JsonView(false, "文件大小超过20M!"));
  8836. }
  8837. if (dto.Userid < 1)
  8838. {
  8839. return Ok(JsonView(false, "请传入有效的Userid!"));
  8840. }
  8841. var jobInfo = _sqlSugar.Queryable<Sys_Users, Sys_JobPost>((u, j) => u.JobPostId == j.Id && j.IsDel == 0)
  8842. .Where(u => u.IsDel == 0 && u.Id == dto.Userid)
  8843. .Select((u, j) => new
  8844. {
  8845. u.CnName,
  8846. UserId = u.Id,
  8847. j.JobName,
  8848. })
  8849. .First();
  8850. if (jobInfo == null)
  8851. {
  8852. return Ok(JsonView(false, "请传入有效的Userid!"));
  8853. }
  8854. var commonFileExtensions = new List<string>
  8855. {
  8856. // 文本文件
  8857. ".txt", ".doc", ".docx", ".odt", ".pdf", ".rtf", ".md", ".log",
  8858. // 图片文件
  8859. ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".svg",
  8860. // 视频文件
  8861. ".mp4", ".avi", ".mov", ".mkv", ".wmv", ".flv", ".mpg", ".mpeg",
  8862. // 音频文件
  8863. ".mp3", ".wav", ".ogg", ".aac", ".flac",
  8864. // 压缩文件
  8865. ".zip", ".rar", ".7z", ".tar", ".gz", ".bz2",
  8866. // 数据文件
  8867. ".csv", ".xls", ".xlsx", ".json", ".xml", ".yaml", ".ini",
  8868. };
  8869. try
  8870. {
  8871. var setting = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1416);
  8872. var settingExtend = JsonConvert.DeserializeObject<List<string>>(setting.Remark);
  8873. commonFileExtensions.AddRange(settingExtend);
  8874. }
  8875. catch (Exception)
  8876. { }
  8877. var setdata = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == dto.FileType);
  8878. if (setdata == null)
  8879. {
  8880. return Ok(JsonView(false, "请传入有效的FileType!"));
  8881. }
  8882. var insertList = new List<Grp_GroupShareFile>();
  8883. string winPath = AppSettingsHelper.Get("ShareFileBasePath") + $"{setdata.Name}/";
  8884. if (!Directory.Exists(winPath))
  8885. {
  8886. Directory.CreateDirectory(winPath);
  8887. }
  8888. foreach (var item in dto.Files)
  8889. {
  8890. var houzui = Path.GetExtension(item.FileName);
  8891. if (!commonFileExtensions.Contains(houzui))
  8892. {
  8893. return Ok(JsonView(false, "未知后缀名称!"));
  8894. }
  8895. var fileName = $"{jobInfo.JobName}-{jobInfo.CnName}-{item.FileName}";
  8896. var saveFilePath = winPath + fileName;
  8897. using (FileStream fs = System.IO.File.Create(saveFilePath))
  8898. {
  8899. item.CopyTo(fs);
  8900. fs.Flush();
  8901. }
  8902. var fileDetail = new Grp_GroupShareFile()
  8903. {
  8904. CreateUserId = dto.Userid,
  8905. CreateTime = DateTime.Now,
  8906. UploadJob = jobInfo.JobName,
  8907. FileName = fileName,
  8908. FileType = dto.FileType,
  8909. Diid = dto.Diid,
  8910. FilePath = winPath + fileName,
  8911. };
  8912. insertList.Add(fileDetail);
  8913. }
  8914. _sqlSugar.Insertable<Grp_GroupShareFile>(insertList).ExecuteCommand();
  8915. return Ok(JsonView(true, "保存成功!"));
  8916. }
  8917. /// <summary>
  8918. /// 查询共享文件列表
  8919. /// </summary>
  8920. /// <param name="dto"></param>
  8921. /// <returns></returns>
  8922. [HttpPost]
  8923. public IActionResult QuerySharedFile(QuerySharedFileDto dto)
  8924. {
  8925. var isGroup = new List<int> { 1412 };
  8926. if (!isGroup.Contains(dto.FileType)) dto.Diid = 0;
  8927. var queryExpression = Expressionable.Create<Grp_GroupShareFile>()
  8928. .And(x => x.Diid == dto.Diid)
  8929. .And(x => x.FileType == dto.FileType)
  8930. .And(x => x.IsDel == 0)
  8931. .AndIF(!dto.FileName.IsNullOrWhiteSpace(), x => x.FileName.Contains(dto.FileName))
  8932. .AndIF(DateTime.TryParse(dto.StartTime, out DateTime Start), x => x.CreateTime >= Start)
  8933. .AndIF(DateTime.TryParse(dto.EndTime, out DateTime End), x => x.CreateTime <= End);
  8934. int totalCount = 0;
  8935. var dbQuery = _sqlSugar.Queryable<Grp_GroupShareFile>()
  8936. .Where(queryExpression.ToExpression())
  8937. .OrderBy(x => x.UploadJob)
  8938. .Select(x => new
  8939. {
  8940. x.Id,
  8941. FilePath = AppSettingsHelper.Get("ShareFileBaseUrl") + x.FilePath.Replace(AppSettingsHelper.Get("ShareFileBasePath"), AppSettingsHelper.Get("ShareFileFtpPath")),
  8942. x.FileName,
  8943. x.FileType,
  8944. x.CreateTime,
  8945. })
  8946. .ToPageList(dto.PageIndex, dto.PageSize, ref totalCount);
  8947. return Ok(JsonView(true, "SUCCESS!", new
  8948. {
  8949. FileList = dbQuery,
  8950. dto.PageSize,
  8951. dto.PageIndex,
  8952. totalCount
  8953. }));
  8954. }
  8955. /// <summary>
  8956. /// 删除共享文件模块下的指定文件
  8957. /// </summary>
  8958. /// <param name="dto"></param>
  8959. /// <returns></returns>
  8960. [HttpPost]
  8961. public IActionResult DeleteSharedFile(DeleteGroupFileDto dto)
  8962. {
  8963. var jw = JsonView(false);
  8964. var sing = _sqlSugar.Queryable<Grp_GroupShareFile>().First(x => x.Id == dto.Id && x.IsDel == 0);
  8965. if (sing == null)
  8966. {
  8967. jw.Msg = "暂无文件信息!";
  8968. return Ok(jw);
  8969. }
  8970. if (sing.CreateUserId != dto.UserId)
  8971. {
  8972. jw.Msg = "只能删除自己上传的文件!";
  8973. return Ok(jw);
  8974. }
  8975. if (System.IO.File.Exists(sing.FilePath))
  8976. {
  8977. try
  8978. {
  8979. System.IO.File.Delete(sing.FilePath);
  8980. }
  8981. catch (Exception ex)
  8982. {
  8983. jw.Msg = "删除失败!" + ex.Message;
  8984. return Ok(jw);
  8985. }
  8986. }
  8987. sing.IsDel = 1;
  8988. sing.DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  8989. sing.DeleteUserId = dto.UserId;
  8990. _sqlSugar.Updateable<Grp_GroupShareFile>(sing).ExecuteCommand();
  8991. jw = JsonView(true, "删除成功!");
  8992. return Ok(jw);
  8993. }
  8994. #endregion
  8995. #region 团组英文资料
  8996. /// <summary>
  8997. /// 查询团组英文所有资料
  8998. /// </summary>
  8999. /// <param name="dto"></param>
  9000. /// <returns></returns>
  9001. [HttpPost]
  9002. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9003. public async Task<IActionResult> QueryDelegationEnData(QueryDelegationEnDataDto dto)
  9004. {
  9005. try
  9006. {
  9007. Result groupData = await _delegationEnDataRep.QueryDelegationEnData(dto);
  9008. if (groupData.Code != 0)
  9009. {
  9010. return Ok(JsonView(false, groupData.Msg));
  9011. }
  9012. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9013. }
  9014. catch (Exception ex)
  9015. {
  9016. return Ok(JsonView(false, ex.Message));
  9017. throw;
  9018. }
  9019. }
  9020. /// <summary>
  9021. /// 团组英文资料操作(Status:1.新增,2.修改)
  9022. /// </summary>
  9023. /// <param name="dto"></param>
  9024. /// <returns></returns>
  9025. [HttpPost]
  9026. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9027. public async Task<IActionResult> OpDelegationEnData(OpDelegationEnDataDto dto)
  9028. {
  9029. try
  9030. {
  9031. Result groupData = await _delegationEnDataRep.OpDelegationEnData(dto);
  9032. if (groupData.Code != 0)
  9033. {
  9034. return Ok(JsonView(false, groupData.Msg));
  9035. }
  9036. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  9037. }
  9038. catch (Exception ex)
  9039. {
  9040. return Ok(JsonView(false, ex.Message));
  9041. throw;
  9042. }
  9043. }
  9044. /// <summary>
  9045. /// 团组英文资料Id查询数据
  9046. /// </summary>
  9047. /// <param name="dto"></param>
  9048. /// <returns></returns>
  9049. [HttpPost]
  9050. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9051. public async Task<IActionResult> QueryDelegationEnDataById(QueryDelegationEnDataByIdDto dto)
  9052. {
  9053. try
  9054. {
  9055. Grp_DelegationEnData _DelegationEnData = await _sqlSugar.Queryable<Grp_DelegationEnData>().FirstAsync(it => it.Id == dto.Id && it.IsDel == 0);
  9056. if (_DelegationEnData != null)
  9057. {
  9058. return Ok(JsonView(true, "查询成功!", _DelegationEnData));
  9059. }
  9060. return Ok(JsonView(true, "暂无数据!", _DelegationEnData));
  9061. }
  9062. catch (Exception ex)
  9063. {
  9064. return Ok(JsonView(false, "程序错误!"));
  9065. throw;
  9066. }
  9067. }
  9068. /// <summary>
  9069. /// 团组英文资料删除
  9070. /// </summary>
  9071. /// <param name="dto"></param>
  9072. /// <returns></returns>
  9073. [HttpPost]
  9074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9075. public async Task<IActionResult> DelDelegationEnData(DelBaseDto dto)
  9076. {
  9077. try
  9078. {
  9079. var res = await _delegationEnDataRep.SoftDeleteByIdAsync<Grp_DelegationEnData>(dto.Id.ToString(), dto.DeleteUserId);
  9080. if (!res)
  9081. {
  9082. return Ok(JsonView(false, "删除失败"));
  9083. }
  9084. return Ok(JsonView(true, "删除成功!"));
  9085. }
  9086. catch (Exception ex)
  9087. {
  9088. return Ok(JsonView(false, ex.Message));
  9089. throw;
  9090. }
  9091. }
  9092. #endregion
  9093. #region 导出邀请函
  9094. /// <summary>
  9095. /// 导出邀请函页面初始化
  9096. /// </summary>
  9097. /// <param name="dto"></param>
  9098. /// <returns></returns>
  9099. [HttpPost]
  9100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9101. public async Task<IActionResult> QueryinvitationLetter(DecreasePaymentsListDto dto)
  9102. {
  9103. try
  9104. {
  9105. var grp_Delegations = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.VisitStartDate, OrderByType.Desc).ToList();
  9106. var crm_Deles = new List<Crm_DeleClient>();
  9107. if (dto.DiId == 0)
  9108. {
  9109. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == grp_Delegations[0].Id && a.IsDel == 0).ToListAsync();
  9110. }
  9111. else
  9112. {
  9113. crm_Deles = await _sqlSugar.Queryable<Crm_DeleClient>().Where(a => a.DiId == dto.DiId && a.IsDel == 0).ToListAsync();
  9114. }
  9115. return Ok(JsonView(true, "查询成功!", new
  9116. {
  9117. deleClient = crm_Deles,
  9118. delegations = grp_Delegations
  9119. }));
  9120. }
  9121. catch (Exception ex)
  9122. {
  9123. return Ok(JsonView(false, "程序错误!"));
  9124. throw;
  9125. }
  9126. }
  9127. /// <summary>
  9128. /// 导出邀请函
  9129. /// </summary>
  9130. /// <param name="dto"></param>
  9131. /// <returns></returns>
  9132. [HttpPost]
  9133. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9134. public async Task<IActionResult> invitationLetter(DecreasePaymentsListDto dto)
  9135. {
  9136. #region 参数验证
  9137. //if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数!"));
  9138. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数!"));
  9139. #endregion
  9140. try
  9141. {
  9142. var transDic = new Dictionary<string, string>();
  9143. string sql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  9144. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  9145. From Grp_TourClientList tcl
  9146. Left Join
  9147. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  9148. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  9149. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  9150. From Crm_DeleClient dc
  9151. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  9152. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  9153. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  9154. Where dc.IsDel = 0) temp
  9155. On temp.DcId =tcl.ClientId
  9156. Where tcl.IsDel = 0 And tcl.DiId = {0}", dto.DiId);
  9157. var datas = _sqlSugar.SqlQueryable<TourClientListDetailsView>(sql).ToList();
  9158. var texts = new List<string>();
  9159. if (datas.Count != 0)
  9160. {
  9161. foreach (TourClientListDetailsView item in datas)
  9162. {
  9163. if (!string.IsNullOrWhiteSpace(item.Pinyin))
  9164. {
  9165. transDic.Add(item.LastName + item.FirstName, item.Pinyin);
  9166. }
  9167. else
  9168. {
  9169. string name = item.LastName + item.FirstName;
  9170. texts.Add(name);
  9171. }
  9172. if (!string.IsNullOrEmpty(item.Job) && !texts.Contains(item.Job))
  9173. {
  9174. if (!transDic.ContainsKey(item.Job))
  9175. {
  9176. texts.Add(item.Job);
  9177. }
  9178. }
  9179. if (!string.IsNullOrEmpty(item.CompanyFullName))
  9180. {
  9181. texts.Add(item.CompanyFullName);
  9182. }
  9183. }
  9184. var transData = await _airTicketResRep.ReTransBatch(texts, "en");
  9185. if (transData.Count > 0)
  9186. {
  9187. foreach (TranslateResult item in transData)
  9188. {
  9189. if (!transDic.ContainsKey(item.Query))
  9190. {
  9191. transDic.Add(item.Query, item.Translation);
  9192. }
  9193. }
  9194. }
  9195. var list = new List<GuestList>();
  9196. foreach (var dele in datas)
  9197. {
  9198. var guestList = new GuestList();
  9199. if (!string.IsNullOrWhiteSpace(dele.Pinyin))
  9200. {
  9201. guestList.Name = dele.Pinyin;
  9202. }
  9203. else
  9204. {
  9205. string Name = transDic.Where(s => s.Key == dele.LastName + dele.FirstName).FirstOrDefault().Value;
  9206. guestList.Name = Name;
  9207. }
  9208. if (dele.Sex == 0)
  9209. {
  9210. guestList.Sex = "Male";
  9211. }
  9212. else if (dele.Sex == 1)
  9213. {
  9214. guestList.Sex = "Female";
  9215. }
  9216. guestList.DOB = dele.BirthDay.Replace('-', '.');
  9217. if (!string.IsNullOrEmpty(dele.Job))
  9218. {
  9219. guestList.Job = dele.Job;
  9220. }
  9221. list.Add(guestList);
  9222. }
  9223. //载入模板
  9224. var doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/邀请函模板0210.docx");
  9225. var builder = new DocumentBuilder(doc);
  9226. //获取word里所有表格
  9227. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9228. //获取所填表格的序数
  9229. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  9230. var rowStart = tableOne.Rows[0]; //获取第1行
  9231. //循环赋值
  9232. for (int i = 0; i < list.Count; i++)
  9233. {
  9234. builder.MoveToCell(0, i + 1, 0, 0);
  9235. builder.Write(list[i].Name.ToString());
  9236. builder.MoveToCell(0, i + 1, 1, 0);
  9237. builder.Write(list[i].Sex.ToString());
  9238. builder.MoveToCell(0, i + 1, 2, 0);
  9239. builder.Write(list[i].DOB.ToString());
  9240. builder.MoveToCell(0, i + 1, 3, 0);
  9241. builder.Write(list[i].Job.ToString());
  9242. }
  9243. //删除多余行
  9244. while (tableOne.Rows.Count > list.Count + 1)
  9245. {
  9246. tableOne.Rows.RemoveAt(list.Count + 1);
  9247. }
  9248. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  9249. string fileName = "邀请函" + DateTime.Now.ToString("yyyy-MM-dd") + ".docx";
  9250. string filePath = fileDir + $@"商邀相关文件/{fileName}";
  9251. doc.Save(filePath);
  9252. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/GrpFile/商邀相关文件/" + fileName;
  9253. return Ok(JsonView(true, "操作成功!", Url));
  9254. }
  9255. else
  9256. {
  9257. return Ok(JsonView(false, "该团组客户名单暂未录入!"));
  9258. }
  9259. }
  9260. catch (Exception ex)
  9261. {
  9262. return Ok(JsonView(false, ex.Message));
  9263. throw;
  9264. }
  9265. }
  9266. #endregion
  9267. #region 团组经理模块 出入境费用
  9268. /// <summary>
  9269. /// 团组模块 - 出入境费用 - 省份基础数据源
  9270. /// </summary>
  9271. /// <returns></returns>
  9272. [HttpGet]
  9273. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9274. public async Task<IActionResult> GetEnterExitProvBelongCostDataSource()
  9275. {
  9276. return Ok(JsonView(await _groupRepository.ProvinceBasicSource()));
  9277. }
  9278. /// <summary>
  9279. /// 团组模块 - 出入境费用 - 基础数据源(团组名称/币种类型)
  9280. /// </summary>
  9281. /// <param name="dto"></param>
  9282. /// <returns></returns>
  9283. [HttpPost]
  9284. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9285. public async Task<IActionResult> GetEnterExitCostDataSource(EnterExitCostDataSourceDto dto)
  9286. {
  9287. var groupNameData = await _groupRepository.EnterExitCostGroupNameAsync();
  9288. var groupNamFirst = groupNameData.FirstOrDefault();
  9289. //SetDataInfoView
  9290. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  9291. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  9292. List<SetDataInfoView> _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  9293. //验证城市归属并给默认值
  9294. int provinceId = 122;
  9295. if (groupNamFirst != null) provinceId = groupNamFirst.ProvinceId;
  9296. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  9297. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  9298. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  9299. #region 城市区间 - 城市数据
  9300. var overseaVehicles = await _sqlSugar.Queryable<Res_OverseaVehicle>().Where(x => x.IsDel == 0).ToListAsync();
  9301. var overseaVehicleTypes = await _sqlSugar.Queryable<Res_OverseaVehicleTypePrice>().Where(x => x.IsDel == 0).ToListAsync();
  9302. var sysUers = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToListAsync();
  9303. var overseaVehicleCityDatas = new List<dynamic>();
  9304. foreach (var item in overseaVehicleTypes)
  9305. {
  9306. var parentInfo = overseaVehicles.FirstOrDefault(x => x.Id == item.OvId);
  9307. string area = string.Empty,
  9308. serviceType = "未设置",
  9309. currencyName = string.Empty;
  9310. decimal otherPrice = 0.00M;
  9311. if (parentInfo != null)
  9312. {
  9313. if (parentInfo.CountryName == parentInfo.CityName) area = parentInfo.CountryName;
  9314. else area = $"{parentInfo.CountryName}-{parentInfo.CityName}";
  9315. serviceType = item.ServiceType.GetDescription();
  9316. currencyName = currencyData.FirstOrDefault(x => x.Id == parentInfo.Currency)?.Name ?? "-";
  9317. otherPrice = parentInfo.OtherPrice1 + parentInfo.OtherPrice2;
  9318. }
  9319. overseaVehicleCityDatas.add(new
  9320. {
  9321. area,
  9322. item.CarTypeName,
  9323. serviceType,
  9324. item.Price,
  9325. guidePrice = parentInfo?.GuidePrice ?? 0.00M,
  9326. otherPrice,
  9327. currency = parentInfo?.Currency ?? 0,
  9328. currencyName,
  9329. LastUpdateUserName = sysUers.FirstOrDefault(x => x.Id == item.LastUpdateUserId)?.CnName ?? "-",
  9330. item.LastUpdateTime,
  9331. item.Remark
  9332. });
  9333. }
  9334. #endregion
  9335. return Ok(JsonView(true, "查询成功!", new
  9336. {
  9337. GroupNameData = groupNameData,
  9338. CurrencyData = _CurrencyData,
  9339. WordTypeData = wordTypeData,
  9340. ExcelTypeData = excelTypeData,
  9341. CurrencyInit = _currencyInfos,
  9342. ViewPermissionData = viewPermissionData,
  9343. OverseaVehicleCityData = overseaVehicleCityDatas
  9344. }));
  9345. }
  9346. /// <summary>
  9347. /// 团组模块 - 出入境费用 - 文件类型list 跟据省份Id获取
  9348. /// </summary>
  9349. /// <returns></returns>
  9350. [HttpGet("{provinceId}")]
  9351. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9352. public async Task<IActionResult> EnterExitCostFileOwner([FromRoute] int provinceId = 122)
  9353. {
  9354. //验证城市归属并给默认值
  9355. if (provinceId < 1) provinceId = 122;
  9356. /*
  9357. * 122 四川
  9358. * 108 贵州
  9359. * 103 重庆
  9360. * 132 云南
  9361. */
  9362. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  9363. return Ok(JsonView(true, "查询成功!", new
  9364. {
  9365. WordTypeData = wordTypeData,
  9366. ExcelTypeData = excelTypeData,
  9367. }));
  9368. }
  9369. /// <summary>
  9370. /// 团组模块 - 出入境费用
  9371. /// 实时汇率 tips
  9372. /// 签证费用 tips
  9373. /// 机票费用 tips
  9374. /// </summary>
  9375. /// <returns></returns>
  9376. [HttpPost]
  9377. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9378. public async Task<IActionResult> GetEnterExitCostCorrelationTips(EnterExitCostInfobyDiIdDto dto)
  9379. {
  9380. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(it => it.Id == dto.DiId && it.IsDel == 0);
  9381. //默认币种显示
  9382. var reteInfos = await GeneralMethod.EnterExitCostLiveRate();
  9383. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.DiId);
  9384. var airData = await GeneralMethod.EntryAndExitTips(dto.DiId);
  9385. return Ok(JsonView(true, "查询成功!", new
  9386. {
  9387. //GroupNameData = groupNameData.Data,
  9388. visaData = visaData.Data,
  9389. airData,
  9390. reteInfos
  9391. }));
  9392. }
  9393. #region 城市区间交通费
  9394. #endregion
  9395. /// <summary>
  9396. /// 团组模块 - 出入境费用 - Info
  9397. /// </summary>
  9398. /// <param name="dto"></param>
  9399. /// <returns></returns>
  9400. [HttpPost]
  9401. //[ApiLog("Grp_EnterExitCost", OperationEnum.Details)]
  9402. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9403. public async Task<IActionResult> GetEnterExitCostInfobyDiId(EnterExitCostInfobyDiIdDto dto)
  9404. {
  9405. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9406. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9407. return Ok(await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto));
  9408. }
  9409. /// <summary>
  9410. /// 团组模块 - 出入境费用 - 设置view权限
  9411. /// </summary>
  9412. /// <returns></returns>
  9413. [HttpPost]
  9414. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9415. public async Task<IActionResult> EnterExitCostSetViewPermissiion(EnterExitCostSetViewPermissiionDto dto)
  9416. {
  9417. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  9418. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  9419. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  9420. var permissions = new List<Grp_EnterExitCostPermission>();
  9421. foreach (var userId in dto.UserIds)
  9422. {
  9423. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.GroupId, UserId = userId, CreateUserId = dto.CurrUserId });
  9424. }
  9425. if (permissions.Any())
  9426. {
  9427. _sqlSugar.BeginTran();
  9428. try
  9429. {
  9430. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.GroupId).ExecuteCommandAsync();
  9431. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  9432. if (result < 1)
  9433. {
  9434. _sqlSugar.RollbackTran();
  9435. return Ok(JsonView(false));
  9436. }
  9437. }
  9438. catch (Exception ex)
  9439. {
  9440. _sqlSugar.RollbackTran();
  9441. return Ok(JsonView(false, ex.Message));
  9442. }
  9443. _sqlSugar.CommitTran();
  9444. return Ok(JsonView(true));
  9445. }
  9446. return Ok(JsonView(false));
  9447. }
  9448. /// <summary>
  9449. /// 团组模块 - 出入境费用 - Add And Update
  9450. /// </summary>
  9451. /// <returns></returns>
  9452. [HttpPost]
  9453. [ApiLog("Grp_EnterExitCost", OperationEnum.Add)]
  9454. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9455. public async Task<IActionResult> PostEnterExitCostOperate(EnterExitCostOperateDto dto)
  9456. {
  9457. try
  9458. {
  9459. var rateRecords = new List<RateRecordInfo>();
  9460. #region 汇率保存前存储
  9461. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(x => x.IsDel == 0 && x.DiId == dto.DiId);
  9462. if (info != null)
  9463. {
  9464. var cacheRateInfos = CommonFun.GetCurrencyChinaToList(info.CurrencyRemark);
  9465. if (cacheRateInfos != null && cacheRateInfos.Count > 0)
  9466. {
  9467. rateRecords = cacheRateInfos.Select(x => new RateRecordInfo()
  9468. {
  9469. CurrencyCode = x.CurrencyCode,
  9470. CurrencyName = x.CurrencyName,
  9471. UpdatePreRate = x.Rate,
  9472. UpdateBreRate = dto.Currencys.Where(x1 => x1.CurrencyName.Equals(x.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M
  9473. }).ToList();
  9474. }
  9475. else
  9476. {
  9477. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  9478. {
  9479. CurrencyCode = x.CurrencyCode,
  9480. CurrencyName = x.CurrencyName,
  9481. UpdatePreRate = 0.00M,
  9482. UpdateBreRate = x.Rate
  9483. }).ToList();
  9484. }
  9485. }
  9486. else
  9487. {
  9488. rateRecords = dto.Currencys.Select(x => new RateRecordInfo()
  9489. {
  9490. CurrencyCode = x.CurrencyCode,
  9491. CurrencyName = x.CurrencyName,
  9492. UpdatePreRate = 0.00M,
  9493. UpdateBreRate = x.Rate
  9494. }).ToList();
  9495. }
  9496. #endregion
  9497. var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  9498. if (dto.DayOtherPriceData.Any())
  9499. {
  9500. var inserList = dto.DayOtherPriceData
  9501. .Where(x => x.Id == 0)
  9502. .Select(x => new Grp_DayOtherPrice
  9503. {
  9504. Cost = x.Cost,
  9505. Id = x.Id,
  9506. CreateTime = DateTime.Now,
  9507. CreateUserId = dto.UserId,
  9508. Currency = x.Currency,
  9509. Diid = x.DiId,
  9510. Index = x.Index,
  9511. IsDel = 0,
  9512. SetDataId = x.SetDataId,
  9513. SubTotal = x.SubTotal,
  9514. Remark = x.Remark
  9515. })
  9516. .ToList();
  9517. var updateList = dto.DayOtherPriceData
  9518. .Where(x => x.Id != 0)
  9519. .Select(x => new Grp_DayOtherPrice
  9520. {
  9521. Cost = x.Cost,
  9522. Id = x.Id,
  9523. CreateTime = DateTime.Now,
  9524. CreateUserId = dto.UserId,
  9525. Currency = x.Currency,
  9526. Diid = x.DiId,
  9527. Index = x.Index,
  9528. IsDel = 0,
  9529. SetDataId = x.SetDataId,
  9530. SubTotal = x.SubTotal,
  9531. Remark = x.Remark
  9532. })
  9533. .ToList();
  9534. //添加
  9535. _sqlSugar.BeginTran();
  9536. if (inserList.Any())
  9537. {
  9538. var rowCount = _sqlSugar.Insertable<Grp_DayOtherPrice>(inserList).ExecuteCommand();
  9539. }
  9540. if (updateList.Any())
  9541. {
  9542. var rowCount = _sqlSugar.Updateable<Grp_DayOtherPrice>(updateList).ExecuteCommand();
  9543. }
  9544. _sqlSugar.CommitTran();
  9545. }
  9546. if (data.Code != 0)
  9547. {
  9548. return Ok(JsonView(false, data.Msg));
  9549. }
  9550. //生成默认文件pdf并且通知人员
  9551. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  9552. {
  9553. DiId = dto.DiId,
  9554. ExportType = 1,
  9555. SubTypeId = 1005
  9556. }, "pdf");
  9557. //发送通知
  9558. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  9559. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  9560. string md5Sign = GeneralMethod.Encrypt($"{sign}&fileName={fileUrl}");
  9561. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", sign, fileUrl);
  9562. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(dto.DiId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  9563. //汇率信息记录
  9564. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  9565. var checkCurrencys = await _enterExitCostRep.GetCheckCurrencies(dto.DiId);
  9566. //汇率验证、反推
  9567. (bool isSendMsg, string msgContent, List<CurrencyInfo> liveRates) = await GeneralMethod.EnterExitCostCheckRate(dto.DiId, checkCurrencys);
  9568. if (isSendMsg)
  9569. {
  9570. //消息推送
  9571. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFin(dto.DiId, dto.UserId, msgContent);
  9572. }
  9573. #region 日志汇率记录
  9574. //按照已使用币种记录
  9575. if (checkCurrencys != null && checkCurrencys.Count > 0)
  9576. {
  9577. rateRecords = rateRecords.Where(x => checkCurrencys.Select(x1 => x1.CurrencyName).ToList().Contains(x.CurrencyName)).ToList();
  9578. //汇率记录中加入实时汇率
  9579. if (liveRates != null && liveRates.Count > 0)
  9580. {
  9581. foreach (var item in rateRecords)
  9582. {
  9583. item.CurrLiveRate = liveRates.Where(x => x.CurrencyName.Equals(item.CurrencyName)).FirstOrDefault()?.Rate ?? 0.00M;
  9584. }
  9585. }
  9586. var teamName = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.Id == dto.DiId && x.IsDel == 0).Select(x => x.TeamName).FirstAsync();
  9587. var operationName = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.UserId && x.IsDel == 0).Select(x => x.CnName).FirstAsync();
  9588. var logContent = new StringBuilder();
  9589. foreach (var item in rateRecords)
  9590. {
  9591. var blRate = (item.CurrLiveRate * 1.0350M).TruncDecimals(4);
  9592. string msg = $">- {item.CurrencyName}汇率:(页面保存前){item.UpdatePreRate:#0.0000}/(页面保存){item.UpdateBreRate:#0.0000}/实时汇率(已上浮1.0350):{blRate:#0.0000}【注:原接口输出汇率为:{item.CurrLiveRate:#0.0000}】";
  9593. logContent.AppendLine(msg);
  9594. }
  9595. _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());
  9596. }
  9597. #endregion
  9598. return Ok(JsonView(true, data.Msg, data.Data));
  9599. }
  9600. catch (Exception ex)
  9601. {
  9602. return Ok(JsonView(false, ex.Message));
  9603. }
  9604. }
  9605. /// <summary>
  9606. /// 团组模块 - 出入境费用 - Confirm 费用
  9607. /// </summary>
  9608. /// <returns></returns>
  9609. [HttpPost]
  9610. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9611. public async Task<IActionResult> PostEnterExitCostIsConfirm(ConfirmCostDto dto)
  9612. {
  9613. //TODO:测试完毕需把对应的用户ID更改
  9614. //1、数据表添加字段
  9615. //2、更改字段接口()
  9616. var _view = await _enterExitCostRep.ConfirmCost(dto);
  9617. //3、确认成功 给财务发送消息
  9618. if (_view.Code == 200)
  9619. {
  9620. if (dto.Type == 1)
  9621. {
  9622. int diId = _enterExitCostRep._sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.Id == dto.Id).First()?.DiId ?? 0;
  9623. await AppNoticeLibrary.SendUserMsg_GroupShare_ToFinance(diId);
  9624. }
  9625. }
  9626. return Ok(_view);
  9627. }
  9628. /// <summary>
  9629. /// 团组模块 - 出入境费用 - File download
  9630. /// </summary>
  9631. /// <param name="dto"></param>
  9632. /// <returns></returns>
  9633. [HttpPost]
  9634. //[ApiLog("Grp_EnterExitCost", OperationEnum.Download)]
  9635. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  9636. public async Task<IActionResult> PostEnterExitCostDownload(EnterExitCostDownloadDto dto)
  9637. {
  9638. try
  9639. {
  9640. if (dto.DiId < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  9641. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  9642. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  9643. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  9644. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  9645. 3 团组成员名单 1 团组成员名单", ""));
  9646. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).OrderByDescending(x => x.CreateTime).First();
  9647. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCost>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  9648. if (_EnterExitCosts == null) return Ok(JsonView(400, "该团组未填写出入境费用;", ""));
  9649. var currencyInit = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToList();
  9650. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  9651. //数据源
  9652. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  9653. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  9654. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  9655. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  9656. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  9657. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  9658. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  9659. .Where((x, a, b) => x.IsDel == 0 && x.Diid == dto.DiId)
  9660. .Select((x, a, b) => new
  9661. {
  9662. x.Index,
  9663. itemName = a.Name,
  9664. CurrencyStr = b.Name,
  9665. x.Cost,
  9666. x.SubTotal,
  9667. x.Remark
  9668. })
  9669. .OrderBy((x) => x.Index)
  9670. .ToList(); //其他款项费用
  9671. var peiceItemCurrencys = new List<string>();
  9672. if (_DayAndCosts.Any())
  9673. {
  9674. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  9675. if (currencyIds.Any()) peiceItemCurrencys.AddRange(currencyInit.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  9676. }
  9677. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  9678. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  9679. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  9680. {
  9681. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  9682. }
  9683. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  9684. var _DelegationInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
  9685. var DeleClientList = _sqlSugar.Queryable<Grp_TourClientList>()
  9686. .LeftJoin<Crm_DeleClient>((tcl, dc) => tcl.ClientId == dc.Id && dc.IsDel == 0)
  9687. .LeftJoin<Crm_CustomerCompany>((tcl, dc, cc) => dc.CrmCompanyId == cc.Id && dc.IsDel == 0)
  9688. .Where((tcl, dc, cc) => tcl.IsDel == 0 && tcl.DiId == dto.DiId)
  9689. .Select((tcl, dc, cc) => new ClientInfo
  9690. {
  9691. LastName = dc.LastName,
  9692. FirstName = dc.FirstName,
  9693. Sex = dc.Sex,
  9694. Birthday = dc.BirthDay,
  9695. Company = cc.CompanyFullName,
  9696. Job = dc.Job
  9697. })
  9698. .ToList();
  9699. foreach (var item in DeleClientList)
  9700. {
  9701. EncryptionProcessor.DecryptProperties(item);
  9702. }
  9703. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).First();
  9704. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  9705. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  9706. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  9707. _DelegationInfo.VisitCountry = _DelegationInfo.VisitCountry.Replace("|", "、");
  9708. if (dto.ExportType == 1) //明细表
  9709. {
  9710. if (dto.SubTypeId == 1005) //1005(默认明细表)
  9711. {
  9712. //获取模板
  9713. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  9714. //载入模板
  9715. var doc = new Document(tempPath);
  9716. var builder = new DocumentBuilder(doc);
  9717. var dic = new Dictionary<string, string>();
  9718. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  9719. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  9720. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  9721. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  9722. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  9723. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  9724. //境内费用(其他费用)
  9725. if (_EnterExitCosts.ChoiceOne == 1)
  9726. {
  9727. string row1_1 = "";
  9728. if (_EnterExitCosts.Visa > 0)
  9729. {
  9730. //insidePayTotal += _EnterExitCosts.Visa;
  9731. row1_1 = $"签证费:{_EnterExitCosts.Visa:#0.00} 元/人";
  9732. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  9733. //{
  9734. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  9735. //}
  9736. }
  9737. string row1_2 = "";
  9738. if (_EnterExitCosts.YiMiao > 0)
  9739. {
  9740. //insidePayTotal += _EnterExitCosts.YiMiao;
  9741. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00} 元/人";
  9742. }
  9743. if (_EnterExitCosts.HeSuan > 0)
  9744. {
  9745. //insidePayTotal += _EnterExitCosts.HeSuan;
  9746. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan:#0.00} 元/人";
  9747. }
  9748. if (_EnterExitCosts.Service > 0)
  9749. {
  9750. //insidePayTotal += _EnterExitCosts.Service;
  9751. row1_2 += $"服务费:{_EnterExitCosts.Service:#0.00} 元/人";
  9752. }
  9753. string row1_3 = "";
  9754. if (_EnterExitCosts.Safe > 0)
  9755. {
  9756. //insidePayTotal += _EnterExitCosts.Safe;
  9757. row1_3 += $"保险费:{_EnterExitCosts.Safe:#0.00} 元/人";
  9758. }
  9759. if (_EnterExitCosts.Ticket > 0)
  9760. {
  9761. //insidePayTotal += _EnterExitCosts.Ticket;
  9762. row1_3 += $"参展门票:{_EnterExitCosts.Ticket:#0.00} 元/人";
  9763. }
  9764. string row1 = "";
  9765. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  9766. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  9767. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  9768. row1 += $"备注:{_EnterExitCosts.Remark}";
  9769. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  9770. dic.Add("Row1Str", row1);
  9771. }
  9772. var airTotalStr = new StringBuilder();
  9773. var airPriceStr = new StringBuilder();
  9774. var cityTrafficLabel = new StringBuilder();
  9775. //经济舱
  9776. if (_EnterExitCosts.SumJJC == 1)
  9777. {
  9778. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideJJPay:#0.00}元/人(经济舱)");
  9779. airPriceStr.AppendFormat($"{_EnterExitCosts.AirJJ:#0.00}元/人(经济舱)");
  9780. cityTrafficLabel.AppendFormat("经济舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic);
  9781. }
  9782. //公务舱
  9783. if (_EnterExitCosts.SumGWC == 1)
  9784. {
  9785. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideGWPay:#0.00} 元/人(公务舱)");
  9786. airPriceStr.AppendFormat($"{_EnterExitCosts.AirGW:#0.00} 元/人(公务舱)");
  9787. cityTrafficLabel.AppendFormat("公务舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic1);
  9788. }
  9789. //头等舱
  9790. if (_EnterExitCosts.SumTDC == 1)
  9791. {
  9792. airTotalStr.AppendFormat($"{_EnterExitCosts.OutsideTDPay:#0.00} 元/人(头等舱)");
  9793. airPriceStr.AppendFormat($"{_EnterExitCosts.AirTD:#0.00} 元/人(头等舱)");
  9794. cityTrafficLabel.AppendFormat("头等舱:{0:#0.00} 元/人 ", _EnterExitCosts.CityTranffic2);
  9795. }
  9796. //描述
  9797. var remarkLable = new StringBuilder();
  9798. //第二项描述
  9799. remarkLable.Append("备注:");
  9800. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) remarkLable.AppendFormat(_EnterExitCosts.TwoItemRemark);
  9801. //汇率描述
  9802. if (peiceItemCurrencyInfos.Any())
  9803. {
  9804. remarkLable.AppendLine();
  9805. remarkLable.AppendFormat("汇率描述:");
  9806. foreach (var item in peiceItemCurrencyInfos)
  9807. {
  9808. remarkLable.AppendFormat($"{item.CurrencyName}({item.CurrencyCode}):{item.Rate:#0.0000} ");
  9809. }
  9810. }
  9811. dic.Add("AirTotalStr", airTotalStr.ToString());
  9812. dic.Add("AirPriceStr", airPriceStr.ToString());
  9813. dic.Add("CityTranffic", cityTrafficLabel.ToString());
  9814. dic.Add("TwoItemRemark", remarkLable.ToString());
  9815. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  9816. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  9817. int table1Row = 0,
  9818. table2Row = 0,
  9819. table3Row = 0,
  9820. table4Row = 0,
  9821. table5Row = 0;
  9822. //住宿费
  9823. if (_EnterExitCosts.ChoiceThree == 1)
  9824. {
  9825. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  9826. table1Row = dac1.Count;
  9827. #region 填充word表格内容
  9828. for (int i = 0; i < dac1.Count; i++)
  9829. {
  9830. Grp_DayAndCost dac = dac1[i];
  9831. if (dac == null) continue;
  9832. builder.MoveToCell(0, i, 0, 0);
  9833. builder.Write("第" + dac.Days.ToString() + "晚:");
  9834. builder.MoveToCell(0, i, 1, 0);
  9835. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  9836. //builder.Write(dac.Place == null ? "" : dac.Place);
  9837. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9838. builder.MoveToCell(0, i, 2, 0);
  9839. builder.Write("费用标准:");
  9840. string curr = "";
  9841. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9842. if (currData != null)
  9843. {
  9844. curr = currData.Name;
  9845. }
  9846. builder.MoveToCell(0, i, 3, 0);
  9847. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9848. builder.MoveToCell(0, i, 4, 0);
  9849. builder.Write("费用小计:");
  9850. builder.MoveToCell(0, i, 5, 0);
  9851. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9852. }
  9853. #endregion
  9854. }
  9855. else dic.Add("SubZS", "0.00");
  9856. //删除多余行
  9857. while (table1.Rows.Count > table1Row)
  9858. {
  9859. table1.Rows.RemoveAt(table1Row);
  9860. }
  9861. //伙食费
  9862. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  9863. if (_EnterExitCosts.ChoiceFour == 1)
  9864. {
  9865. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  9866. table2Row = dac2.Count;
  9867. #region 填充word表格内容
  9868. for (int i = 0; i < dac2.Count; i++)
  9869. {
  9870. Grp_DayAndCost dac = dac2[i];
  9871. if (dac == null) continue;
  9872. builder.MoveToCell(1, i, 0, 0);
  9873. builder.Write("第" + dac.Days.ToString() + "天:");
  9874. builder.MoveToCell(1, i, 1, 0);
  9875. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9876. builder.MoveToCell(1, i, 2, 0);
  9877. builder.Write("费用标准:");
  9878. string curr = "";
  9879. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9880. if (currData != null)
  9881. {
  9882. curr = currData.Name;
  9883. }
  9884. builder.MoveToCell(1, i, 3, 0);
  9885. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9886. builder.MoveToCell(1, i, 4, 0);
  9887. builder.Write("费用小计:");
  9888. builder.MoveToCell(1, i, 5, 0);
  9889. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9890. }
  9891. #endregion
  9892. }
  9893. else dic.Add("SubHS", "0.00");
  9894. //删除多余行
  9895. while (table2.Rows.Count > table2Row)
  9896. {
  9897. table2.Rows.RemoveAt(table2Row);
  9898. }
  9899. //公杂费
  9900. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  9901. if (_EnterExitCosts.ChoiceFive == 1)
  9902. {
  9903. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  9904. table3Row = dac3.Count;
  9905. #region 填充word表格内容
  9906. for (int i = 0; i < dac3.Count; i++)
  9907. {
  9908. Grp_DayAndCost dac = dac3[i];
  9909. if (dac == null) continue;
  9910. builder.MoveToCell(2, i, 0, 0);
  9911. builder.Write("第" + dac.Days.ToString() + "天:");
  9912. builder.MoveToCell(2, i, 1, 0);
  9913. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9914. builder.MoveToCell(2, i, 2, 0);
  9915. builder.Write("费用标准:");
  9916. string curr = "";
  9917. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9918. if (currData != null)
  9919. {
  9920. curr = currData.Name;
  9921. }
  9922. builder.MoveToCell(2, i, 3, 0);
  9923. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9924. builder.MoveToCell(2, i, 4, 0);
  9925. builder.Write("费用小计:");
  9926. builder.MoveToCell(2, i, 5, 0);
  9927. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9928. }
  9929. //删除多余行
  9930. while (table3.Rows.Count > table3Row)
  9931. {
  9932. table3.Rows.RemoveAt(table3Row);
  9933. }
  9934. #endregion
  9935. }
  9936. else dic.Add("SubGZF", "0.00");
  9937. //删除多余行
  9938. while (table3.Rows.Count > table3Row)
  9939. {
  9940. table3.Rows.RemoveAt(table3Row);
  9941. }
  9942. //培训费
  9943. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  9944. if (_EnterExitCosts.ChoiceSix == 1)
  9945. {
  9946. string pxStr = $"六、培训费合计: {tainFeeTotal:#0.00} 元/人";
  9947. dic.Add("SubPX", pxStr);
  9948. table4Row = dac4.Count;
  9949. #region 填充word表格内容
  9950. for (int i = 0; i < dac4.Count; i++)
  9951. {
  9952. Grp_DayAndCost dac = dac4[i];
  9953. if (dac == null) continue;
  9954. builder.MoveToCell(3, i, 0, 0);
  9955. builder.Write("第" + dac.Days.ToString() + "天:");
  9956. builder.MoveToCell(3, i, 1, 0);
  9957. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  9958. builder.MoveToCell(3, i, 2, 0);
  9959. builder.Write("费用标准:");
  9960. string curr = "";
  9961. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  9962. if (currData != null)
  9963. {
  9964. curr = currData.Name;
  9965. }
  9966. builder.MoveToCell(3, i, 3, 0);
  9967. builder.Write(dac.Cost.ToString("#0.00") + curr);
  9968. builder.MoveToCell(3, i, 4, 0);
  9969. builder.Write("费用小计:");
  9970. builder.MoveToCell(3, i, 5, 0);
  9971. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  9972. }
  9973. #endregion
  9974. }
  9975. //else dic.Add("SubPX", $"六、培训费合计: 0.00 元/人");
  9976. //删除多余行
  9977. while (table4.Rows.Count > table4Row)
  9978. {
  9979. table4.Rows.RemoveAt(table4Row);
  9980. }
  9981. //其他费用
  9982. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  9983. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  9984. {
  9985. string qtStr = $"七、其他费用合计: {otherPriceTotal:#0.00} 元/人";
  9986. dic.Add("titleQi", qtStr);
  9987. table5Row = dac5.Count;
  9988. #region 填充word表格内容
  9989. for (int i = 0; i < dac5.Count; i++)
  9990. {
  9991. var dac = dac5[i];
  9992. if (dac == null) continue;
  9993. builder.MoveToCell(4, i, 0, 0);
  9994. builder.Write("第" + dac.Index.ToString() + "项:");
  9995. builder.MoveToCell(4, i, 1, 0);
  9996. builder.Write(dac.itemName);
  9997. builder.MoveToCell(4, i, 2, 0);
  9998. builder.Write("费用标准:");
  9999. builder.MoveToCell(4, i, 3, 0);
  10000. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  10001. builder.MoveToCell(4, i, 4, 0);
  10002. builder.Write("费用小计:");
  10003. builder.MoveToCell(4, i, 5, 0);
  10004. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  10005. builder.MoveToCell(4, i, 6, 0);
  10006. builder.Write("备注:");
  10007. builder.MoveToCell(4, i, 7, 0);
  10008. builder.Write(dac.Remark);
  10009. }
  10010. #endregion
  10011. }
  10012. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  10013. //删除多余行
  10014. while (table5.Rows.Count > table5Row)
  10015. {
  10016. table5.Rows.RemoveAt(table5Row);
  10017. }
  10018. //加上其他费用
  10019. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  10020. decimal subJJC = 0.00M,
  10021. subGWC = 0.00M,
  10022. subTDC = 0.00M;
  10023. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  10024. string totalLabel = string.Format("全部费用总计:");
  10025. //经济舱
  10026. if (_EnterExitCosts.SumJJC == 1)
  10027. {
  10028. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  10029. totalLabel += $"{subJJC:#0.00} 元/人(经济舱)";
  10030. }
  10031. //公务舱
  10032. if (_EnterExitCosts.SumGWC == 1)
  10033. {
  10034. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  10035. totalLabel += $"{subGWC:#0.00} 元/人(公务舱)";
  10036. }
  10037. //头等舱
  10038. if (_EnterExitCosts.SumTDC == 1)
  10039. {
  10040. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  10041. totalLabel += $"{subTDC:#0.00} 元/人(头等舱)";
  10042. }
  10043. //TotalLabel
  10044. dic.Add("TotalLabel", totalLabel);
  10045. //dic.Add("SubJJC", subJJC.ToString("#0.00"));
  10046. //dic.Add("SubGWC", subGWC.ToString("#0.00"));
  10047. //dic.Add("SubTDC", subTDC.ToString("#0.00"));
  10048. #region 填充word模板书签内容
  10049. foreach (var key in dic.Keys)
  10050. {
  10051. Bookmark bookmark = doc.Range.Bookmarks[key];
  10052. if (bookmark != null)
  10053. {
  10054. builder.MoveToBookmark(key);
  10055. builder.Write(dic[key]);
  10056. }
  10057. }
  10058. #endregion
  10059. #region 设置页眉
  10060. string userLabel = string.Empty;
  10061. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  10062. if (currUserInfo != null)
  10063. {
  10064. var userInfo = await _usersRep.GetUserBriefInfo(currUserInfo.UserId);
  10065. if (userInfo != null)
  10066. {
  10067. string ext = string.IsNullOrEmpty(userInfo.ExtensionNumber) ? "-" : userInfo.ExtensionNumber;
  10068. //userLabel = $"联系人:{userInfo.Name} 职位:{userInfo.Job}\r\n座机/分机号:{ext} 手机号:{userInfo.Tel} 公司邮箱:{userInfo.Email}";
  10069. userLabel = $"联系人:{userInfo.Name} 职 位:{userInfo.Job} 手机号:{userInfo.Tel}\r\n公司邮箱:{userInfo.Email}";
  10070. }
  10071. }
  10072. //设置页脚
  10073. //GeneralMethod.AsposeWordSetFooter(builder, userLabel, "华文仿宋", 10);
  10074. #endregion
  10075. var guid = CommonFun.GUID.Substring(0, 8);
  10076. //文件名
  10077. string strFileName = CommonFun.ValidFileName($"{_DelegationInfo.TeamName}出入境费用{guid}.docx");
  10078. AsposeHelper.removewatermark_v2180();
  10079. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10080. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10081. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10082. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10083. }
  10084. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  10085. {
  10086. //获取模板
  10087. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  10088. //载入模板
  10089. var doc = new Document(tempPath);
  10090. var builder = new DocumentBuilder(doc);
  10091. var dic = new Dictionary<string, string>();
  10092. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  10093. {
  10094. var list = new List<string>();
  10095. try
  10096. {
  10097. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  10098. foreach (var item in spilitArr)
  10099. {
  10100. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  10101. var depCode = spDotandEmpty[2].Substring(0, 3);
  10102. var arrCode = spDotandEmpty[2].Substring(3, 3);
  10103. string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  10104. arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  10105. list.Add(depName);
  10106. list.Add(arrName);
  10107. }
  10108. list = list.Distinct().ToList();
  10109. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  10110. }
  10111. catch (Exception)
  10112. {
  10113. dic.Add("ReturnCode", "行程录入不正确!");
  10114. }
  10115. }
  10116. else
  10117. {
  10118. dic.Add("ReturnCode", "未录入行程!");
  10119. }
  10120. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  10121. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10122. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10123. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  10124. {
  10125. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10126. dic.Add("Day", sp.Days.ToString());
  10127. }
  10128. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10129. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  10130. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  10131. //dic.Add("Names", Names);
  10132. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10133. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10134. decimal dac1totalPrice = 0.00M;
  10135. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  10136. foreach (var dac in dac1)
  10137. {
  10138. if (dac.SubTotal == 0.00M)
  10139. {
  10140. continue;
  10141. }
  10142. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  10143. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  10144. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10145. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  10146. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  10147. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  10148. builder.Write(currency);//币种
  10149. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  10150. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10151. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  10152. builder.Write("");//人数
  10153. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  10154. builder.Write("");//天数
  10155. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  10156. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10157. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  10158. decimal rate = 0.00M;
  10159. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  10160. builder.Write(rate.ToString("#0.0000"));//汇率
  10161. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10162. decimal rbmPrice = dac.SubTotal;
  10163. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10164. accommodationStartIndex++;
  10165. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  10166. }
  10167. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10168. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  10169. {
  10170. table1.Rows.RemoveAt(i - 1);
  10171. foodandotherStartIndex--;
  10172. }
  10173. if (dac2.Count == dac3.Count)//国家 币种 金额
  10174. {
  10175. for (int i = 0; i < dac2.Count; i++)
  10176. {
  10177. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10178. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10179. }
  10180. }
  10181. decimal dac2totalPrice = 0.00M;
  10182. foreach (var dac in dac2)
  10183. {
  10184. if (dac.SubTotal == 0)
  10185. {
  10186. continue;
  10187. }
  10188. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  10189. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  10190. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  10191. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  10192. builder.Write(currency);//币种
  10193. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  10194. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10195. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  10196. builder.Write("");//人数
  10197. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  10198. builder.Write("");//天数
  10199. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  10200. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10201. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  10202. decimal rate = 0.00M;
  10203. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  10204. builder.Write(rate.ToString("#0.0000"));//汇率
  10205. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  10206. decimal rbmPrice = dac.SubTotal;
  10207. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10208. foodandotherStartIndex++;
  10209. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  10210. }
  10211. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  10212. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  10213. {
  10214. table1.Rows.RemoveAt(i - 1);
  10215. }
  10216. var cityTrafficLabel = new StringBuilder()
  10217. .AppendFormat(" 经济舱:{0:#0.00} 元", _EnterExitCosts.CityTranffic)
  10218. .AppendFormat(" 公务舱:{0:#0.00} 元", _EnterExitCosts.CityTranffic1)
  10219. .AppendFormat(" 头等舱:{0:#0.00} ", _EnterExitCosts.CityTranffic2)
  10220. .ToString();
  10221. dic.Add("CityTranffic", cityTrafficLabel);
  10222. string otherFeeStr = "";
  10223. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00} 元,";
  10224. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00} 元,";
  10225. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00} 元,";
  10226. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  10227. foreach (var otherInfo in dac5)
  10228. {
  10229. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  10230. }
  10231. #endregion
  10232. if (otherFeeStr.Length > 0)
  10233. {
  10234. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  10235. otherFeeStr = $"({otherFeeStr})";
  10236. dic.Add("OtherFeeStr", otherFeeStr);
  10237. }
  10238. //总计
  10239. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  10240. //国际旅费
  10241. string outsideAir = string.Empty;
  10242. string allPriceAir = string.Empty;
  10243. if (_EnterExitCosts.SumJJC == 1)
  10244. {
  10245. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  10246. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  10247. }
  10248. if (_EnterExitCosts.SumGWC == 1)
  10249. {
  10250. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  10251. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10252. }
  10253. if (_EnterExitCosts.SumTDC == 1)
  10254. {
  10255. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  10256. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  10257. }
  10258. dic.Add("InTravelPrice", $"({outsideAir})");
  10259. dic.Add("FinalSumPrice", $"({allPriceAir})");
  10260. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  10261. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  10262. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  10263. foreach (var key in dic.Keys)
  10264. {
  10265. builder.MoveToBookmark(key);
  10266. builder.Write(dic[key]);
  10267. }
  10268. //模板文件名
  10269. string strFileName = $"{_DelegationInfo.TeamName}因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10270. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10271. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10272. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10273. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10274. }
  10275. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  10276. {
  10277. //获取模板
  10278. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  10279. //载入模板
  10280. var designer = new WorkbookDesigner
  10281. {
  10282. Workbook = new Workbook(tempPath)
  10283. };
  10284. var dic = new Dictionary<string, string>();
  10285. if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  10286. {
  10287. var list = new List<string>();
  10288. try
  10289. {
  10290. var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  10291. foreach (var item in spilitArr)
  10292. {
  10293. var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  10294. var depCode = spDotandEmpty[2].Substring(0, 3);
  10295. var arrCode = spDotandEmpty[2].Substring(3, 3);
  10296. string depName = threeCodes.Find(it => it.Three.Equals(depCode))?.City ?? "Unknwon",
  10297. arrName = threeCodes.Find(it => it.Three.Equals(arrCode))?.City ?? "Unknown";
  10298. list.Add(depName);
  10299. list.Add(arrName);
  10300. }
  10301. list = list.Distinct().ToList();
  10302. dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  10303. }
  10304. catch (Exception)
  10305. {
  10306. dic.Add("ReturnCode", "行程录入不正确!");
  10307. }
  10308. }
  10309. else
  10310. {
  10311. dic.Add("ReturnCode", "未录入行程!");
  10312. }
  10313. dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  10314. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10315. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10316. if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  10317. {
  10318. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10319. dic.Add("Day", sp.Days.ToString());
  10320. }
  10321. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10322. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  10323. var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  10324. designer.SetDataSource("ClientUnit", _DelegationInfo.ClientUnit);
  10325. designer.SetDataSource("VisitCountry", _DelegationInfo.VisitCountry);
  10326. designer.SetDataSource("Group", _DelegationInfo.TeamName);
  10327. designer.SetDataSource("ClientUnitTitle", _DelegationInfo.TeamName);
  10328. designer.SetDataSource("Name", Names);
  10329. designer.SetDataSource("VisitStartDate", dic["VisitStartDate"] + "-" + dic["VisitEndDate"]);
  10330. designer.SetDataSource("Day", dic["Day"] + "天");
  10331. designer.SetDataSource("ReturnCode", dic["ReturnCode"]);
  10332. designer.SetDataSource("ReturnCodeAir", dic["ReturnCodeAir"]);
  10333. int startIndex = 10;
  10334. const int startIndexcopy = 10;
  10335. if (dac2.Count == dac3.Count)//国家 币种 金额
  10336. {
  10337. for (int i = 0; i < dac2.Count; i++)
  10338. {
  10339. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10340. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10341. }
  10342. }
  10343. var dtdac1 = new DataTable();
  10344. var place = new List<string>();
  10345. dtdac1.Columns.AddRange(new DataColumn[] {
  10346. new(){ ColumnName = "city"},
  10347. new(){ ColumnName = "curr"},
  10348. new(){ ColumnName = "criterion"},
  10349. new(){ ColumnName = "number",DataType = typeof(int)},
  10350. new(){ ColumnName = "day",DataType = typeof(int)},
  10351. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  10352. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  10353. new(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  10354. });
  10355. var dtdac2 = new DataTable();
  10356. dtdac2.Columns.AddRange(new DataColumn[] {
  10357. new(){ ColumnName = "city"},
  10358. new(){ ColumnName = "curr"},
  10359. new(){ ColumnName = "criterion"},
  10360. new(){ ColumnName = "number",DataType = typeof(int)},
  10361. new(){ ColumnName = "day",DataType = typeof(int)},
  10362. new(){ ColumnName = "cost", DataType = typeof(decimal)},
  10363. new(){ ColumnName = "rate", DataType = typeof(decimal) },
  10364. new(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  10365. });
  10366. dtdac1.TableName = "tb1";
  10367. dtdac2.TableName = "tb2";
  10368. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  10369. foreach (var item in dac1)
  10370. {
  10371. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  10372. if (place.Contains(item.Place))
  10373. {
  10374. continue;
  10375. }
  10376. DataRow row = dtdac1.NewRow();
  10377. row["city"] = item.Place;
  10378. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10379. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10380. row["curr"] = currency;
  10381. row["rate"] = rate.ToString("#0.0000");
  10382. row["criterion"] = item.Cost.ToString("#0.00");
  10383. row["number"] = 1;
  10384. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10385. //row["costRMB"] = rbmPrice;
  10386. dtdac1.Rows.Add(row);
  10387. place.Add(item.Place);
  10388. }
  10389. place = new List<string>();
  10390. foreach (var item in dac2)
  10391. {
  10392. item.Place = GetEnterExitCostExportCity(placeData, item.NationalTravelFeeId);
  10393. if (place.Contains(item.Place))
  10394. {
  10395. continue;
  10396. }
  10397. DataRow row = dtdac2.NewRow();
  10398. row["city"] = item.Place;
  10399. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  10400. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10401. row["curr"] = currency;
  10402. row["rate"] = rate.ToString("#0.0000");
  10403. row["criterion"] = item.Cost.ToString("#0.00");
  10404. row["number"] = 1;
  10405. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  10406. //row["cost"] = item.SubTotal;
  10407. //row["costRMB"] = rbmPrice;
  10408. dtdac2.Rows.Add(row);
  10409. place.Add(item.Place);
  10410. //dac2totalPrice += rbmPrice;
  10411. }
  10412. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  10413. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  10414. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10415. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  10416. var cityTrafficLabel = new StringBuilder()
  10417. .AppendFormat(" 其中:国外城市间")
  10418. .AppendFormat(" 经济舱费:{0:#0.00} 元、", _EnterExitCosts.CityTranffic)
  10419. .AppendFormat(" 公务舱费:{0:#0.00} 元、", _EnterExitCosts.CityTranffic1)
  10420. .AppendFormat(" 头等舱费:{0:#0.00} 元", _EnterExitCosts.CityTranffic2)
  10421. .ToString();
  10422. //decimal cityTraffic =_EnterExitCosts.CityTranffic + _EnterExitCosts.CityTranffic1 + _EnterExitCosts.CityTranffic2;
  10423. designer.SetDataSource("cityTranffic", cityTrafficLabel);
  10424. // designer.SetDataSource("sumCityTranffic", @$"{cityTraffic:#0.00} ");
  10425. string cell4Str1 = string.Empty;
  10426. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  10427. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  10428. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  10429. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  10430. string cellStr = $" 5.其他费用(";
  10431. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  10432. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  10433. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  10434. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  10435. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  10436. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  10437. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  10438. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  10439. foreach (var otherInfo in dac5)
  10440. {
  10441. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  10442. }
  10443. #endregion
  10444. if (cellStr.Length > 8)
  10445. {
  10446. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  10447. }
  10448. cellStr += ")";
  10449. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  10450. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  10451. decimal pxFee = dac4.Sum(it => it.Cost);
  10452. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  10453. string celllastStr1 = "";
  10454. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  10455. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  10456. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  10457. celllastStr1 += $",国际旅费 元";
  10458. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  10459. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  10460. designer.SetDataSource("cell4Str", cell4Str);
  10461. designer.SetDataSource("cellStr", cellStr);
  10462. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  10463. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  10464. designer.SetDataSource("celllastStr", celllastStr);
  10465. Workbook wb = designer.Workbook;
  10466. var sheet = wb.Worksheets[0];
  10467. //绑定datatable数据集
  10468. designer.SetDataSource(dtdac1);
  10469. designer.SetDataSource(dtdac2);
  10470. designer.Process();
  10471. var rowStart = dtdac1.Rows.Count;
  10472. while (rowStart > 0)
  10473. {
  10474. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  10475. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10476. startIndex++;
  10477. rowStart--;
  10478. }
  10479. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  10480. startIndex += 1; //总计行
  10481. rowStart = dtdac2.Rows.Count;
  10482. while (rowStart > 0)
  10483. {
  10484. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  10485. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  10486. startIndex++;
  10487. rowStart--;
  10488. }
  10489. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  10490. wb.CalculateFormula(true);
  10491. //模板文件名
  10492. string strFileName = $"{_DelegationInfo.TeamName}-四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  10493. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10494. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10495. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10496. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10497. }
  10498. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  10499. {
  10500. //获取模板
  10501. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  10502. //载入模板
  10503. var doc = new Document(tempPath);
  10504. var builder = new DocumentBuilder(doc);
  10505. var dic = new Dictionary<string, string>
  10506. {
  10507. { "GroupName", _DelegationInfo.TeamName },
  10508. { "ClientUnit", _DelegationInfo.ClientUnit }
  10509. };
  10510. string missionLeader = ""; //团负责人默认接团客户名单第一个人
  10511. string missionLeaderJob = "";//负责人job
  10512. //int groupNumber = 0; //团人数
  10513. if (DeleClientList.Count > 0)
  10514. {
  10515. missionLeader = DeleClientList[0]?.Name ?? "";
  10516. missionLeaderJob = DeleClientList[0]?.Job ?? "";
  10517. }
  10518. dic.Add("MissionLeader", missionLeader); //团负责人
  10519. dic.Add("MissionLeaderJob", missionLeaderJob); //团负责人job
  10520. dic.Add("GroupNumber", _DelegationInfo.VisitPNumber.ToString()); //团人数
  10521. #region MyRegion
  10522. //if (blackCode != null && !string.IsNullOrWhiteSpace(blackCode.BlackCode))
  10523. //{
  10524. // List<string> list = new List<string>();
  10525. // try
  10526. // {
  10527. // var spilitArr = Regex.Split(blackCode.BlackCode, "\r\n");
  10528. // foreach (var item in spilitArr)
  10529. // {
  10530. // var spDotandEmpty = item.Split('.')[1].Split(' ').Where(x => !string.IsNullOrEmpty(x)).ToList();
  10531. // var depCode = spDotandEmpty[2].Substring(0, 3);
  10532. // var arrCode = spDotandEmpty[2].Substring(3, 3);
  10533. // string depName = threeCodes.Find(it => it.Three.Equals(depCode)).City,
  10534. // arrName = threeCodes.Find(it => it.Three.Equals(arrCode)).City;
  10535. // list.Add(depName);
  10536. // list.Add(arrName);
  10537. // }
  10538. // list = list.Distinct().ToList();
  10539. // dic.Add("ReturnCode", string.Join("-", list).TrimEnd('-'));
  10540. // }
  10541. // catch (Exception)
  10542. // {
  10543. // dic.Add("ReturnCode", "行程录入不正确!");
  10544. // }
  10545. //}
  10546. //else
  10547. //{
  10548. // dic.Add("ReturnCode", "未录入行程!");
  10549. //}
  10550. List<string> countrys = _groupRepository.GroupSplitCountry(_DelegationInfo.VisitCountry);
  10551. dic.Add("ReturnCode", string.Join("、", countrys));
  10552. #endregion
  10553. //dic.Add("ReturnCodeAir", dic["ReturnCode"]);
  10554. //dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10555. //dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10556. //if (dic.ContainsKey("VisitStartDate") && dic.ContainsKey("VisitEndDate"))
  10557. //{
  10558. // TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10559. // dic.Add("Day", sp.Days.ToString());
  10560. //}
  10561. dic.Add("Day", _DelegationInfo.VisitDays.ToString());
  10562. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  10563. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10564. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10565. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10566. //培训人员名单
  10567. int cultivateRowIndex = 7;
  10568. foreach (var item in DeleClientList)
  10569. {
  10570. builder.MoveToCell(0, cultivateRowIndex, 0, 0);
  10571. builder.Write(item.Name);
  10572. builder.MoveToCell(0, cultivateRowIndex, 1, 0);
  10573. builder.Write(item.Sex == 0 ? "男" : item.Sex == 1 ? "女" : "");
  10574. builder.MoveToCell(0, cultivateRowIndex, 2, 0);
  10575. string birthDay = "";
  10576. if (item.Birthday != null)
  10577. {
  10578. DateTime dt = Convert.ToDateTime(item.Birthday);
  10579. birthDay = $"{dt.Year}.{dt.Month}";
  10580. }
  10581. builder.Write(birthDay);
  10582. builder.MoveToCell(0, cultivateRowIndex, 3, 0);
  10583. builder.Write(item.Company);
  10584. builder.MoveToCell(0, cultivateRowIndex, 4, 0);
  10585. builder.Write(item.Job);
  10586. cultivateRowIndex++;
  10587. }
  10588. //删除多余行
  10589. //cultivateRowIndex -= 2;
  10590. int delRows = 10 + 7 - cultivateRowIndex;
  10591. if (delRows > 0)
  10592. {
  10593. for (int i = 0; i < delRows; i++)
  10594. {
  10595. table1.Rows.RemoveAt(cultivateRowIndex);
  10596. //cultivateRowIndex++;
  10597. }
  10598. }
  10599. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  10600. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  10601. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  10602. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  10603. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  10604. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  10605. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  10606. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  10607. //decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  10608. decimal cityTranfficFeeToatal = 0.00M;
  10609. //dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));
  10610. //其他费用
  10611. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  10612. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  10613. //其他费用合计
  10614. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  10615. decimal _jjcFeeToatal = _EnterExitCosts.OutsideJJPay + _otherFeeTotal; //经济舱
  10616. decimal _gwcFeeToatal = _EnterExitCosts.OutsideGWPay + _otherFeeTotal; //公务舱
  10617. //公务舱合计
  10618. //国际旅费
  10619. //string outsideJJ = "";
  10620. //string allPriceJJ = "";
  10621. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  10622. {
  10623. dic.Add("AirFeeTotal", _EnterExitCosts.OutsideJJPay.ToString("#0.00"));
  10624. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  10625. }
  10626. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  10627. {
  10628. dic.Add("AirFeeTotal", _EnterExitCosts.OutsideGWPay.ToString("#0.00"));
  10629. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  10630. }
  10631. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  10632. {
  10633. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.OutsideJJPay:#0.00} 公务舱:{_EnterExitCosts.OutsideGWPay:#0.00}");
  10634. dic.Add("AirFeeTotal", airFeeTotalStr);
  10635. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  10636. dic.Add("FeeTotal", feeTotalStr);
  10637. }
  10638. foreach (var key in dic.Keys)
  10639. {
  10640. builder.MoveToBookmark(key);
  10641. builder.Write(dic[key]);
  10642. }
  10643. //模板文件名
  10644. string strFileName = $"{_DelegationInfo.TeamName}-成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  10645. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10646. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10647. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10648. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10649. }
  10650. }
  10651. else if (dto.ExportType == 2) //表格
  10652. {
  10653. //利用键值对存放数据
  10654. Dictionary<string, string> dic = new Dictionary<string, string>();
  10655. dic.Add("VisitStartDate", _DelegationInfo.VisitStartDate.ToString("yyyy年MM月dd日"));
  10656. dic.Add("VisitEndDate", _DelegationInfo.VisitEndDate.ToString("yyyy年MM月dd日"));
  10657. TimeSpan sp = _DelegationInfo.VisitEndDate.Subtract(_DelegationInfo.VisitStartDate);
  10658. dic.Add("Day", sp.Days.ToString());
  10659. dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  10660. if (dto.SubTypeId == 1008) //1008(派员单位出(境)任务和预算审批意见表)
  10661. {
  10662. //获取模板
  10663. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/派员单位出(境)任务和预算审批意见表.docx");
  10664. //载入模板
  10665. var doc = new Document(tempPath);
  10666. var builder = new DocumentBuilder(doc);
  10667. dic.Add("TeamName", _DelegationInfo.TeamName);
  10668. dic.Add("ClientUnit", _DelegationInfo.ClientUnit);
  10669. //dic.Add("TellPhone", _DelegationInfo.TellPhone);
  10670. string missionLeaderName = "",
  10671. missionLeaderJob = "";
  10672. if (DeleClientList.Count > 0)
  10673. {
  10674. missionLeaderName = DeleClientList[0].Name;
  10675. missionLeaderJob = DeleClientList[0].Job;
  10676. }
  10677. dic.Add("MissionLeaderName", missionLeaderName);
  10678. dic.Add("MissionLeaderJob", missionLeaderJob);
  10679. dic.Add("VisitPNumber", _DelegationInfo.VisitPNumber.ToString());
  10680. dic.Add("VisitPurpose", _DelegationInfo.VisitPurpose);
  10681. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10682. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10683. int rowCount = 10;//总人数行
  10684. int startRowIndex = 7; //起始行
  10685. for (int i = 0; i < DeleClientList.Count; i++)
  10686. {
  10687. builder.MoveToCell(0, startRowIndex, 0, 0);
  10688. builder.Write(DeleClientList[i].Name); //出国人员姓名
  10689. builder.MoveToCell(0, startRowIndex, 1, 0);
  10690. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  10691. builder.Write(sex);//性别
  10692. builder.MoveToCell(0, startRowIndex, 2, 0);
  10693. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));//出生年月
  10694. builder.MoveToCell(0, startRowIndex, 3, 0);
  10695. builder.Write(DeleClientList[i].Company);//工作单位
  10696. builder.MoveToCell(0, startRowIndex, 4, 0);
  10697. builder.Write(DeleClientList[i].Job);//职务及级别
  10698. builder.MoveToCell(0, startRowIndex, 5, 0);
  10699. builder.Write("");//人员属性
  10700. builder.MoveToCell(0, startRowIndex, 6, 0);
  10701. builder.Write("");//上次出国时间
  10702. startRowIndex++;
  10703. }
  10704. int nullRow = rowCount - DeleClientList.Count;//空行
  10705. for (int i = 0; i < nullRow; i++)
  10706. {
  10707. table1.Rows.Remove(table1.Rows[startRowIndex]);
  10708. }
  10709. foreach (var key in dic.Keys)
  10710. {
  10711. builder.MoveToBookmark(key);
  10712. builder.Write(dic[key]);
  10713. }
  10714. //模板文件名
  10715. string strFileName = $"派员单位出(境)任务和预算审批意见表.docx";
  10716. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10717. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10718. if (dto.PortType == 1) return Ok(JsonView(true, "成功", new { Url = url }));
  10719. else if (dto.PortType == 2 || dto.PortType == 3) return Ok(JsonView(true, "成功", url));
  10720. }
  10721. else if (dto.SubTypeId == 1009)//1009(省级单位出(境)经费报销单)
  10722. {
  10723. //获取模板
  10724. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/省级单位出(境)经费报销单.docx");
  10725. //载入模板
  10726. var doc = new Document(tempPath);
  10727. var builder = new DocumentBuilder(doc);
  10728. dic.Add("GroupClient", _DelegationInfo.ClientUnit);
  10729. var Names = string.Join("、", DeleClientList.Select(x => x.Name)).TrimEnd('、');
  10730. dic.Add("Names", Names);
  10731. int accommodationRows = 12;
  10732. //int foodandotherRows = 12;
  10733. var Dac1currCn = dac1.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  10734. var Dac2currCn = dac2.GroupBy(x => x.Currency).Select(x => x.Key).ToList();
  10735. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10736. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  10737. int accommodationStartIndex = 6;
  10738. decimal dac1totalPrice = 0.00M;
  10739. foreach (var dac in dac1)
  10740. {
  10741. if (dac.SubTotal == 0)
  10742. {
  10743. continue;
  10744. }
  10745. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  10746. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  10747. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10748. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  10749. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  10750. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  10751. builder.Write(currency);//币种
  10752. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  10753. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10754. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  10755. builder.Write("");//人数
  10756. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  10757. builder.Write("");//天数
  10758. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  10759. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10760. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  10761. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10762. builder.Write(rate.ToString("#0.0000"));//汇率
  10763. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10764. decimal rbmPrice = rate * dac.SubTotal;
  10765. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10766. accommodationStartIndex++;
  10767. dac1totalPrice += rbmPrice;
  10768. }
  10769. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  10770. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  10771. builder.Write("小计");
  10772. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  10773. builder.Write(dac1totalPrice.ToString("#0.00"));
  10774. accommodationStartIndex++;
  10775. int nullRow = accommodationRows - dac1.Count;
  10776. //删除空行
  10777. //if (nullRow > 0)
  10778. //{
  10779. // int rowIndex = accommodationStartIndex;
  10780. // for (int i = 0; i < nullRow; i++)
  10781. // {
  10782. // Aspose.Words.Tables.Row row = table1.Rows[rowIndex];
  10783. // row.Remove();
  10784. // rowIndex++;
  10785. // }
  10786. //}
  10787. if (dac2.Count == dac3.Count)//国家 币种 金额
  10788. {
  10789. for (int i = 0; i < dac2.Count; i++)
  10790. {
  10791. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  10792. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  10793. }
  10794. }
  10795. int foodandotherStartIndex = 19;//
  10796. decimal dac2totalPrice = 0.00M;
  10797. foreach (var dac in dac2)
  10798. {
  10799. if (dac.SubTotal == 0)
  10800. {
  10801. continue;
  10802. }
  10803. //foodandotherStartIndex = 12;
  10804. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  10805. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));//城市
  10806. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  10807. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknwon";
  10808. builder.Write(currency);//币种
  10809. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  10810. builder.Write(dac.Cost.ToString("#0.00"));//标准
  10811. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  10812. builder.Write("");//人数
  10813. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  10814. builder.Write("");//天数
  10815. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  10816. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  10817. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  10818. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  10819. builder.Write(rate.ToString("#0.0000"));//汇率
  10820. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  10821. decimal rbmPrice = rate * dac.SubTotal;
  10822. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  10823. foodandotherStartIndex++;
  10824. dac2totalPrice += rbmPrice;
  10825. }
  10826. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  10827. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  10828. //删除空行
  10829. //if (dac2.Count < foodandotherRows)
  10830. //{
  10831. // while (table2.Rows.Count > dac2.Count)
  10832. // {
  10833. // table2.Rows.RemoveAt(dac2.Count);
  10834. // }
  10835. //}
  10836. var citytrafficLable = new StringBuilder()
  10837. .AppendFormat($"经济舱费用:{_EnterExitCosts.CityTranffic:#0.00} 元、")
  10838. .AppendFormat($"公务舱费用:{_EnterExitCosts.CityTranffic1:#0.00}元、")
  10839. .AppendFormat($"头等舱费用:{_EnterExitCosts.CityTranffic2:#0.00}")
  10840. .ToString();
  10841. dic.Add("CityTranffic", citytrafficLable);
  10842. string otherFeeStr = "";
  10843. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  10844. if (_EnterExitCosts.YiMiao > 0) otherFeeStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  10845. if (_EnterExitCosts.HeSuan > 0) otherFeeStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  10846. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  10847. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  10848. if (_EnterExitCosts.Service > 0) otherFeeStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  10849. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  10850. foreach (var otherInfo in dac5)
  10851. {
  10852. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  10853. }
  10854. #endregion
  10855. if (otherFeeStr.Length > 0)
  10856. {
  10857. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  10858. otherFeeStr = $"({otherFeeStr})";
  10859. dic.Add("OtherFeeStr", otherFeeStr);
  10860. }
  10861. foreach (var key in dic.Keys)
  10862. {
  10863. builder.MoveToBookmark(key);
  10864. builder.Write(dic[key]);
  10865. }
  10866. //模板文件名
  10867. string strFileName = $"省级单位出(境)经费报销单{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  10868. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10869. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10870. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10871. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10872. }
  10873. }
  10874. else if (dto.ExportType == 3)
  10875. {
  10876. if (dto.SubTypeId == 1) //团组成员名单
  10877. {
  10878. if (!DeleClientList.Any()) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成员暂未录入!!!", ""));
  10879. //获取模板
  10880. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/dwon_团组人员列表模板.doc");
  10881. //载入模板
  10882. var doc = new Document(tempPath);
  10883. var builder = new DocumentBuilder(doc);
  10884. //获取word里所有表格
  10885. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  10886. //获取所填表格的序数
  10887. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  10888. var rowStart = tableOne.Rows[0]; //获取第1行
  10889. //循环赋值
  10890. for (int i = 0; i < DeleClientList.Count; i++)
  10891. {
  10892. builder.MoveToCell(0, i + 1, 0, 0);
  10893. builder.Write(DeleClientList[i].Name);
  10894. builder.MoveToCell(0, i + 1, 1, 0);
  10895. string sex = DeleClientList[i].Sex == 0 ? "男" : DeleClientList[i].Sex == 1 ? "女" : "";
  10896. builder.Write(sex);
  10897. builder.MoveToCell(0, i + 1, 2, 0);
  10898. builder.Write(Convert.ToDateTime(DeleClientList[i].Birthday).ToString("yyyy年MM月dd日"));
  10899. builder.MoveToCell(0, i + 1, 3, 0);
  10900. builder.Write(DeleClientList[i].Company);
  10901. builder.MoveToCell(0, i + 1, 4, 0);
  10902. builder.Write(DeleClientList[i].Job);
  10903. }
  10904. //删除多余行
  10905. while (tableOne.Rows.Count > DeleClientList.Count + 1)
  10906. {
  10907. tableOne.Rows.RemoveAt(DeleClientList.Count + 1);
  10908. }
  10909. string strFileName = $"{_DelegationInfo.TeamName}组团人员名单({DateTime.Now.ToString("yyyyMMddHHmmss")}).doc";
  10910. //C:/Server/File/OA2023/Office/Word/EnterExitCost/File/
  10911. //C:\Server\File\OA2023\Office\Word\EnterExitCost\File\
  10912. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  10913. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  10914. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  10915. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  10916. }
  10917. }
  10918. return Ok(JsonView(400, "操作失败!", ""));
  10919. }
  10920. catch (Exception ex)
  10921. {
  10922. return Ok(JsonView(400, ex.Message, ""));
  10923. }
  10924. }
  10925. /// <summary>
  10926. /// 获取三公费用标准city
  10927. /// </summary>
  10928. /// <param name="placeData"></param>
  10929. /// <param name="nationalTravelFeeId"></param>
  10930. /// <returns></returns>
  10931. private static string GetEnterExitCostExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  10932. {
  10933. string _city = string.Empty;
  10934. if (placeData.Count < 1) return _city;
  10935. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  10936. if (data == null) return _city;
  10937. string country = data.Country;
  10938. string city = data.City;
  10939. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  10940. else _city = city;
  10941. return _city;
  10942. }
  10943. ///// <summary>
  10944. ///// 团组模块 - 出入境费用 - 明细表导出
  10945. ///// </summary>
  10946. ///// <returns></returns>
  10947. //[HttpPost]
  10948. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10949. //public async Task<IActionResult> PostEnterExitCostExportDetailsList(EnterExitCostOperateDto dto)
  10950. //{
  10951. // var data = await _enterExitCostRep.PostEnterExitCostOperate(dto);
  10952. // if (data.Code != 0)
  10953. // {
  10954. // return Ok(JsonView(false, data.Msg));
  10955. // }
  10956. // return Ok(JsonView(true, data.Msg, data.Data));
  10957. //}
  10958. /// <summary>
  10959. /// 团组模块 - 出入境费用 - 一键清空
  10960. /// </summary>
  10961. /// <returns></returns>
  10962. [HttpPost]
  10963. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  10964. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10965. public async Task<IActionResult> PostEnterExitCostOneClickClear(EnterExitCostOneClickClearDto dto)
  10966. {
  10967. if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数;"));
  10968. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  10969. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  10970. var _view = await _enterExitCostRep.OneClickClear(dto.Id, dto.DiId, dto.UserId);
  10971. await _sqlSugar.Updateable<Grp_DayOtherPrice>()
  10972. .Where(x => x.Diid == dto.DiId && x.IsDel == 0)
  10973. .SetColumns(x => new Grp_DayOtherPrice
  10974. {
  10975. IsDel = 1,
  10976. DeleteUserId = dto.UserId,
  10977. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  10978. })
  10979. .ExecuteCommandAsync();
  10980. if (_view.Code == 0)
  10981. {
  10982. return Ok(JsonView(true, "操作成功"));
  10983. }
  10984. return Ok(JsonView(false, "操作失败"));
  10985. }
  10986. /// <summary>
  10987. /// 团组模块 - 出入境费用 - 子项删除
  10988. /// </summary>
  10989. /// <returns></returns>
  10990. [HttpPost]
  10991. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  10992. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  10993. public async Task<IActionResult> PostEnterExitCostSubItemDel(EnterExitCostSubItemDelDto dto)
  10994. {
  10995. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  10996. if (data.Code != 0)
  10997. {
  10998. return Ok(JsonView(false, data.Msg));
  10999. }
  11000. return Ok(JsonView(true, "操作成功!", data.Data));
  11001. }
  11002. /// <summary>
  11003. /// 删除三公其他费用
  11004. /// </summary>
  11005. /// <param name="dto"></param>
  11006. /// <returns></returns>
  11007. [HttpPost]
  11008. //[ApiLog("Grp_EnterExitCost", OperationEnum.Del)]
  11009. public IActionResult DeleteOtherExpenses(EnterExitCostSubItemDelDto dto)
  11010. {
  11011. var jw = JsonView(false, "删除失败!");
  11012. var data = new Grp_DayOtherPrice()
  11013. {
  11014. Id = dto.Id,
  11015. IsDel = 1,
  11016. DeleteUserId = dto.DeleteUserId,
  11017. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  11018. };
  11019. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  11020. if (del > 0)
  11021. {
  11022. jw.Code = 200;
  11023. jw.Msg = "删除成功!";
  11024. }
  11025. return Ok(jw);
  11026. }
  11027. /// <summary>
  11028. /// 团组模块 - 出入境国家费用标准 List
  11029. /// </summary>
  11030. /// <returns></returns>
  11031. [HttpPost]
  11032. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11033. public async Task<IActionResult> GetNationalTravelFeeData(NationalTravelFeeDataDto dto)
  11034. {
  11035. int provinceId = dto.ProvinceId;
  11036. if (provinceId < 1) provinceId = 122; //默认四川省数据
  11037. var nftData = await _sqlSugar
  11038. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, c) => new JoinQueryInfos(
  11039. JoinType.Left, ntf.Currency == sd1.Id,
  11040. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  11041. JoinType.Left, ntf.ProvinceId == c.Id
  11042. ))
  11043. .Where((ntf, sd1, u, c) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  11044. .Select((ntf, sd1, u, c) => new NationalTravelFeeInfoView
  11045. {
  11046. Id = ntf.Id,
  11047. ProvinceId = ntf.ProvinceId,
  11048. ProvinceName = c.Name_CN,
  11049. Continent = ntf.Continent,
  11050. Country = ntf.Country,
  11051. City = ntf.City,
  11052. Currency = ntf.Currency,
  11053. CurrencyCode = sd1.Name,
  11054. CurrencyName = sd1.Remark,
  11055. RoomCost = ntf.RoomCost,
  11056. FoodCost = ntf.FoodCost,
  11057. PublicCost = ntf.PublicCost,
  11058. LastUpdateUserId = ntf.LastUpdateUserId,
  11059. LastUpdateUserName = u.CnName,
  11060. LastUpdateTime = ntf.LastUpdateTime
  11061. })
  11062. .ToListAsync();
  11063. return Ok(JsonView(true, "查询成功!", nftData));
  11064. }
  11065. /// <summary>
  11066. /// 团组模块 - 出入境国家费用标准 Page List Data Source
  11067. /// </summary>
  11068. /// <returns></returns>
  11069. [HttpPost]
  11070. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11071. public async Task<IActionResult> GetNationalTravelFeePageDataSource()
  11072. {
  11073. string sql = string.Format(@"Select * From Grp_NationalTravelFee Where Isdel = 0 ");
  11074. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<Grp_NationalTravelFee>(sql).ToListAsync();
  11075. List<string> countryData = new List<string>();
  11076. countryData.AddRange(nationalTravelFeeData.Select(it => it.Country!).ToList());
  11077. countryData = countryData.Distinct().ToList();
  11078. List<dynamic> dataSource = new List<dynamic>();
  11079. foreach (var item in countryData)
  11080. {
  11081. var cityData1 = new List<string>();
  11082. cityData1 = nationalTravelFeeData.Where(it => it.Country == item).Select(it => it.City ?? "").ToList();
  11083. var countryData2 = new
  11084. {
  11085. CountryName = item,
  11086. CityData = cityData1
  11087. };
  11088. if (!dataSource.Contains(countryData2))
  11089. {
  11090. dataSource.Add(countryData2);
  11091. }
  11092. }
  11093. return Ok(JsonView(true, "查询成功!", dataSource));
  11094. }
  11095. /// <summary>
  11096. /// 团组模块 - 出入境国家费用标准 Page List
  11097. /// </summary>
  11098. /// <returns></returns>
  11099. [HttpPost]
  11100. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11101. public async Task<IActionResult> PostNationalTravelFeePage(NationalTravelFeePageDto dto)
  11102. {
  11103. int portId = dto.PortType,
  11104. pageIndex = dto.PageIndex,
  11105. pageSize = dto.PageSize;
  11106. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  11107. if (pageIndex == 0) pageIndex = 1;
  11108. if (pageSize == 0) pageSize = 10;
  11109. RefAsync<int> total = 0;
  11110. var nationalTravelFeeData = await _sqlSugar
  11111. .Queryable<Grp_NationalTravelFee, Sys_SetData, Sys_Users, Sys_Cities>((ntf, sd1, u, sd2) => new JoinQueryInfos(
  11112. JoinType.Left, ntf.Currency == sd1.Id,
  11113. JoinType.Left, ntf.LastUpdateUserId == u.Id,
  11114. JoinType.Left, ntf.ProvinceId == sd2.Id
  11115. ))
  11116. .Where((ntf, sd1, u, sd2) => ntf.IsDel == 0)
  11117. .WhereIF(dto.ProvinceId > 0, (ntf, sd1, u, sd2) => ntf.ProvinceId == dto.ProvinceId)
  11118. .WhereIF(!string.IsNullOrEmpty(dto.Country), (ntf, sd1, u, sd2) => ntf.Country.Contains(dto.Country))
  11119. .WhereIF(!string.IsNullOrEmpty(dto.City), (ntf, sd1, u, sd2) => ntf.City.Contains(dto.City))
  11120. .OrderByDescending((ntf, sd1, u, sd2) => ntf.LastUpdateTime)
  11121. .Select((ntf, sd1, u, sd2) => new NationalTravelFeePageInfoView
  11122. {
  11123. RowNumber = SqlFunc.RowNumber($"{ntf.LastUpdateTime} Desc"),
  11124. Id = ntf.Id,
  11125. ProvinceId = ntf.ProvinceId,
  11126. ProvinceName = sd2.Name_CN,
  11127. Continent = ntf.Continent,
  11128. Country = ntf.Country,
  11129. City = ntf.City,
  11130. Currency = ntf.Currency,
  11131. CurrencyCode = sd1.Name,
  11132. CurrencyName = sd1.Remark,
  11133. RoomCost = ntf.RoomCost,
  11134. FoodCost = ntf.FoodCost,
  11135. PublicCost = ntf.PublicCost,
  11136. LastUpdateUserId = ntf.LastUpdateUserId,
  11137. LastUpdateUserName = u.CnName,
  11138. LastUpdateTime = ntf.LastUpdateTime,
  11139. Remark = ntf.Remark
  11140. })
  11141. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  11142. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData, (int)total));
  11143. }
  11144. /// <summary>
  11145. /// 团组模块 - 出入境国家费用标准 根据城市查询
  11146. /// </summary>
  11147. /// <returns></returns>
  11148. [HttpPost]
  11149. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11150. public async Task<IActionResult> PostNationalTravelFeeInfoByCountryAndCity(NationalTravelFeeByCountryAndCityDto dto)
  11151. {
  11152. if (dto == null) return Ok(JsonView(false, "请传入参数!"));
  11153. int portId = dto.PortType;
  11154. if (portId != 1 && portId != 2 && portId != 3) return Ok(JsonView(false, "请输入正确的端口号!\r\n请求端口分类1 Web 2 Android 3 IOS"));
  11155. string whereSql = string.Empty;
  11156. if (!string.IsNullOrEmpty(dto.Country))
  11157. {
  11158. whereSql = string.Format(@"And Country = '{0}' ", dto.Country);
  11159. }
  11160. if (!string.IsNullOrEmpty(dto.City))
  11161. {
  11162. whereSql = string.Format(@"And City = '{0}' ", dto.City);
  11163. }
  11164. string sql = string.Format(@"Select gntf.Country,gntf.City,gntf.Currency,ssd.Name as CurrencyCode,
  11165. ssd.Remark as CurrencyName,gntf.RoomCost,gntf.FoodCost,gntf.PublicCost,gntf.TrainCost,
  11166. gntf.LastUpdateUserId,su.CnName as LastUpdateUserName,gntf.LastUpdateTime
  11167. From Grp_NationalTravelFee gntf
  11168. Left Join Sys_SetData ssd On ssd.STid = 66 And gntf.Currency = ssd.Id
  11169. Left Join Sys_Users su On gntf.LastUpdateUserId = su.Id
  11170. Where gntf.Isdel = 0 {0} ", whereSql);
  11171. var nationalTravelFeeData = await _groupRepository._sqlSugar.SqlQueryable<NationalTravelFeeInfoByCountryAndCityView>(sql).FirstAsync();
  11172. return Ok(JsonView(true, "查询成功!", nationalTravelFeeData));
  11173. }
  11174. /// <summary>
  11175. /// 团组模块 - 出入境国家费用标准 - Add Or Update
  11176. /// </summary>
  11177. /// <returns></returns>
  11178. [HttpPost]
  11179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11180. public async Task<IActionResult> PostNationalTravelFeeOperate(NationalTravelFeeOperateDto dto)
  11181. {
  11182. return Ok(await _enterExitCostRep.PostNationalTravelFeeOperate(dto));
  11183. }
  11184. /// <summary>
  11185. /// 团组模块 - 出入境国家费用标准 - Del
  11186. /// </summary>
  11187. /// <returns></returns>
  11188. [HttpPost]
  11189. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11190. public async Task<IActionResult> PostNationalTravelFeeDel(NationalTravelFeeDelDto dto)
  11191. {
  11192. Grp_NationalTravelFee _nationalTravelFee = new Grp_NationalTravelFee()
  11193. {
  11194. Id = dto.Id,
  11195. DeleteUserId = dto.DeleteUserId,
  11196. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  11197. IsDel = 1
  11198. };
  11199. var delStatus = await _enterExitCostRep._sqlSugar.Updateable<Grp_NationalTravelFee>(_nationalTravelFee)
  11200. .UpdateColumns(it => new { it.DeleteTime, it.DeleteUserId, it.IsDel })
  11201. .WhereColumns(it => new { it.Id })
  11202. .ExecuteCommandAsync();
  11203. if (delStatus <= 0)
  11204. {
  11205. return Ok(JsonView(false, "删除失败!"));
  11206. }
  11207. return Ok(JsonView(true, "操作成功!"));
  11208. }
  11209. /// <summary>
  11210. /// 团组模块 - 出入境国家费用标准 - 费用导入收款账单
  11211. /// 注:Get 请求Headers 加 Token
  11212. /// </summary>
  11213. /// <param name="groupId"></param>
  11214. /// <returns></returns>
  11215. [HttpGet("{groupId}")]
  11216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11217. public async Task<IActionResult> NationalTravelFeeImportReceivables(int groupId)
  11218. {
  11219. var _currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  11220. if (_currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  11221. var data = await GeneralMethod.ReceivablesImportFeeAsync(groupId);
  11222. data.ForEach(x =>
  11223. {
  11224. x.CreateUserId = _currUserInfo.UserId;
  11225. });
  11226. if (data.Any())
  11227. {
  11228. var add = await _sqlSugar.Insertable(data).ExecuteCommandAsync();
  11229. if (add > 0)
  11230. {
  11231. return Ok(JsonView(true, "操作成功!"));
  11232. }
  11233. }
  11234. return Ok(JsonView(false, "未操作!"));
  11235. }
  11236. #endregion
  11237. #region 团组经理模块 出入境费用-草稿
  11238. /// <summary>
  11239. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  11240. /// </summary>
  11241. /// <returns></returns>
  11242. [HttpGet]
  11243. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11244. public async Task<IActionResult> EnterExitDraftProvBelongCostDataSource()
  11245. {
  11246. var provData = await _groupRepository.ProvinceBasicSource();
  11247. return Ok(JsonView(true, "查询成功!", provData));
  11248. }
  11249. /// <summary>
  11250. /// 团组模块 - 出入境费用-草稿 - 文件类型list 根据省份Id获取
  11251. /// </summary>
  11252. /// <returns></returns>
  11253. [HttpGet("{provinceId}")]
  11254. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11255. public async Task<IActionResult> EnterExitCostDraftFileOwner([FromRoute] int provinceId = 122)
  11256. {
  11257. //验证城市归属并给默认值
  11258. if (provinceId < 1) provinceId = 122;
  11259. /*
  11260. * 122 四川
  11261. * 108 贵州
  11262. * 103 重庆
  11263. * 132 云南
  11264. */
  11265. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostDraftRep.FileOwner(provinceId);
  11266. return Ok(JsonView(true, "查询成功!", new
  11267. {
  11268. WordTypeData = wordTypeData,
  11269. ExcelTypeData = excelTypeData,
  11270. }));
  11271. }
  11272. /// <summary>
  11273. /// 团组模块 - 出入境费用-草稿 - 基础数据源(团组名称/币种类型)
  11274. /// </summary>
  11275. /// <returns></returns>
  11276. [HttpPost]
  11277. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11278. public async Task<IActionResult> EnterExitCostDraftDataSource(EnterExitCostDraftDataSourceDto dto)
  11279. {
  11280. var draftNameDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  11281. .Where(x => x.IsDel == 0)
  11282. .OrderByDescending(x => x.CreateTime)
  11283. .Select(x => new { x.Id, x.DraftName })
  11284. .ToListAsync();
  11285. string sql = string.Format("Select * From Sys_SetData Where IsDel = 0");
  11286. //SetDataInfoView
  11287. var dataSource = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  11288. var currencyData = dataSource.Where(it => it.STid == 66).ToList(); //所有币种
  11289. var _CurrencyData = _mapper.Map<List<SetDataInfoView>>(currencyData);
  11290. int provinceId = dto.ProvinceId;
  11291. if (provinceId < 1) provinceId = 122;
  11292. /*
  11293. * 122 四川
  11294. * 108 贵州
  11295. * 103 重庆
  11296. * 132 云南
  11297. */
  11298. (SetDataInfoView[] wordTypeData, SetDataInfoView[] excelTypeData) = await _enterExitCostRep.FileOwner(provinceId);
  11299. //默认币种显示
  11300. var _currencyInfos = await GeneralMethod.EnterExitCostInitRate();
  11301. var viewPermissionData = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  11302. return Ok(JsonView(true, "查询成功!", new
  11303. {
  11304. DraftNameDatas = draftNameDatas,
  11305. CurrencyData = _CurrencyData,
  11306. WordTypeData = wordTypeData,
  11307. ExcelTypeData = excelTypeData,
  11308. CurrencyInit = _currencyInfos,
  11309. ViewPermissionData = viewPermissionData
  11310. }));
  11311. }
  11312. /// <summary>
  11313. /// 团组模块 - 出入境费用-草稿
  11314. /// 实时汇率 tips
  11315. /// 机票费用 tips
  11316. /// </summary>
  11317. /// <returns></returns>
  11318. [HttpPost]
  11319. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11320. public async Task<IActionResult> EnterExitCostDraftCorrelationTips(EnterExitCostDraftCorrelationTipsDto dto)
  11321. {
  11322. //var airData = await _ticketBlackCodeRep.EntryAndExitTips(dto.DiId);
  11323. return Ok(JsonView(true, "查询成功!", new
  11324. {
  11325. //GroupNameData = groupNameData.Data,
  11326. //visaData = visaData.Data,
  11327. //airData = airData.Data,
  11328. reteInfos = await GeneralMethod.EnterExitCostLiveRate()
  11329. }));
  11330. }
  11331. /// <summary>
  11332. /// 团组模块 - 出入境费用-草稿
  11333. /// 签证费用 tips
  11334. /// </summary>
  11335. /// <returns></returns>
  11336. [HttpPost]
  11337. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11338. public async Task<IActionResult> EnterExitCostDraftVisaTips(EnterExitCostDraftVisaTipsDto dto)
  11339. {
  11340. //if (dto.DraftId < 1) return Ok(JsonView(false,MsgTips.Id));
  11341. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  11342. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  11343. .Select(x => x.NationalTravelFeeId)
  11344. .Distinct()
  11345. .ToListAsync();
  11346. //if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11347. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  11348. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  11349. .Select(x => x.Country)
  11350. .Distinct()
  11351. .ToArrayAsync();
  11352. //if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  11353. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  11354. return Ok(JsonView(true, "查询成功!", new
  11355. {
  11356. totalAmt,
  11357. remark
  11358. }));
  11359. }
  11360. /// <summary>
  11361. /// 团组模块 - 出入境费用-草稿 - Info
  11362. /// </summary>
  11363. /// <returns></returns>
  11364. [HttpPost]
  11365. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Details)]
  11366. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11367. public async Task<IActionResult> EnterExitCostDraftInfoById(EnterExitCostDraftInfoByIdDto dto)
  11368. {
  11369. return Ok(await _enterExitCostDraftRep.EnterExitCostDraftInfoById(dto));
  11370. }
  11371. /// <summary>
  11372. /// 团组模块 - 出入境费用-草稿 - 设置view权限
  11373. /// </summary>
  11374. /// <returns></returns>
  11375. [HttpPost]
  11376. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11377. public async Task<IActionResult> EnterExitCostDraftSetViewPermissiion(EnterExitCostDraftSetViewPermissiionDto dto)
  11378. {
  11379. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  11380. if (dto.DraftId < 1) return Ok(JsonView(false, "请传入有效的DraftId;"));
  11381. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  11382. var permissions = new List<Grp_EnterExitCostDraftPermission>();
  11383. foreach (var userId in dto.UserIds)
  11384. {
  11385. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  11386. }
  11387. if (permissions.Any())
  11388. {
  11389. _sqlSugar.BeginTran();
  11390. try
  11391. {
  11392. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  11393. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  11394. if (result < 1)
  11395. {
  11396. _sqlSugar.RollbackTran();
  11397. return Ok(JsonView(false));
  11398. }
  11399. }
  11400. catch (Exception ex)
  11401. {
  11402. _sqlSugar.RollbackTran();
  11403. return Ok(JsonView(false, ex.Message));
  11404. }
  11405. _sqlSugar.CommitTran();
  11406. return Ok(JsonView(true));
  11407. }
  11408. return Ok(JsonView(false));
  11409. }
  11410. /// <summary>
  11411. /// 团组模块 - 出入境费用-草稿 - Add And Update
  11412. /// </summary>
  11413. /// <returns></returns>
  11414. [HttpPost]
  11415. [ApiLog("Grp_EnterExitCostDraft", OperationEnum.Add)]
  11416. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11417. public async Task<IActionResult> EnterExitCostDraftOp(EnterExitCostDraftOpDto dto)
  11418. {
  11419. var data = await _enterExitCostDraftRep.EnterExitCostDraftOp(dto);
  11420. if (data.Code != 0)
  11421. {
  11422. return Ok(JsonView(false, data.Msg));
  11423. }
  11424. int sign = (int)data.Data.GetType().GetProperty("sign").GetValue(data.Data, null);
  11425. //汇率信息记录
  11426. await GeneralMethod.RateRecordSave(dto.UserId, sign, "出入境费用");
  11427. return Ok(JsonView(true, data.Msg, data.Data));
  11428. }
  11429. /// <summary>
  11430. /// 团组模块 - 出入境费用-草稿 - File downlaod
  11431. /// </summary>
  11432. /// <param name="dto"></param>
  11433. /// <returns></returns>
  11434. [HttpPost]
  11435. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Download)]
  11436. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  11437. public async Task<IActionResult> EnterExitCostDraftDownload(EnterExitCostDraftDownloadDto dto)
  11438. {
  11439. try
  11440. {
  11441. var id = dto.Id;
  11442. if (id < 1) return Ok(JsonView(400, "请传入有效的DiId参数;", ""));
  11443. if (dto.ExportType < 1) return Ok(JsonView(400, "请传入有效的ExportType参数; 1 明细表 2 表格", ""));
  11444. if (dto.SubTypeId < 1) return Ok(JsonView(400, @"请传入有效的SubTypeId参数;
  11445. 1 明细表 --> 1005(默认明细表) 1006(因公出国(境)经费测算明细表) 1007(四川省商务厅出国经费财政先行审核表)
  11446. 2 表格 --> 1008(派员单位出(境)任务和预算审批意见表) 1009(省级单位出(境)经费报销单)
  11447. 3 团组成员名单 1 团组成员名单", ""));
  11448. var _EnterExitCosts = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(it => it.IsDel == 0 && it.Id == id).OrderByDescending(x => x.CreateTime).First();
  11449. if (_EnterExitCosts == null) return Ok(JsonView(400, "未填写出入境费用-草稿;", ""));
  11450. var _DayAndCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(it => it.IsDel == 0 && it.ParentId == id).ToList();
  11451. var countryIds = _DayAndCosts.Select(x => x.NationalTravelFeeId).ToList();
  11452. var nationalTravelFeeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0 && countryIds.Contains(it.Id)).ToList();
  11453. var enterExitCostCurrencys = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(_EnterExitCosts.CurrencyRemark);
  11454. //数据源
  11455. var dac1 = _DayAndCosts.Where(it => it.Type == 1).ToList(); //住宿费
  11456. var dac2 = _DayAndCosts.Where(it => it.Type == 2).ToList(); //伙食费
  11457. var dac3 = _DayAndCosts.Where(it => it.Type == 3).ToList(); //公杂费
  11458. var dac4 = _DayAndCosts.Where(it => it.Type == 4).ToList(); //培训费
  11459. var dac5 = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  11460. .LeftJoin<Sys_SetData>((x, a) => a.IsDel == 0 && a.Id == x.SetDataId)
  11461. .LeftJoin<Sys_SetData>((x, a, b) => b.IsDel == 0 && b.Id == x.Currency)
  11462. .Where((x, a, b) => x.IsDel == 0 && x.ParentId == id)
  11463. .Select((x, a, b) => new
  11464. {
  11465. x.Index,
  11466. itemName = a.Name,
  11467. CurrencyStr = b.Name,
  11468. x.Cost,
  11469. x.SubTotal,
  11470. x.Remark
  11471. })
  11472. .OrderBy((x) => x.Index)
  11473. .ToList(); //其他款项费用
  11474. var _CurrDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  11475. var peiceItemCurrencys = new List<string>();
  11476. if (_DayAndCosts.Any())
  11477. {
  11478. var currencyIds = _DayAndCosts.Select(x => x.Currency).Distinct().ToList();
  11479. if (currencyIds.Any()) peiceItemCurrencys.AddRange(_CurrDatas.Where(x => currencyIds.Contains(x.Id)).Select(x => x.Name).ToList());
  11480. }
  11481. if (dac5.Any()) peiceItemCurrencys.AddRange(dac5.Select(x => x.CurrencyStr).Distinct().ToList());
  11482. var peiceItemCurrencyInfos = new List<CurrencyInfo>();
  11483. if (enterExitCostCurrencys.Any() && peiceItemCurrencys.Any())
  11484. {
  11485. peiceItemCurrencyInfos = enterExitCostCurrencys.Where(x => peiceItemCurrencys.Contains(x.CurrencyCode)).ToList();
  11486. }
  11487. var threeCodes = _sqlSugar.Queryable<Res_ThreeCode>().Where(it => it.IsDel == 0).ToList();
  11488. var placeData = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(it => it.IsDel == 0).ToList();
  11489. var rateDatas = await _EnterExitCosts.CurrencyRemark.SplitExchangeRate();
  11490. if (dto.ExportType == 1) //明细表
  11491. {
  11492. if (dto.SubTypeId == 1005) //1005(默认明细表)
  11493. {
  11494. //获取模板
  11495. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/出入境费用表模板.docx");
  11496. //载入模板
  11497. Document doc = new Document(tempPath);
  11498. DocumentBuilder builder = new DocumentBuilder(doc);
  11499. //利用键值对存放数据
  11500. Dictionary<string, string> dic = new Dictionary<string, string>();
  11501. decimal stayFeeTotal = _EnterExitCosts.ChoiceThree == 1 ? _DayAndCosts.Where(it => it.Type == 1).Sum(it => it.SubTotal) : 0.00M; // 住宿费
  11502. decimal mealsFeeTotal = _EnterExitCosts.ChoiceFour == 1 ? _DayAndCosts.Where(it => it.Type == 2).Sum(it => it.SubTotal) : 0.00M; // 伙食费费
  11503. decimal miscellaneousFeeTotal = _EnterExitCosts.ChoiceFive == 1 ? _DayAndCosts.Where(it => it.Type == 3).Sum(it => it.SubTotal) : 0.00M; // 公杂费
  11504. decimal tainFeeTotal = _EnterExitCosts.ChoiceSix == 1 ? _DayAndCosts.Where(it => it.Type == 4).Sum(it => it.SubTotal) : 0.00M; // 培训费
  11505. decimal otherPriceTotal = _EnterExitCosts.OtherExpenses_Checked == 1 ? dac5.Sum(x => x.SubTotal) : 0.00M; //其他费用
  11506. decimal insidePayTotal = _EnterExitCosts.ChoiceOne == 1 ? _EnterExitCosts.InsidePay : 0.00M;
  11507. //境内费用(其他费用)
  11508. if (_EnterExitCosts.ChoiceOne == 1)
  11509. {
  11510. string row1_1 = "";
  11511. if (_EnterExitCosts.Visa > 0)
  11512. {
  11513. //insidePayTotal += _EnterExitCosts.Visa;
  11514. row1_1 = $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 人民币/人";
  11515. //if (!string.IsNullOrEmpty(_EnterExitCosts.VisaRemark))
  11516. //{
  11517. // row1_1 += $"\t签证费用描述: {_EnterExitCosts.VisaRemark} 人民币/人";
  11518. //}
  11519. }
  11520. string row1_2 = "";
  11521. if (_EnterExitCosts.YiMiao > 0)
  11522. {
  11523. //insidePayTotal += _EnterExitCosts.YiMiao;
  11524. row1_2 += $"疫苗费:{_EnterExitCosts.YiMiao.ToString("#0.00")} 人民币/人";
  11525. }
  11526. if (_EnterExitCosts.HeSuan > 0)
  11527. {
  11528. //insidePayTotal += _EnterExitCosts.HeSuan;
  11529. row1_2 += $"核酸检测费:{_EnterExitCosts.HeSuan.ToString("#0.00")} 人民币/人";
  11530. }
  11531. if (_EnterExitCosts.Service > 0)
  11532. {
  11533. //insidePayTotal += _EnterExitCosts.Service;
  11534. row1_2 += $"服务费:{_EnterExitCosts.Service.ToString("#0.00")} 人民币/人";
  11535. }
  11536. string row1_3 = "";
  11537. if (_EnterExitCosts.Safe > 0)
  11538. {
  11539. //insidePayTotal += _EnterExitCosts.Safe;
  11540. row1_3 += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 人民币/人";
  11541. }
  11542. if (_EnterExitCosts.Ticket > 0)
  11543. {
  11544. //insidePayTotal += _EnterExitCosts.Ticket;
  11545. row1_3 += $"参展门票:{_EnterExitCosts.Ticket.ToString("#0.00")} 人民币/人";
  11546. }
  11547. string row1 = "";
  11548. if (!string.IsNullOrEmpty(row1_1)) row1 += $"{row1_1}\r\n";
  11549. if (!string.IsNullOrEmpty(row1_2)) row1 += $"{row1_2}\r\n";
  11550. if (!string.IsNullOrEmpty(row1_3)) row1 += $"{row1_3}\r\n";
  11551. row1 += $"备注:{_EnterExitCosts.Remark}";
  11552. dic.Add("InsidePay", insidePayTotal.ToString("#0.00"));
  11553. dic.Add("Row1Str", row1);
  11554. }
  11555. string airTotalStr = string.Empty,
  11556. airPriceStr = string.Empty;
  11557. //经济舱
  11558. if (_EnterExitCosts.SumJJC == 1)
  11559. {
  11560. airTotalStr += $"{_EnterExitCosts.OutsideJJPay.ToString("#0.00")}元/人(经济舱)";
  11561. airPriceStr += $"{_EnterExitCosts.AirJJ.ToString("#0.00")}元/人(经济舱)";
  11562. }
  11563. //公务舱
  11564. if (_EnterExitCosts.SumGWC == 1)
  11565. {
  11566. airTotalStr += $" {_EnterExitCosts.OutsideGWPay.ToString("#0.00")} 元/人(公务舱)";
  11567. airPriceStr += $" {_EnterExitCosts.AirGW.ToString("#0.00")} 元/人(公务舱)";
  11568. }
  11569. //头等舱
  11570. if (_EnterExitCosts.SumTDC == 1)
  11571. {
  11572. airTotalStr += $" {_EnterExitCosts.OutsideTDPay.ToString("#0.00")} 元/人(头等舱)";
  11573. airPriceStr += $" {_EnterExitCosts.AirTD.ToString("#0.00")} 元/人(头等舱)";
  11574. }
  11575. //汇率描述
  11576. string rateStr = "";
  11577. if (peiceItemCurrencyInfos.Any())
  11578. {
  11579. rateStr = "\r\n汇率描述:";
  11580. foreach (var item in peiceItemCurrencyInfos)
  11581. {
  11582. rateStr += $"{item.CurrencyName}({item.CurrencyCode}):{item.Rate.ToString("#0.0000")} ";
  11583. }
  11584. }
  11585. string twoItemRemark = "备注:";
  11586. if (!string.IsNullOrEmpty(_EnterExitCosts.TwoItemRemark)) twoItemRemark += _EnterExitCosts.TwoItemRemark;
  11587. if (!string.IsNullOrEmpty(rateStr)) twoItemRemark += rateStr;
  11588. dic.Add("AirTotalStr", airTotalStr);
  11589. dic.Add("AirPriceStr", airPriceStr);
  11590. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  11591. dic.Add("TwoItemRemark", twoItemRemark);
  11592. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11593. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  11594. int table1Row = 0,
  11595. table2Row = 0,
  11596. table3Row = 0,
  11597. table4Row = 0,
  11598. table5Row = 0;
  11599. //住宿费
  11600. if (_EnterExitCosts.ChoiceThree == 1)
  11601. {
  11602. dic.Add("SubZS", stayFeeTotal.ToString("#0.00"));
  11603. table1Row = dac1.Count;
  11604. #region 填充word表格内容
  11605. for (int i = 0; i < dac1.Count; i++)
  11606. {
  11607. var dac = dac1[i];
  11608. if (dac == null) continue;
  11609. builder.MoveToCell(0, i, 0, 0);
  11610. builder.Write("第" + dac.Days.ToString() + "晚:");
  11611. builder.MoveToCell(0, i, 1, 0);
  11612. //builder.Write(placeData.Find(it => it.Id == dac.NationalTravelFeeId)?.Country ?? "Unknown");
  11613. //builder.Write(dac.Place == null ? "" : dac.Place);
  11614. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11615. builder.MoveToCell(0, i, 2, 0);
  11616. builder.Write("费用标准:");
  11617. string curr = "";
  11618. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11619. if (currData != null)
  11620. {
  11621. curr = currData.Name;
  11622. }
  11623. builder.MoveToCell(0, i, 3, 0);
  11624. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11625. builder.MoveToCell(0, i, 4, 0);
  11626. builder.Write("费用小计:");
  11627. builder.MoveToCell(0, i, 5, 0);
  11628. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11629. }
  11630. #endregion
  11631. }
  11632. else dic.Add("SubZS", "0.00");
  11633. //删除多余行
  11634. while (table1.Rows.Count > table1Row)
  11635. {
  11636. table1.Rows.RemoveAt(table1Row);
  11637. }
  11638. //伙食费
  11639. Aspose.Words.Tables.Table table2 = allTables[1] as Aspose.Words.Tables.Table;
  11640. if (_EnterExitCosts.ChoiceFour == 1)
  11641. {
  11642. dic.Add("SubHS", mealsFeeTotal.ToString("#0.00"));
  11643. table2Row = dac2.Count;
  11644. #region 填充word表格内容
  11645. for (int i = 0; i < dac2.Count; i++)
  11646. {
  11647. var dac = dac2[i];
  11648. if (dac == null) continue;
  11649. builder.MoveToCell(1, i, 0, 0);
  11650. builder.Write("第" + dac.Days.ToString() + "天:");
  11651. builder.MoveToCell(1, i, 1, 0);
  11652. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11653. builder.MoveToCell(1, i, 2, 0);
  11654. builder.Write("费用标准:");
  11655. string curr = "";
  11656. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11657. if (currData != null)
  11658. {
  11659. curr = currData.Name;
  11660. }
  11661. builder.MoveToCell(1, i, 3, 0);
  11662. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11663. builder.MoveToCell(1, i, 4, 0);
  11664. builder.Write("费用小计:");
  11665. builder.MoveToCell(1, i, 5, 0);
  11666. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11667. }
  11668. #endregion
  11669. }
  11670. else dic.Add("SubHS", "0.00");
  11671. //删除多余行
  11672. while (table2.Rows.Count > table2Row)
  11673. {
  11674. table2.Rows.RemoveAt(table2Row);
  11675. }
  11676. //公杂费
  11677. Aspose.Words.Tables.Table table3 = allTables[2] as Aspose.Words.Tables.Table;
  11678. if (_EnterExitCosts.ChoiceFive == 1)
  11679. {
  11680. dic.Add("SubGZF", miscellaneousFeeTotal.ToString("#0.00"));
  11681. table3Row = dac3.Count;
  11682. #region 填充word表格内容
  11683. for (int i = 0; i < dac3.Count; i++)
  11684. {
  11685. var dac = dac3[i];
  11686. if (dac == null) continue;
  11687. builder.MoveToCell(2, i, 0, 0);
  11688. builder.Write("第" + dac.Days.ToString() + "天:");
  11689. builder.MoveToCell(2, i, 1, 0);
  11690. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11691. builder.MoveToCell(2, i, 2, 0);
  11692. builder.Write("费用标准:");
  11693. string curr = "";
  11694. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11695. if (currData != null)
  11696. {
  11697. curr = currData.Name;
  11698. }
  11699. builder.MoveToCell(2, i, 3, 0);
  11700. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11701. builder.MoveToCell(2, i, 4, 0);
  11702. builder.Write("费用小计:");
  11703. builder.MoveToCell(2, i, 5, 0);
  11704. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11705. }
  11706. //删除多余行
  11707. while (table3.Rows.Count > table3Row)
  11708. {
  11709. table3.Rows.RemoveAt(table3Row);
  11710. }
  11711. #endregion
  11712. }
  11713. else dic.Add("SubGZF", "0.00");
  11714. //删除多余行
  11715. while (table3.Rows.Count > table3Row)
  11716. {
  11717. table3.Rows.RemoveAt(table3Row);
  11718. }
  11719. //培训费
  11720. Aspose.Words.Tables.Table table4 = allTables[3] as Aspose.Words.Tables.Table;
  11721. if (_EnterExitCosts.ChoiceSix == 1)
  11722. {
  11723. string pxStr = $"六、培训费合计: {tainFeeTotal.ToString("#0.00")} 元/人";
  11724. dic.Add("SubPX", pxStr);
  11725. table4Row = dac4.Count;
  11726. #region 填充word表格内容
  11727. for (int i = 0; i < dac4.Count; i++)
  11728. {
  11729. var dac = dac4[i];
  11730. if (dac == null) continue;
  11731. builder.MoveToCell(3, i, 0, 0);
  11732. builder.Write("第" + dac.Days.ToString() + "天:");
  11733. builder.MoveToCell(3, i, 1, 0);
  11734. builder.Write(GetEnterExitCostDraftExportCity(placeData, dac.NationalTravelFeeId));
  11735. builder.MoveToCell(3, i, 2, 0);
  11736. builder.Write("费用标准:");
  11737. string curr = "";
  11738. var currData = _CurrDatas.Where(it => it.Id == dac.Currency).FirstOrDefault();
  11739. if (currData != null)
  11740. {
  11741. curr = currData.Name;
  11742. }
  11743. builder.MoveToCell(3, i, 3, 0);
  11744. builder.Write(dac.Cost.ToString("#0.00") + curr);
  11745. builder.MoveToCell(3, i, 4, 0);
  11746. builder.Write("费用小计:");
  11747. builder.MoveToCell(3, i, 5, 0);
  11748. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11749. }
  11750. #endregion
  11751. }
  11752. //else dic.Add("SubPX", $"六、培训费合计: 0 元/人");
  11753. //删除多余行
  11754. while (table4.Rows.Count > table4Row)
  11755. {
  11756. table4.Rows.RemoveAt(table4Row);
  11757. }
  11758. //其他费用
  11759. Aspose.Words.Tables.Table table5 = allTables[4] as Aspose.Words.Tables.Table;
  11760. if (_EnterExitCosts.OtherExpenses_Checked == 1)
  11761. {
  11762. string qtStr = $"七、其他费用合计: {otherPriceTotal.ToString("#0.00")} 元/人";
  11763. dic.Add("titleQi", qtStr);
  11764. table5Row = dac5.Count;
  11765. #region 填充word表格内容
  11766. for (int i = 0; i < dac5.Count; i++)
  11767. {
  11768. var dac = dac5[i];
  11769. if (dac == null) continue;
  11770. builder.MoveToCell(4, i, 0, 0);
  11771. builder.Write("第" + dac.Index.ToString() + "项:");
  11772. builder.MoveToCell(4, i, 1, 0);
  11773. builder.Write(dac.itemName);
  11774. builder.MoveToCell(4, i, 2, 0);
  11775. builder.Write("费用标准:");
  11776. builder.MoveToCell(4, i, 3, 0);
  11777. builder.Write(dac.Cost.ToString("#0.00") + dac.CurrencyStr);
  11778. builder.MoveToCell(4, i, 4, 0);
  11779. builder.Write("费用小计:");
  11780. builder.MoveToCell(4, i, 5, 0);
  11781. builder.Write(dac.SubTotal.ToString("#0.00") + "CNY");
  11782. builder.MoveToCell(4, i, 6, 0);
  11783. builder.Write("备注:");
  11784. builder.MoveToCell(4, i, 7, 0);
  11785. builder.Write(dac.Remark);
  11786. }
  11787. #endregion
  11788. }
  11789. //else dic.Add("SubQT", "七、其他费用合计: 0 元/人");
  11790. //删除多余行
  11791. while (table5.Rows.Count > table5Row)
  11792. {
  11793. table5.Rows.RemoveAt(table5Row);
  11794. }
  11795. //加上其他费用
  11796. decimal otherFeeTotal = insidePayTotal + stayFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + tainFeeTotal + otherPriceTotal;
  11797. decimal subJJC = 0.00M,
  11798. subGWC = 0.00M,
  11799. subTDC = 0.00M;
  11800. //全部费用总计: 元 / 人(经济舱) 元 / 人(公务舱) 元 / 人(头等舱)
  11801. string totalLabel = string.Format("全部费用总计:");
  11802. //经济舱
  11803. if (_EnterExitCosts.SumJJC == 1)
  11804. {
  11805. subJJC = otherFeeTotal + _EnterExitCosts.OutsideJJPay;
  11806. totalLabel += $"{subJJC.ToString("#0.00")} 元/人(经济舱)";
  11807. }
  11808. //公务舱
  11809. if (_EnterExitCosts.SumGWC == 1)
  11810. {
  11811. subGWC = otherFeeTotal + _EnterExitCosts.OutsideGWPay;
  11812. totalLabel += $"{subGWC.ToString("#0.00")} 元/人(公务舱)";
  11813. }
  11814. //头等舱
  11815. if (_EnterExitCosts.SumTDC == 1)
  11816. {
  11817. subTDC = otherFeeTotal + _EnterExitCosts.OutsideTDPay;
  11818. totalLabel += $"{subTDC.ToString("#0.00")} 元/人(头等舱)";
  11819. }
  11820. //TotalLabel
  11821. dic.Add("TotalLabel", totalLabel);
  11822. #region 填充word模板书签内容
  11823. foreach (var key in dic.Keys)
  11824. {
  11825. Bookmark bookmark = doc.Range.Bookmarks[key];
  11826. if (bookmark != null)
  11827. {
  11828. builder.MoveToBookmark(key);
  11829. builder.Write(dic[key]);
  11830. }
  11831. }
  11832. #endregion
  11833. //文件名
  11834. string strFileName = $"{_EnterExitCosts.DraftName}_出入境费用-草稿{Guid.NewGuid().ToString()}.docx";
  11835. strFileName = CommonFun.ValidFileName(strFileName);
  11836. AsposeHelper.removewatermark_v2180();
  11837. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  11838. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  11839. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  11840. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  11841. }
  11842. else if (dto.SubTypeId == 1006)//1006(因公出国(境)经费测算明细表)
  11843. {
  11844. //获取模板
  11845. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/因公出国(境)经费测算明细表.docx");
  11846. //载入模板
  11847. Document doc = new Document(tempPath);
  11848. DocumentBuilder builder = new DocumentBuilder(doc);
  11849. Dictionary<string, string> dic = new Dictionary<string, string>();
  11850. string returnCodeLabel = string.Empty;
  11851. if (nationalTravelFeeData.Any())
  11852. {
  11853. List<string> list = new List<string>();
  11854. foreach (var item in nationalTravelFeeData)
  11855. {
  11856. list.Add($"{item.Country}({item.City})");
  11857. }
  11858. list = list.Distinct().ToList();
  11859. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  11860. }
  11861. var countryLabel = string.Empty;
  11862. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  11863. if (countryData.Any())
  11864. {
  11865. countryLabel = string.Join("、", countryData);
  11866. }
  11867. dic.Add("ReturnCodeAir", returnCodeLabel);
  11868. dic.Add("VisitStartDate", "-");
  11869. dic.Add("VisitEndDate", "-");
  11870. dic.Add("Day", "-");
  11871. dic.Add("VisitCountry", countryLabel);
  11872. dic.Add("ClientUnit", "-");
  11873. //var Names = string.Join("、", DeleClientList.Select(it => it.Name).ToList()).TrimEnd('、');
  11874. //dic.Add("Names", Names);
  11875. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  11876. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  11877. decimal dac1totalPrice = 0.00M;
  11878. int accommodationStartIndex = 6, foodandotherStartIndex = 22;
  11879. foreach (var dac in dac1)
  11880. {
  11881. if (dac.SubTotal == 0.00M)
  11882. {
  11883. continue;
  11884. }
  11885. //builder.MoveToCell(0, accommodationStartIndex, 0, 0);
  11886. //builder.Write(DeleClientList[i].LastName + DeleClientList[i].Name);
  11887. builder.MoveToCell(0, accommodationStartIndex, 1, 0);
  11888. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  11889. builder.MoveToCell(0, accommodationStartIndex, 2, 0);
  11890. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  11891. builder.Write(currency);//币种
  11892. builder.MoveToCell(0, accommodationStartIndex, 3, 0);
  11893. builder.Write(dac.Cost.ToString("#0.00"));//标准
  11894. builder.MoveToCell(0, accommodationStartIndex, 4, 0);
  11895. builder.Write("");//人数
  11896. builder.MoveToCell(0, accommodationStartIndex, 5, 0);
  11897. builder.Write("");//天数
  11898. builder.MoveToCell(0, accommodationStartIndex, 6, 0);
  11899. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  11900. builder.MoveToCell(0, accommodationStartIndex, 7, 0);
  11901. decimal rate = 0.00M;
  11902. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  11903. builder.Write(rate.ToString("#0.0000"));//汇率
  11904. builder.MoveToCell(0, accommodationStartIndex, 8, 0);
  11905. decimal rbmPrice = dac.SubTotal;
  11906. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  11907. accommodationStartIndex++;
  11908. dac1totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  11909. }
  11910. dic.Add("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  11911. for (int i = 21; i > (dac1.Count == 0 ? 1 : dac1.Count) + 6; i--)
  11912. {
  11913. table1.Rows.RemoveAt(i - 1);
  11914. foodandotherStartIndex--;
  11915. }
  11916. if (dac2.Count == dac3.Count)//国家 币种 金额
  11917. {
  11918. for (int i = 0; i < dac2.Count; i++)
  11919. {
  11920. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  11921. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  11922. }
  11923. }
  11924. decimal dac2totalPrice = 0.00M;
  11925. foreach (var dac in dac2)
  11926. {
  11927. if (dac.SubTotal == 0)
  11928. {
  11929. continue;
  11930. }
  11931. builder.MoveToCell(0, foodandotherStartIndex, 1, 0);
  11932. builder.Write(GetEnterExitCostExportCity(placeData, dac.NationalTravelFeeId));
  11933. builder.MoveToCell(0, foodandotherStartIndex, 2, 0);
  11934. string currency = _CurrDatas.Find(it => it.Id == dac.Currency)?.Remark ?? "Unknown";
  11935. builder.Write(currency);//币种
  11936. builder.MoveToCell(0, foodandotherStartIndex, 3, 0);
  11937. builder.Write(dac.Cost.ToString("#0.00"));//标准
  11938. builder.MoveToCell(0, foodandotherStartIndex, 4, 0);
  11939. builder.Write("");//人数
  11940. builder.MoveToCell(0, foodandotherStartIndex, 5, 0);
  11941. builder.Write("");//天数
  11942. builder.MoveToCell(0, foodandotherStartIndex, 6, 0);
  11943. builder.Write(dac.SubTotal.ToString("#0.00"));//小计
  11944. builder.MoveToCell(0, foodandotherStartIndex, 7, 0);
  11945. decimal rate = 0.00M;
  11946. rate = rateDatas.Find(it => it.CurrencyName.Equals(currency))?.Rate ?? 0.00M;
  11947. builder.Write(rate.ToString("#0.0000"));//汇率
  11948. builder.MoveToCell(0, foodandotherStartIndex, 8, 0);
  11949. decimal rbmPrice = dac.SubTotal;
  11950. builder.Write(rbmPrice.ToString("#0.00"));//折合人民币
  11951. foodandotherStartIndex++;
  11952. dac2totalPrice += Convert.ToDecimal(rbmPrice.ToString("#0.00"));
  11953. }
  11954. dic.Add("dac2totalPrice", dac2totalPrice.ToString("#0.00"));
  11955. for (int i = foodandotherStartIndex + (15 - dac2.Count); i > (dac2.Count == 0 ? 1 : 0) + foodandotherStartIndex; i--)
  11956. {
  11957. table1.Rows.RemoveAt(i - 1);
  11958. }
  11959. dic.Add("CityTranffic", _EnterExitCosts.CityTranffic.ToString("#0.00"));
  11960. string otherFeeStr = "";
  11961. if (_EnterExitCosts.Visa > 0) otherFeeStr += $"签证费:{_EnterExitCosts.Visa.ToString("#0.00")} 元,";
  11962. if (_EnterExitCosts.Safe > 0) otherFeeStr += $"保险费:{_EnterExitCosts.Safe.ToString("#0.00")} 元,";
  11963. if (_EnterExitCosts.Ticket > 0) otherFeeStr += $"参展门票费:{_EnterExitCosts.Ticket.ToString("#0.00")} 元,";
  11964. #region 其他款项费用 增加位置:模板第6项其他费用字符串追加
  11965. foreach (var otherInfo in dac5)
  11966. {
  11967. otherFeeStr += $"{otherInfo.itemName}:{otherInfo.SubTotal.ToString("#0.00")} 元,";
  11968. }
  11969. #endregion
  11970. if (otherFeeStr.Length > 0)
  11971. {
  11972. otherFeeStr = otherFeeStr.Substring(0, otherFeeStr.Length - 1);
  11973. otherFeeStr = $"({otherFeeStr})";
  11974. dic.Add("OtherFeeStr", otherFeeStr);
  11975. }
  11976. //总计
  11977. decimal allPrice = dac1totalPrice + dac2totalPrice + _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket;
  11978. //国际旅费
  11979. string outsideAir = string.Empty;
  11980. string allPriceAir = string.Empty;
  11981. if (_EnterExitCosts.SumJJC == 1)
  11982. {
  11983. outsideAir += string.Format(@"经济舱:{0} 元/人;", _EnterExitCosts.AirJJ.ToString("#0.00"));
  11984. allPriceAir += string.Format(@"经济舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideJJPay).ToString("#0.00"));
  11985. }
  11986. if (_EnterExitCosts.SumGWC == 1)
  11987. {
  11988. outsideAir += string.Format(@"公务舱:{0} 元/人;", _EnterExitCosts.AirGW.ToString("#0.00"));
  11989. allPriceAir += string.Format(@"公务舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  11990. }
  11991. if (_EnterExitCosts.SumTDC == 1)
  11992. {
  11993. outsideAir += string.Format(@"头等舱:{0} 元/人;", _EnterExitCosts.AirTD.ToString("#0.00"));
  11994. allPriceAir += string.Format(@"头等舱:{0} 元/人;", (allPrice + _EnterExitCosts.OutsideTDPay).ToString("#0.00"));
  11995. }
  11996. dic.Add("InTravelPrice", $"({outsideAir})");
  11997. dic.Add("FinalSumPrice", $"({allPriceAir})");
  11998. //dic.Add("VisaPay", _EnterExitCosts.Visa.ToString("#0.00"));
  11999. //dic.Add("SafePay", _EnterExitCosts.Safe.ToString("#0.00"));
  12000. //dic.Add("YiMiao", _EnterExitCosts.YiMiao.ToString("#0.00"));
  12001. foreach (var key in dic.Keys)
  12002. {
  12003. builder.MoveToBookmark(key);
  12004. builder.Write(dic[key]);
  12005. }
  12006. //模板文件名
  12007. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_因公出国(境)经费测算明细表{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  12008. strFileName = CommonFun.ValidFileName(strFileName);
  12009. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  12010. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  12011. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  12012. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  12013. }
  12014. else if (dto.SubTypeId == 1007) //1007(四川省商务厅出国经费财政先行审核表)
  12015. {
  12016. //获取模板
  12017. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/四川省商务厅出国经费财政先行审核表.xls");
  12018. //载入模板
  12019. WorkbookDesigner designer = new WorkbookDesigner();
  12020. designer.Workbook = new Workbook(tempPath);
  12021. Dictionary<string, string> dic = new Dictionary<string, string>();
  12022. string returnCodeLabel = string.Empty;
  12023. if (nationalTravelFeeData.Any())
  12024. {
  12025. List<string> list = new List<string>();
  12026. foreach (var item in nationalTravelFeeData)
  12027. {
  12028. list.Add($"{item.Country}({item.City})");
  12029. }
  12030. list = list.Distinct().ToList();
  12031. returnCodeLabel = string.Join("-", list).TrimEnd('-');
  12032. }
  12033. var countryLabel = string.Empty;
  12034. var countryData = nationalTravelFeeData.Select(x => x.Country).Distinct().ToList();
  12035. if (countryData.Any())
  12036. {
  12037. countryLabel = string.Join("、", countryData);
  12038. }
  12039. dic.Add("ReturnCodeAir", returnCodeLabel);
  12040. dic.Add("VisitStartDate", "-");
  12041. dic.Add("VisitEndDate", "-");
  12042. dic.Add("Day", "0");
  12043. dic.Add("VisitCountry", countryLabel);
  12044. dic.Add("ClientUnit", "-");
  12045. designer.SetDataSource("ClientUnit", "-");
  12046. designer.SetDataSource("VisitCountry", countryLabel);
  12047. designer.SetDataSource("Group", "-");
  12048. designer.SetDataSource("ClientUnitTitle", "-");
  12049. designer.SetDataSource("Name", "-");
  12050. designer.SetDataSource("VisitStartDate", "-");
  12051. designer.SetDataSource("Day", "0");
  12052. designer.SetDataSource("ReturnCode", returnCodeLabel);
  12053. designer.SetDataSource("ReturnCodeAir", "-");
  12054. int startIndex = 10;
  12055. const int startIndexcopy = 10;
  12056. if (dac2.Count == dac3.Count)//国家 币种 金额
  12057. {
  12058. for (int i = 0; i < dac2.Count; i++)
  12059. {
  12060. dac2[i].SubTotal = dac2[i].SubTotal + dac3[i].SubTotal; //小计
  12061. dac2[i].Cost = dac3[i].Cost + dac2[i].Cost; //标准
  12062. }
  12063. }
  12064. DataTable dtdac1 = new DataTable();
  12065. List<string> place = new List<string>();
  12066. dtdac1.Columns.AddRange(new DataColumn[] {
  12067. new DataColumn(){ ColumnName = "city"},
  12068. new DataColumn(){ ColumnName = "curr"},
  12069. new DataColumn(){ ColumnName = "criterion"},
  12070. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  12071. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  12072. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  12073. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  12074. new DataColumn(){ ColumnName = "costRMB", DataType = typeof(decimal) },
  12075. });
  12076. DataTable dtdac2 = new DataTable();
  12077. dtdac2.Columns.AddRange(new DataColumn[] {
  12078. new DataColumn(){ ColumnName = "city"},
  12079. new DataColumn(){ ColumnName = "curr"},
  12080. new DataColumn(){ ColumnName = "criterion"},
  12081. new DataColumn(){ ColumnName = "number",DataType = typeof(int)},
  12082. new DataColumn(){ ColumnName = "day",DataType = typeof(int)},
  12083. new DataColumn(){ ColumnName = "cost", DataType = typeof(decimal)},
  12084. new DataColumn(){ ColumnName = "rate", DataType = typeof(decimal) },
  12085. new DataColumn(){ ColumnName = "costRMB",DataType = typeof(decimal)},
  12086. });
  12087. dtdac1.TableName = "tb1";
  12088. dtdac2.TableName = "tb2";
  12089. decimal dac1totalPrice = 0.00M, dac2totalPrice = 0.00M;
  12090. foreach (var item in dac1)
  12091. {
  12092. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  12093. if (place.Contains(item.Place))
  12094. {
  12095. continue;
  12096. }
  12097. DataRow row = dtdac1.NewRow();
  12098. row["city"] = item.Place;
  12099. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  12100. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  12101. row["curr"] = currency;
  12102. row["rate"] = rate.ToString("#0.0000");
  12103. row["criterion"] = item.Cost.ToString("#0.00");
  12104. row["number"] = 1;
  12105. row["day"] = dac1.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  12106. //row["costRMB"] = rbmPrice;
  12107. dtdac1.Rows.Add(row);
  12108. place.Add(item.Place);
  12109. }
  12110. place = new List<string>();
  12111. foreach (var item in dac2)
  12112. {
  12113. item.Place = GetEnterExitCostDraftExportCity(placeData, item.NationalTravelFeeId);
  12114. if (place.Contains(item.Place))
  12115. {
  12116. continue;
  12117. }
  12118. DataRow row = dtdac2.NewRow();
  12119. row["city"] = item.Place;
  12120. string currency = _CurrDatas.Find(it => it.Id == item.Currency)?.Remark ?? "Unknwon";
  12121. decimal rate = rateDatas.Find(it => it.CurrencyName == currency)?.Rate ?? 0.00M;
  12122. row["curr"] = currency;
  12123. row["rate"] = rate.ToString("#0.0000");
  12124. row["criterion"] = item.Cost.ToString("#0.00");
  12125. row["number"] = 1;
  12126. row["day"] = dac2.FindAll(x => x.NationalTravelFeeId == item.NationalTravelFeeId).Count;
  12127. //row["cost"] = item.SubTotal;
  12128. //row["costRMB"] = rbmPrice;
  12129. dtdac2.Rows.Add(row);
  12130. place.Add(item.Place);
  12131. //dac2totalPrice += rbmPrice;
  12132. }
  12133. dac1totalPrice = dac1.Sum(it => it.SubTotal);
  12134. dac2totalPrice = dac2.Sum(it => it.SubTotal);
  12135. designer.SetDataSource("dac1totalPrice", dac1totalPrice.ToString("#0.00"));
  12136. designer.SetDataSource("dac2totalPrice", dac2totalPrice);
  12137. designer.SetDataSource("cityTranffic", @$"其中:国外城市间机票费: {_EnterExitCosts.CityTranffic:#0.00} 元");
  12138. designer.SetDataSource("sumCityTranffic", @$"{_EnterExitCosts.CityTranffic:#0.00} ");
  12139. string cell4Str1 = string.Empty;
  12140. if (_EnterExitCosts.SumJJC == 1) cell4Str1 += $"经济舱:{_EnterExitCosts.AirJJ:#0.00} 元/人;";
  12141. if (_EnterExitCosts.SumGWC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirGW:#0.00} 元/人;";
  12142. if (_EnterExitCosts.SumTDC == 1) cell4Str1 += $"公务舱:{_EnterExitCosts.AirTD:#0.00} 元/人;";
  12143. string cell4Str = $" 4.国际旅费:{cell4Str1}";
  12144. string cellStr = $" 5.其他费用(";
  12145. if (_EnterExitCosts.Visa > 0) cellStr += $"签证费:{_EnterExitCosts.Visa:#0.00}元,";
  12146. if (_EnterExitCosts.YiMiao > 0) cellStr += $"疫苗费:{_EnterExitCosts.YiMiao:#0.00}元,";
  12147. if (_EnterExitCosts.HeSuan > 0) cellStr += $"核酸费:{_EnterExitCosts.HeSuan:#0.00}元,";
  12148. if (_EnterExitCosts.Safe > 0) cellStr += $"保险费:{_EnterExitCosts.Safe:#0.00}元,";
  12149. if (_EnterExitCosts.Ticket > 0) cellStr += $"参展门票费:{_EnterExitCosts.Ticket:#0.00}元,";
  12150. if (_EnterExitCosts.Service > 0) cellStr += $"服务费:{_EnterExitCosts.Service:#0.00}元,";
  12151. #region 其他款项费用 增加位置:模板第5项其他费用字符串追加
  12152. var otherPriceTotal = dac5.Sum(x => x.SubTotal);
  12153. foreach (var otherInfo in dac5)
  12154. {
  12155. cellStr += $"{otherInfo.itemName}:{otherInfo.SubTotal:#0.00} 元,";
  12156. }
  12157. #endregion
  12158. if (cellStr.Length > 8)
  12159. {
  12160. cellStr = cellStr.Substring(0, cellStr.Length - 1);
  12161. }
  12162. cellStr += ")";
  12163. decimal otherFee = _EnterExitCosts.Visa + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.Service + otherPriceTotal;
  12164. decimal s = dac1totalPrice + dac2totalPrice + _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay + otherFee;
  12165. decimal pxFee = dac4.Sum(it => it.Cost);
  12166. decimal glvFee = _EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay;
  12167. string celllastStr1 = "";
  12168. if (dac1totalPrice > 0) celllastStr1 += $"住宿费 {dac1totalPrice:#0.00} 元";
  12169. if (dac2totalPrice > 0) celllastStr1 += $",伙食费和公杂费 {dac2totalPrice:#0.00} 元";
  12170. if (pxFee > 0) celllastStr1 += $",培训费 {pxFee:#0.00} 元";
  12171. celllastStr1 += $",国际旅费 元";
  12172. if (otherFee > 0) celllastStr1 += $",其他费用 {otherFee:#0.00} 元";
  12173. string celllastStr = $" 经审核,{celllastStr1},本次出国经费预算合计为 元。其中:市本级安排 。";
  12174. designer.SetDataSource("cell4Str", cell4Str);
  12175. designer.SetDataSource("cellStr", cellStr);
  12176. designer.SetDataSource("cellSum", otherFee.ToString("#0.00"));
  12177. designer.SetDataSource("cellSum4", (_EnterExitCosts.OutsideJJPay + _EnterExitCosts.OutsideGWPay).ToString("#0.00"));
  12178. designer.SetDataSource("celllastStr", celllastStr);
  12179. Workbook wb = designer.Workbook;
  12180. var sheet = wb.Worksheets[0];
  12181. //绑定datatable数据集
  12182. designer.SetDataSource(dtdac1);
  12183. designer.SetDataSource(dtdac2);
  12184. designer.Process();
  12185. var rowStart = dtdac1.Rows.Count;
  12186. while (rowStart > 0)
  12187. {
  12188. sheet.Cells[startIndex, 8].Formula = $"=G{startIndex + 1} * H{startIndex + 1}";
  12189. sheet.Cells[startIndex, 6].Formula = $"=E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  12190. startIndex++;
  12191. rowStart--;
  12192. }
  12193. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + 1}: I{startIndex})";
  12194. startIndex += 1; //总计行
  12195. rowStart = dtdac2.Rows.Count;
  12196. while (rowStart > 0)
  12197. {
  12198. sheet.Cells[startIndex, 8].Formula = $"= G{startIndex + 1} * H{startIndex + 1}";
  12199. sheet.Cells[startIndex, 6].Formula = $"= E{startIndex + 1} * F{startIndex + 1} * D{startIndex + 1}";
  12200. startIndex++;
  12201. rowStart--;
  12202. }
  12203. sheet.Cells[startIndex, 8].Formula = $"=SUM(I{startIndexcopy + dtdac1.Rows.Count + 2}: I{startIndex})";
  12204. wb.CalculateFormula(true);
  12205. //模板文件名
  12206. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_四川省商务厅出国经费财政先行审核表{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  12207. designer.Workbook.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  12208. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  12209. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  12210. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  12211. }
  12212. else if (dto.SubTypeId == 1066) //成都市因公临时出国任务和预算审批意见表(外专培训团专用)
  12213. {
  12214. //获取模板
  12215. string tempPath = (AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/Temp/成都市因公临时出国任务和预算审批意见表.docx");
  12216. //载入模板
  12217. Document doc = new Document(tempPath);
  12218. DocumentBuilder builder = new DocumentBuilder(doc);
  12219. Dictionary<string, string> dic = new Dictionary<string, string>();
  12220. dic.Add("GroupName", "-");
  12221. dic.Add("ClientUnit", "-");
  12222. //string missionLeader = ""; //团负责人默认接团客户名单第一个人
  12223. //string missionLeaderJob = "";//负责人job
  12224. //int groupNumber = 0; //团人数
  12225. dic.Add("MissionLeader", "-"); //团负责人
  12226. dic.Add("MissionLeaderJob", "-"); //团负责人job
  12227. dic.Add("GroupNumber", "0"); //团人数
  12228. dic.Add("Day", "0");
  12229. dic.Add("CultivateDay", dac4.Count.ToString()); //培训天数
  12230. // dic.Add("VisitCountry", _DelegationInfo.VisitCountry);
  12231. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  12232. Aspose.Words.Tables.Table table1 = allTables[0] as Aspose.Words.Tables.Table;
  12233. decimal hotelFeeTotal = dac1.Sum(it => it.SubTotal);//住宿费
  12234. dic.Add("HotelFeeTotal", hotelFeeTotal.ToString("#0.00"));
  12235. decimal mealsFeeTotal = dac2.Sum(it => it.SubTotal);//伙食费
  12236. dic.Add("MealsFeeTotal", mealsFeeTotal.ToString("#0.00"));
  12237. decimal miscellaneousFeeTotal = dac3.Sum(it => it.SubTotal);//公杂费
  12238. dic.Add("MiscellaneousFeeTotal", miscellaneousFeeTotal.ToString("#0.00"));
  12239. decimal trainingFeeTotal = dac4.Sum(it => it.SubTotal);//培训费
  12240. dic.Add("TrainingFeeTotal", trainingFeeTotal.ToString("#0.00"));
  12241. decimal cityTranfficFeeToatal = _EnterExitCosts.CityTranffic; //城市区间交通费
  12242. dic.Add("CityTranfficFeeToatal", cityTranfficFeeToatal.ToString("#0.00"));//
  12243. //其他费用
  12244. decimal otherFeeTotal = _EnterExitCosts.Visa + _EnterExitCosts.Safe + _EnterExitCosts.Ticket + _EnterExitCosts.YiMiao + _EnterExitCosts.HeSuan + _EnterExitCosts.Service + dac5.Sum(x => x.SubTotal);
  12245. dic.Add("OtherFeeTotal", otherFeeTotal.ToString("#0.00"));
  12246. //其他费用合计
  12247. decimal _otherFeeTotal = hotelFeeTotal + mealsFeeTotal + miscellaneousFeeTotal + trainingFeeTotal + cityTranfficFeeToatal + otherFeeTotal;
  12248. decimal _jjcFeeToatal = _EnterExitCosts.AirJJ + _otherFeeTotal; //经济舱
  12249. decimal _gwcFeeToatal = _EnterExitCosts.AirGW + _otherFeeTotal; //公务舱
  12250. //公务舱合计
  12251. //国际旅费
  12252. //string outsideJJ = "";
  12253. //string allPriceJJ = "";
  12254. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 0)
  12255. {
  12256. dic.Add("AirFeeTotal", _EnterExitCosts.AirJJ.ToString("#0.00"));
  12257. dic.Add("FeeTotal", _jjcFeeToatal.ToString("#0.00"));
  12258. }
  12259. if (_EnterExitCosts.SumGWC == 1 && _EnterExitCosts.SumJJC == 0)
  12260. {
  12261. dic.Add("AirFeeTotal", _EnterExitCosts.AirGW.ToString("#0.00"));
  12262. dic.Add("FeeTotal", _gwcFeeToatal.ToString("#0.00"));
  12263. }
  12264. if (_EnterExitCosts.SumJJC == 1 && _EnterExitCosts.SumGWC == 1)
  12265. {
  12266. string airFeeTotalStr = string.Format(@$"经济舱:{_EnterExitCosts.AirJJ:#0.00} 公务舱:{_EnterExitCosts.AirGW:#0.00}");
  12267. dic.Add("AirFeeTotal", airFeeTotalStr);
  12268. string feeTotalStr = string.Format(@$"经济舱:{_jjcFeeToatal:#0.00} 公务舱:{_gwcFeeToatal:#0.00}");
  12269. dic.Add("FeeTotal", feeTotalStr);
  12270. }
  12271. foreach (var key in dic.Keys)
  12272. {
  12273. builder.MoveToBookmark(key);
  12274. builder.Write(dic[key]);
  12275. }
  12276. //模板文件名
  12277. string strFileName = $"草稿_{_EnterExitCosts.DraftName}_成都市因公临时出国任务和预算审批意见表(外专培训团专用).docx";
  12278. strFileName = CommonFun.ValidFileName(strFileName);
  12279. doc.Save(AppSettingsHelper.Get("WordBasePath") + "EnterExitCost/File/" + strFileName);
  12280. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/EnterExitCost/File/" + strFileName;
  12281. if (dto.PortType == 1 || dto.PortType == 3) return Ok(JsonView(true, "成功", new { Url = url }));
  12282. else if (dto.PortType == 2) return Ok(JsonView(true, "成功", url));
  12283. }
  12284. }
  12285. else if (dto.ExportType == 2) //表格
  12286. {
  12287. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  12288. }
  12289. else if (dto.ExportType == 3)
  12290. {
  12291. return Ok(JsonView(400, "因需关联团组信息和客户信息,请在出入境费用明细里下载!", ""));
  12292. }
  12293. return Ok(JsonView(400, "只可导出明细表!", ""));
  12294. }
  12295. catch (Exception ex)
  12296. {
  12297. return Ok(JsonView(400, ex.Message, ""));
  12298. }
  12299. }
  12300. /// <summary>
  12301. /// 获取三公费用标准city
  12302. /// </summary>
  12303. /// <param name="placeData"></param>
  12304. /// <param name="nationalTravelFeeId"></param>
  12305. /// <returns></returns>
  12306. private string GetEnterExitCostDraftExportCity(List<Grp_NationalTravelFee> placeData, int nationalTravelFeeId)
  12307. {
  12308. string _city = string.Empty;
  12309. if (!placeData.Any()) return _city;
  12310. var data = placeData.Find(it => it.Id == nationalTravelFeeId);
  12311. if (data == null) return _city;
  12312. string country = data.Country;
  12313. string city = data.City;
  12314. if (city.Contains("其他城市") || city.Contains("所有城市")) _city = $"{country}-{city}";
  12315. else _city = city;
  12316. return _city;
  12317. }
  12318. /// <summary>
  12319. /// 团组模块 - 出入境费用-草稿 - 一键清空
  12320. /// </summary>
  12321. /// <returns></returns>
  12322. [HttpPost]
  12323. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  12324. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12325. public async Task<IActionResult> EnterExitCostDraftOneClickEmpty(EnterExitCostDraftOneClickEmptyDto dto)
  12326. {
  12327. if (dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数;"));
  12328. if (dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数;"));
  12329. var _view = await _enterExitCostDraftRep.OneClickEmpty(dto.Id, dto.UserId);
  12330. if (_view.Code == 0)
  12331. {
  12332. return Ok(JsonView(true, "操作成功"));
  12333. }
  12334. return Ok(JsonView(false, "操作失败"));
  12335. }
  12336. /// <summary>
  12337. /// 团组模块 - 出入境费用-草稿 - 子项删除
  12338. /// </summary>
  12339. /// <returns></returns>
  12340. [HttpPost]
  12341. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  12342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12343. public async Task<IActionResult> EnterExitCostDraftSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  12344. {
  12345. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  12346. if (data.Code != 0)
  12347. {
  12348. return Ok(JsonView(false, data.Msg));
  12349. }
  12350. return Ok(JsonView(true, "操作成功!", data.Data));
  12351. }
  12352. /// <summary>
  12353. /// 三公其他费用草稿 删除
  12354. /// </summary>
  12355. /// <param name="dto"></param>
  12356. /// <returns></returns>
  12357. [HttpPost]
  12358. //[ApiLog("Grp_EnterExitCostDraft", OperationEnum.Del)]
  12359. public IActionResult EnterExitCostDraftOtherExpensesDel(EnterExitCostDraftOtherExpensesDelDto dto)
  12360. {
  12361. var jw = JsonView(false, "删除失败!");
  12362. var data = new Grp_DayOtherPriceDraft()
  12363. {
  12364. Id = dto.Id,
  12365. IsDel = 1,
  12366. DeleteUserId = dto.DeleteUserId,
  12367. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  12368. };
  12369. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  12370. if (del > 0)
  12371. {
  12372. jw.Code = 200;
  12373. jw.Msg = "删除成功!";
  12374. }
  12375. return Ok(jw);
  12376. }
  12377. /// <summary>
  12378. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用基础数据
  12379. /// </summary>
  12380. /// <returns></returns>
  12381. [HttpPost]
  12382. public async Task<IActionResult> EnterExitCostDraftImportDataInit()
  12383. {
  12384. var jw = JsonView(false);
  12385. var groupNameDatas = await _groupRepository.EnterExitCostGroupNameAsync();
  12386. var draftDatas = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0).OrderByDescending(x => x.CreateTime).Select(x => new { x.Id, x.DraftName }).ToListAsync();
  12387. jw.Code = StatusCodes.Status200OK;
  12388. jw.Msg = "操作成功!";
  12389. jw.Data = new { groupNameDatas = groupNameDatas, draftNames = draftDatas };
  12390. return Ok(jw);
  12391. }
  12392. /// <summary>
  12393. /// 团组模块 - 出入境费用-草稿 - 导入正式出入境费用
  12394. /// </summary>
  12395. /// <param name="dto"></param>
  12396. /// <returns></returns>
  12397. [HttpPost]
  12398. public async Task<IActionResult> EnterExitCostDraftImportData(EnterExitCostDraftImportDataDto dto)
  12399. {
  12400. int userId = dto.UserId,
  12401. portId = dto.PortType,
  12402. groupId = dto.GroupId,
  12403. draftId = dto.DraftId;
  12404. _portTypeData.Add(1);
  12405. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12406. if (!_portTypeData.Contains(portId)) return Ok(JsonView(false, MsgTips.Port));
  12407. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId!"));
  12408. if (draftId < 1) return Ok(JsonView(false, "请传入有效的DraftId!"));
  12409. _sqlSugar.BeginTran();
  12410. try
  12411. {
  12412. var draftDatas = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).First();
  12413. if (draftDatas == null)
  12414. {
  12415. _sqlSugar.RollbackTran();
  12416. return Ok(JsonView(false, "草稿数据为空,不可导入!"));
  12417. }
  12418. //验证可覆盖已有数据 两边创建人需为同一人;
  12419. int draftCreateUserId = draftDatas.CreateUserId,
  12420. formalCreateUserId = 0;
  12421. var formalData = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  12422. if (formalData != null)
  12423. {
  12424. formalCreateUserId = formalData.CreateUserId;
  12425. if (draftCreateUserId != formalCreateUserId)
  12426. {
  12427. _sqlSugar.RollbackTran();
  12428. return Ok(JsonView(false, "由草稿数据到入至正式数据,两边创建人为同一人才可导入正式版!"));
  12429. }
  12430. }
  12431. //默认添加查看、编辑权限(创建人、自己)
  12432. await _enterExitCostRep.InitPerm(dto.GroupId, dto.UserId);
  12433. var dayDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  12434. var otherDatas = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == draftId).ToList();
  12435. var newExterData = _mapper.Map<Grp_EnterExitCost>(draftDatas);
  12436. newExterData.DiId = groupId;
  12437. newExterData.CreateUserId = userId;
  12438. newExterData.Remark = $"由草稿数据导入;草稿数Id:{draftId}";
  12439. var newDayDatas = _mapper.Map<List<Grp_DayAndCost>>(dayDatas);
  12440. if (newDayDatas.Any()) newDayDatas.Select(x => { x.DiId = groupId; x.CreateUserId = userId; return x; }).ToList();
  12441. var newOtherDatas = _mapper.Map<List<Grp_DayOtherPrice>>(otherDatas);
  12442. if (newOtherDatas.Any()) newOtherDatas.Select(x => { x.Diid = groupId; x.CreateUserId = userId; return x; }).ToList();
  12443. var enterExitCostInfo = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == groupId).First();
  12444. //数据如果存在执行删除
  12445. if (enterExitCostInfo != null)
  12446. {
  12447. _sqlSugar.Updateable<Grp_EnterExitCost>()
  12448. .SetColumns(x => new Grp_EnterExitCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), Remark = "由草稿数据导入前软删除数据!" })
  12449. .Where(x => x.Id == enterExitCostInfo.Id)
  12450. .ExecuteCommand();
  12451. _sqlSugar.Updateable<Grp_DayAndCost>()
  12452. .SetColumns(x => new Grp_DayAndCost() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  12453. .Where(x => x.DiId == groupId)
  12454. .ExecuteCommand();
  12455. _sqlSugar.Updateable<Grp_DayOtherPrice>()
  12456. .SetColumns(x => new Grp_DayOtherPrice() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  12457. .Where(x => x.Diid == groupId)
  12458. .ExecuteCommand();
  12459. _sqlSugar.Updateable<Grp_EnterExitCostPermission>()
  12460. .SetColumns(x => new Grp_EnterExitCostPermission() { IsDel = 1, DeleteUserId = userId, DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") })
  12461. .Where(x => x.GroupId == groupId)
  12462. .ExecuteCommand();
  12463. }
  12464. //执行insert
  12465. var insertId = _sqlSugar.Insertable(newExterData).ExecuteReturnIdentity();
  12466. if (insertId < 1)
  12467. {
  12468. _sqlSugar.RollbackTran();
  12469. return Ok(JsonView(false, "草稿数据导入失败!"));
  12470. }
  12471. if (newDayDatas.Any()) _sqlSugar.Insertable(newDayDatas).ExecuteCommand();
  12472. if (newOtherDatas.Any()) _sqlSugar.Insertable(newOtherDatas).ExecuteCommand();
  12473. #region 默认添加权限
  12474. #endregion
  12475. _sqlSugar.CommitTran();
  12476. //执行操作之后
  12477. //生成默认文件pdf并且通知人员
  12478. var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  12479. {
  12480. DiId = groupId,
  12481. ExportType = 1,
  12482. SubTypeId = 1005
  12483. }, "pdf");
  12484. //发送通知
  12485. string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  12486. string md5Sign = GeneralMethod.Encrypt($"{insertId}&fileName={fileUrl}");
  12487. string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", insertId, fileUrl);
  12488. await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(groupId, new List<string>() { "208", "233", "21" }, dto.UserId, url);
  12489. //汇率信息记录
  12490. await GeneralMethod.RateRecordSave(userId, insertId, "出入境费用-草稿导入");
  12491. return Ok(JsonView(true));
  12492. }
  12493. catch (Exception ex)
  12494. {
  12495. _sqlSugar.RollbackTran();
  12496. return Ok(JsonView(false, ex.Message));
  12497. }
  12498. }
  12499. #endregion
  12500. #region 团组经理模块 出入境费用 移动端(Android/IOS)
  12501. /// <summary>
  12502. /// 获取币种基础数据(含逻辑处理)
  12503. /// </summary>
  12504. /// <returns></returns>
  12505. private async Task<List<CurrencyInfo>> EnterExitCostMobileGetCurrencyInit()
  12506. {
  12507. return await GeneralMethod.EnterExitCostInitRate();
  12508. }
  12509. /// <summary>
  12510. /// 团组模块 - 出入境费用-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  12511. /// </summary>
  12512. /// <returns></returns>
  12513. [HttpPost]
  12514. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12515. public async Task<IActionResult> EnterExitCostMobileDataSource(EnterExitCostMobileDataSourceDto dto)
  12516. {
  12517. //验证城市归属并给默认值
  12518. int provinceId = dto.ProvinceId;
  12519. if (provinceId < 1) provinceId = 122;
  12520. var dataSource = await _sqlSugar
  12521. .Queryable<Sys_SetData>()
  12522. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  12523. .ToListAsync();
  12524. var fileTypes = new List<EecSetDataInfoView>();
  12525. //三公费用-Word明细类型
  12526. var wordTypeData = dataSource
  12527. .Where(it => it.STid == 72)
  12528. .Select(x => new EecSetDataInfoView
  12529. {
  12530. ParentId = 1,
  12531. Id = x.Id,
  12532. Name = x.Name
  12533. })
  12534. .ToArray();
  12535. if (wordTypeData.Any()) fileTypes.AddRange(wordTypeData);
  12536. var excelTypeData = dataSource
  12537. .Where(it => it.STid == 73)
  12538. .Select(x => new EecSetDataInfoView
  12539. {
  12540. ParentId = 2,
  12541. Id = x.Id,
  12542. Name = x.Name
  12543. })
  12544. .ToArray();
  12545. if (excelTypeData.Any()) fileTypes.AddRange(excelTypeData);
  12546. var groupNameList = new EecSetDataInfoView() { ParentId = 3, Id = 1, Name = "团组成员名单" };
  12547. fileTypes.Add(groupNameList);
  12548. fileTypes = fileTypes.OrderBy(x => x.ParentId).ThenBy(x => x.Id).ToList();
  12549. //默认币种显示
  12550. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  12551. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  12552. return Ok(JsonView(true, "查询成功!", new
  12553. {
  12554. FileTypeData = fileTypes,
  12555. CurrencyInit = _currencyInfos,
  12556. viewPermissionData = viewPermissionData
  12557. }));
  12558. }
  12559. /// <summary>
  12560. /// 团组模块 - 出入境费用-移动端 - 团组基础数据Data
  12561. /// </summary>
  12562. /// <returns></returns>
  12563. [HttpPost]
  12564. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12565. public async Task<IActionResult> EnterExitCostMobileGroupData(PostEnterExitCostMobileGroupDataDto dto)
  12566. {
  12567. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12568. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12569. RefAsync<int> total = 0;
  12570. int diId = 0;
  12571. var status = int.TryParse(dto.GroupName, out diId);
  12572. var basicUserId = await _enterExitCostRep.PermissionViewUsersAsync();
  12573. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  12574. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  12575. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  12576. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  12577. .OrderByDescending(x => x.VisitStartDate)
  12578. .Select(x => new EnterExitCostMobileGroupView()
  12579. {
  12580. Id = x.Id,
  12581. GroupName = x.TeamName,
  12582. IsNull = SqlFunc.Subqueryable<Grp_EnterExitCost>().Where(x1 => x1.DiId == x.Id && x1.IsDel == 0).Any() ? false : true,
  12583. IsView = SqlFunc.Subqueryable<Grp_EnterExitCostPermission>().Where(x1 => x1.GroupId == x.Id && x1.UserId == dto.CurrUserId).Any(),
  12584. ProvinceId = x.CityId
  12585. })
  12586. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12587. //处理省份Id
  12588. if (data.Any())
  12589. {
  12590. var provCityDatas = await _groupRepository.ProvinceCityBasicSource();
  12591. if (provCityDatas.Any())
  12592. {
  12593. foreach (var item in data)
  12594. {
  12595. var provinceId = item.ProvinceId;
  12596. var isDefualtVal = true;
  12597. if (provinceId > 0)
  12598. {
  12599. var parentId = _groupRepository.FindParentIdByChildId(provCityDatas, provinceId);
  12600. if (parentId != null)
  12601. {
  12602. isDefualtVal = false;
  12603. item.ProvinceId = (int)parentId;
  12604. }
  12605. }
  12606. if (isDefualtVal)
  12607. {
  12608. item.ProvinceId = 122; //默认四川
  12609. }
  12610. }
  12611. }
  12612. }
  12613. //处理是否显示
  12614. if (basicUserId.Any(x => x.Id == dto.CurrUserId))
  12615. {
  12616. foreach (var item in data)
  12617. {
  12618. item.IsView = true;
  12619. }
  12620. }
  12621. return Ok(JsonView(true, "查询成功!", data, total));
  12622. }
  12623. /// <summary>
  12624. /// 团组模块 - 出入境费用-移动端 - 币种基础数据Data
  12625. /// </summary>
  12626. /// <returns></returns>
  12627. [HttpPost]
  12628. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12629. public async Task<IActionResult> EnterExitCostMobileCurrencyData(PostEnterExitCostMobileCurrencyDataDto dto)
  12630. {
  12631. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12632. RefAsync<int> total = 0;
  12633. var data = await _sqlSugar.Queryable<Sys_SetData>()
  12634. .Where(x => x.IsDel == 0 && x.STid == 66)
  12635. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  12636. .Select(x => new
  12637. {
  12638. id = x.Id,
  12639. name = x.Name,
  12640. remark = x.Remark,
  12641. })
  12642. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12643. return Ok(JsonView(true, "查询成功!", data, total));
  12644. }
  12645. /// <summary>
  12646. /// 团组模块 - 出入境费用-移动端 - 其他款项 - 币种、费用类型基础数据Data
  12647. /// </summary>
  12648. /// <returns></returns>
  12649. [HttpPost]
  12650. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12651. public async Task<IActionResult> EnterExitCostMobileOtherItemCurrencyData(PostEnterExitCostMobileOtherItemCurrencyDataDto dto)
  12652. {
  12653. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12654. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12655. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(dto.PortType, dto.DiId, 98);
  12656. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  12657. var groupOtherRateData = groupRateData.TeamRates;
  12658. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  12659. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  12660. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  12661. groupOtherRateData = groupOtherRateData
  12662. .Select(x => new TeamRateDescAddCurrencyIdView
  12663. {
  12664. CurrencyId = x.CurrencyId,
  12665. CurrencyName = x.CurrencyName,
  12666. CurrencyCode = x.CurrencyCode,
  12667. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  12668. }).ToList();
  12669. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  12670. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  12671. }
  12672. /// <summary>
  12673. /// 团组模块 - 出入境费用-移动端 - 实时汇率、签证费用、机票费用 Tips
  12674. /// </summary>
  12675. /// <returns></returns>
  12676. [HttpPost]
  12677. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12678. public async Task<IActionResult> EnterExitCostMobileFeeTips(GetEnterExitCostMobileFeeTipsDto dto)
  12679. {
  12680. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12681. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12682. var tipsData = new List<int>() { 1, 2, 3 };
  12683. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  12684. if (dto.TipsType == 1)
  12685. {
  12686. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  12687. }
  12688. else if (dto.TipsType == 2)
  12689. {
  12690. var visaData = await _visaFeeInfoRep.EnterExitCostVisaTips(dto.GroupId);
  12691. return Ok(JsonView(true, "查询成功!", visaData.Data));
  12692. }
  12693. else if (dto.TipsType == 3)
  12694. {
  12695. var airData = await GeneralMethod.EntryAndExitTips(dto.GroupId);
  12696. return Ok(JsonView(true, "查询成功!", airData));
  12697. }
  12698. return Ok(JsonView(false));
  12699. }
  12700. /// <summary>
  12701. /// 团组模块 - 出入境国家费用标准-移动端 List
  12702. /// </summary>
  12703. /// <returns></returns>
  12704. [HttpPost]
  12705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12706. public async Task<IActionResult> NationalTravelFeeMobileData(PostNationalTravelFeeMobileDataDto dto)
  12707. {
  12708. Stopwatch sw = new Stopwatch();
  12709. sw.Start();
  12710. int provinceId = dto.ProvinceId;
  12711. if (provinceId < 1) provinceId = 122; // 默认四川
  12712. RefAsync<int> total = 0;
  12713. var data = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  12714. .LeftJoin<Sys_SetData>((ntf, sd) => ntf.Currency == sd.Id)
  12715. .LeftJoin<Sys_Users>((ntf, sd, u) => ntf.CreateUserId == u.Id)
  12716. .LeftJoin<Sys_Cities>((ntf, sd, u, sd1) => ntf.ProvinceId == sd1.Id)
  12717. .Where((ntf, sd, u, sd1) => ntf.IsDel == 0 && ntf.ProvinceId == provinceId)
  12718. .WhereIF(!string.IsNullOrEmpty(dto.Search), (ntf, sd, u, sd1) => dto.Search.Contains(ntf.Country) || dto.Search.Contains(ntf.City))
  12719. .Select((ntf, sd, u, sd1) => new
  12720. {
  12721. Id = ntf.Id,
  12722. Area = $"{ntf.Country}-{ntf.City}",
  12723. Currency = ntf.Currency,
  12724. CurrencyCode = sd.Name,
  12725. CurrencyName = sd.Remark,
  12726. RoomCost = ntf.RoomCost,
  12727. FoodCost = ntf.FoodCost,
  12728. PublicCost = ntf.PublicCost,
  12729. TrainCost = ntf.TrainCost,
  12730. LastUpdateUserId = ntf.LastUpdateUserId,
  12731. LastUpdateUserName = u.CnName,
  12732. LastUpdateTime = ntf.LastUpdateTime
  12733. })
  12734. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  12735. sw.Stop();
  12736. return Ok(JsonView(true, "查询成功!耗时:" + sw.ElapsedMilliseconds + "ms", data, total));
  12737. }
  12738. /// <summary>
  12739. /// 团组模块 - 出入境费用-移动端 - Info
  12740. /// </summary>
  12741. /// <returns></returns>
  12742. [HttpPost]
  12743. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12744. public async Task<IActionResult> EnterExitCostMobileInfo(EnterExitCostInfobyDiIdDto dto)
  12745. {
  12746. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12747. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12748. var data = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  12749. return Ok(data);
  12750. }
  12751. /// <summary>
  12752. /// 团组模块 - 出入境费用-移动端 - ParentInfo
  12753. /// </summary>
  12754. /// <returns></returns>
  12755. [HttpPost]
  12756. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12757. public async Task<IActionResult> EnterExitCostMobileParentInfo(EnterExitCostInfobyDiIdDto dto)
  12758. {
  12759. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12760. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12761. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12762. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  12763. var mobileInfo = new EnterExitCostMobileParentInfoView();
  12764. mobileInfo.DiId = dto.DiId;
  12765. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  12766. if (eecInfo == null) return Ok(mobileInfo);
  12767. //验证查看权限
  12768. (bool isView, bool isSet) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);
  12769. if (!isView) return Ok(JsonView(false, "没有查看权限!"));
  12770. mobileInfo = _mapper.Map<EnterExitCostMobileParentInfoView>(eecInfo);
  12771. mobileInfo.IsAssignPerm = isSet;
  12772. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCost>()
  12773. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12774. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12775. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  12776. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12777. {
  12778. SubId = dac.Id,
  12779. DiId = dac.DiId,
  12780. Type = dac.Type,
  12781. Days = dac.Days,
  12782. NationalTravelFeeId = dac.NationalTravelFeeId,
  12783. Arae = $"{ntf.Country}-{ntf.City}",
  12784. Cost = dac.Cost,
  12785. Currency = dac.Currency,
  12786. CurrencyName = sd.Name,
  12787. SubTotal = dac.SubTotal,
  12788. })
  12789. .ToList();
  12790. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  12791. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  12792. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  12793. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  12794. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  12795. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  12796. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  12797. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  12798. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  12799. //其他款项
  12800. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  12801. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  12802. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  12803. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  12804. .OrderBy((dop, sd1, sd2) => dop.Index)
  12805. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  12806. {
  12807. SubId = dop.Id,
  12808. DiId = dop.Diid,
  12809. Index = dop.Index,
  12810. SetDataId = dop.SetDataId,
  12811. SetDataName = sd1.Name,
  12812. Cost = dop.Cost,
  12813. Currency = dop.Currency,
  12814. CurrencyName = sd2.Remark,
  12815. SubTotal = dop.SubTotal,
  12816. Remark = dop.Remark,
  12817. })
  12818. .ToArray();
  12819. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  12820. return Ok(mobileInfo);
  12821. }
  12822. /// <summary>
  12823. /// 团组模块 - 出入境费用-移动端 - 查看权限用户
  12824. /// </summary>
  12825. /// <returns></returns>
  12826. [HttpPost]
  12827. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12828. public async Task<IActionResult> EnterExitCostMobileViewPermissionUsers(EnterExitCostMobileViewPermissionUsersDto dto)
  12829. {
  12830. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12831. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12832. //验证查看权限
  12833. (bool viewPerm, bool assignPerm) = await _enterExitCostRep.PermissionValidationAsync(dto.DiId, dto.CurrUserId);//分配权限
  12834. if (!viewPerm) return Ok(JsonView(false, "未分配查看权限,如要查看,请联系市场部或国交部负责人!"));
  12835. var userIds = await _sqlSugar
  12836. .Queryable<Grp_EnterExitCostPermission>()
  12837. .Where(x => x.IsDel == 0 && x.GroupId == dto.DiId)
  12838. .Select(x => x.UserId)
  12839. .ToArrayAsync();
  12840. var perUsers = await _enterExitCostRep.PermissionViewUsersAsync();
  12841. var perUsersView = new List<dynamic>();
  12842. foreach (var item in perUsers)
  12843. {
  12844. bool isView1 = false;
  12845. if (userIds.Any(x => x == item.Id)) isView1 = true;
  12846. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  12847. }
  12848. return Ok(JsonView(perUsersView));
  12849. }
  12850. /// <summary>
  12851. /// 团组模块 - 出入境费用-移动端 - SubInfo
  12852. /// </summary>
  12853. /// <returns></returns>
  12854. [HttpPost]
  12855. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  12856. public async Task<IActionResult> EnterExitCostMobileSubInfo(PostEnterExitCostMobileSubInfoDto dto)
  12857. {
  12858. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  12859. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  12860. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  12861. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  12862. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  12863. //验证查看权限
  12864. //(bool isView, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId);
  12865. //if (!isView) return Ok(JsonView(false, msg));
  12866. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCost>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DiId == dto.DiId && it.IsDel == 0);
  12867. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  12868. var subType = dto.SubType;
  12869. if (subType == 1) //1:境内费用
  12870. {
  12871. var oneData = new ChoiceOneMobileSubInfoView()
  12872. {
  12873. Id = eecInfo.Id,
  12874. ChoiceOne = eecInfo.ChoiceOne,
  12875. ChoiceOneTotalCost = eecInfo.InsidePay,
  12876. Visa = eecInfo.Visa,
  12877. VisaRemark = eecInfo.VisaRemark,
  12878. YiMiao = eecInfo.YiMiao,
  12879. HeSuan = eecInfo.HeSuan,
  12880. Service = eecInfo.Service,
  12881. Ticket = eecInfo.Ticket,
  12882. Safe = eecInfo.Safe,
  12883. FirstItemRemark = eecInfo.FirstItemRemark
  12884. };
  12885. return Ok(JsonView(oneData));
  12886. }
  12887. else if (subType == 2) //2:国际旅费
  12888. {
  12889. var twoData = new ChoiceTwoMobileSubInfoView()
  12890. {
  12891. Id = eecInfo.Id,
  12892. ChoiceTwoJJ = eecInfo.SumJJC,
  12893. OutsideJJPay = eecInfo.OutsideJJPay,
  12894. ChoiceTwoGW = eecInfo.SumGWC,
  12895. OutsideGWPay = eecInfo.OutsideGWPay,
  12896. ChoiceTwoTD = eecInfo.SumTDC,
  12897. OutsideTDPay = eecInfo.OutsideTDPay,
  12898. AirJJ = eecInfo.AirJJ,
  12899. AirGW = eecInfo.AirGW,
  12900. AirTD = eecInfo.AirTD,
  12901. CityTranffic = eecInfo.CityTranffic,
  12902. CityTranffic1 = eecInfo.CityTranffic1,
  12903. CityTranffic2 = eecInfo.CityTranffic2,
  12904. TwoItemRemark = eecInfo.TwoItemRemark
  12905. };
  12906. return Ok(JsonView(twoData));
  12907. }
  12908. else if (subType == 3) //3:住宿费
  12909. {
  12910. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12911. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12912. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12913. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 1)
  12914. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12915. {
  12916. SubId = dac.Id,
  12917. DiId = dac.DiId,
  12918. Type = dac.Type,
  12919. Days = dac.Days,
  12920. NationalTravelFeeId = dac.NationalTravelFeeId,
  12921. Arae = $"{ntf.Country}-{ntf.City}",
  12922. Cost = dac.Cost,
  12923. Currency = dac.Currency,
  12924. CurrencyName = sd.Name,
  12925. SubTotal = dac.SubTotal,
  12926. })
  12927. .ToArray();
  12928. var data = new ChoiceMobileSubInfo3To6View()
  12929. {
  12930. ParentId = eecInfo.Id,
  12931. Choice = eecInfo.ChoiceThree,
  12932. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12933. Details = dayAndCostDatas
  12934. };
  12935. return Ok(JsonView(data));
  12936. }
  12937. else if (subType == 4) //4:伙食费
  12938. {
  12939. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12940. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12941. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12942. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 2)
  12943. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12944. {
  12945. SubId = dac.Id,
  12946. DiId = dac.DiId,
  12947. Type = dac.Type,
  12948. Days = dac.Days,
  12949. NationalTravelFeeId = dac.NationalTravelFeeId,
  12950. Arae = $"{ntf.Country}-{ntf.City}",
  12951. Cost = dac.Cost,
  12952. Currency = dac.Currency,
  12953. CurrencyName = sd.Name,
  12954. SubTotal = dac.SubTotal,
  12955. })
  12956. .ToArray();
  12957. var data = new ChoiceMobileSubInfo3To6View()
  12958. {
  12959. ParentId = eecInfo.Id,
  12960. Choice = eecInfo.ChoiceFour,
  12961. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12962. Details = dayAndCostDatas
  12963. };
  12964. return Ok(JsonView(data));
  12965. }
  12966. else if (subType == 5) //5:公杂费
  12967. {
  12968. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12969. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12970. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  12971. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 3)
  12972. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  12973. {
  12974. SubId = dac.Id,
  12975. DiId = dac.DiId,
  12976. Type = dac.Type,
  12977. Days = dac.Days,
  12978. NationalTravelFeeId = dac.NationalTravelFeeId,
  12979. Arae = $"{ntf.Country}-{ntf.City}",
  12980. Cost = dac.Cost,
  12981. Currency = dac.Currency,
  12982. CurrencyName = sd.Name,
  12983. SubTotal = dac.SubTotal,
  12984. })
  12985. .ToArray();
  12986. var data = new ChoiceMobileSubInfo3To6View()
  12987. {
  12988. ParentId = eecInfo.Id,
  12989. Choice = eecInfo.ChoiceFive,
  12990. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  12991. Details = dayAndCostDatas
  12992. };
  12993. return Ok(JsonView(data));
  12994. }
  12995. else if (subType == 6) //6:培训费
  12996. {
  12997. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCost>()
  12998. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  12999. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  13000. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId && dac.Type == 4)
  13001. .Select((dac, ntf, sd) => new DayAndCostMobileInfoView
  13002. {
  13003. SubId = dac.Id,
  13004. DiId = dac.DiId,
  13005. Type = dac.Type,
  13006. Days = dac.Days,
  13007. NationalTravelFeeId = dac.NationalTravelFeeId,
  13008. Arae = $"{ntf.Country}-{ntf.City}",
  13009. Cost = dac.Cost,
  13010. Currency = dac.Currency,
  13011. CurrencyName = sd.Name,
  13012. SubTotal = dac.SubTotal,
  13013. })
  13014. .ToArray();
  13015. var data = new ChoiceMobileSubInfo3To6View()
  13016. {
  13017. ParentId = eecInfo.Id,
  13018. Choice = eecInfo.ChoiceSix,
  13019. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  13020. Details = dayAndCostDatas
  13021. };
  13022. return Ok(JsonView(data));
  13023. }
  13024. else if (subType == 7) //7:其他
  13025. {
  13026. //其他款项
  13027. var otherData = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  13028. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  13029. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  13030. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  13031. .OrderBy((dop, sd1, sd2) => dop.Index)
  13032. .Select((dop, sd1, sd2) => new DayOtherPriceMobileInfoView
  13033. {
  13034. SubId = dop.Id,
  13035. DiId = dop.Diid,
  13036. Index = dop.Index,
  13037. SetDataId = dop.SetDataId,
  13038. SetDataName = sd1.Name,
  13039. Cost = dop.Cost,
  13040. Currency = dop.Currency,
  13041. CurrencyName = sd2.Name,
  13042. SubTotal = dop.SubTotal,
  13043. Remark = dop.Remark,
  13044. })
  13045. .ToArray();
  13046. var data = new ChoiceSevenMobileSubInfoView()
  13047. {
  13048. ParentId = eecInfo.Id,
  13049. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  13050. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  13051. Details = otherData
  13052. };
  13053. return Ok(JsonView(data));
  13054. }
  13055. return Ok(JsonView(false));
  13056. }
  13057. #region op
  13058. ///// <summary>
  13059. ///// 移动端更新费用消息通知
  13060. ///// </summary>
  13061. ///// <param name="diid"></param>
  13062. ///// <param name="id"></param>
  13063. ///// <param name="currUserId"></param>
  13064. //private async Task EnterExitCostMobileOpNotice(int diid, int id, int currUserId)
  13065. //{
  13066. // try
  13067. // {
  13068. // ////生成默认文件pdf并且通知人员
  13069. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  13070. // //{
  13071. // // DiId = diid,
  13072. // // ExportType = 1,
  13073. // // SubTypeId = 1005
  13074. // //}, "pdf");
  13075. // ////发送通知
  13076. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  13077. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  13078. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  13079. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(diid, new List<string>() { "208", "233", "21" }, currUserId, url);
  13080. // ////汇率信息记录
  13081. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  13082. // }
  13083. // catch (Exception ex)
  13084. // {
  13085. // //记录日志
  13086. // throw;
  13087. // }
  13088. //}
  13089. /// <summary>
  13090. /// 验证出入境费用数据是否存在
  13091. /// 不存在添加
  13092. /// </summary>
  13093. /// <param name="diId"></param>
  13094. /// <param name="currUserId"></param>
  13095. /// <returns></returns>
  13096. /// <exception cref="CustomException"></exception>
  13097. private async Task<int> EnterExitCostVerifyIsNull(int diId, int currUserId)
  13098. {
  13099. var parentId = 0;
  13100. var info = await _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == diId).OrderByDescending(x => x.CreateTime).FirstAsync();
  13101. if (info != null)
  13102. {
  13103. parentId = info.Id;
  13104. }
  13105. else
  13106. {
  13107. var currencys = await EnterExitCostMobileGetCurrencyInit();
  13108. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCost() { DiId = diId, CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  13109. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  13110. parentId = addId;
  13111. }
  13112. return parentId;
  13113. }
  13114. /// <summary>
  13115. /// 团组模块 - 出入境费用-移动端 - 设置view权限
  13116. /// </summary>
  13117. /// <returns></returns>
  13118. [HttpPost]
  13119. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13120. public async Task<IActionResult> EnterExitCostMobileSetViewPermissiion(EnterExitCostMobileSetViewPermissiionDto dto)
  13121. {
  13122. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13123. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13124. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  13125. //验证编辑权限
  13126. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13127. //if (!isEdit) return Ok(JsonView(false, msg));
  13128. var permissions = new List<Grp_EnterExitCostPermission>();
  13129. foreach (var userId in dto.UserIds)
  13130. {
  13131. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = userId, CreateUserId = dto.CurrUserId });
  13132. }
  13133. if (permissions.Any())
  13134. {
  13135. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  13136. {
  13137. permissions.Add(new Grp_EnterExitCostPermission { Permission = 1, GroupId = dto.DiId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  13138. }
  13139. _sqlSugar.BeginTran();
  13140. await _sqlSugar.Deleteable<Grp_EnterExitCostPermission>().Where(it => it.GroupId == dto.DiId).ExecuteCommandAsync();
  13141. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  13142. if (result < 1)
  13143. {
  13144. _sqlSugar.RollbackTran();
  13145. return Ok(JsonView(false));
  13146. }
  13147. _sqlSugar.CommitTran();
  13148. return Ok(JsonView(true));
  13149. }
  13150. return Ok(JsonView(false));
  13151. }
  13152. /// <summary>
  13153. /// 团组模块 - 出入境费用-移动端 - OP --> 汇率
  13154. /// </summary>
  13155. /// <returns></returns>
  13156. [HttpPost]
  13157. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13158. public async Task<IActionResult> EnterExitCostMobileOpRate(PostEnterExitCostMobileFeeRateOpDto dto)
  13159. {
  13160. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13161. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13162. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13163. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  13164. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  13165. int id = dto.Id;
  13166. if (id <= 0) //add
  13167. {
  13168. //int provinceId = dto.ProvinceId;
  13169. int groupId = dto.DiId;
  13170. //if (provinceId < 1) provinceId = 122;
  13171. var info = new Grp_EnterExitCost() { DiId = groupId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId };
  13172. info.LastUpdateUserId = dto.CurrUserId;
  13173. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13174. var add = await _sqlSugar.Insertable(info).ExecuteCommandAsync();
  13175. if (add < 1) return Ok(JsonView(false));
  13176. id = add;
  13177. }
  13178. else //update
  13179. {
  13180. ////验证编辑权限
  13181. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13182. //if (!isEdit) return Ok(JsonView(false, msg));
  13183. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>().SetColumns(x => new Grp_EnterExitCost()
  13184. {
  13185. CurrencyRemark = currencyStr,
  13186. LastUpdateUserId = dto.CurrUserId,
  13187. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13188. }).Where(x => x.Id == dto.Id).ExecuteCommandAsync();
  13189. if (upd < 1) return Ok(JsonView(false));
  13190. }
  13191. #region 汇率变更时更改币种相关费用
  13192. var opDayCosts = new List<Grp_DayAndCost>();
  13193. var opDayOtherCosts = new List<Grp_DayOtherPrice>();
  13194. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  13195. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCost>()
  13196. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  13197. .Where((dac, sd) => dac.IsDel == 0 && dac.DiId == dto.DiId)
  13198. .Select((dac, sd) => new
  13199. {
  13200. dac.Id,
  13201. dac.DiId,
  13202. CurrencyCode = sd.Name,
  13203. dac.Cost
  13204. })
  13205. .ToList();
  13206. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPrice>()
  13207. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  13208. .Where((dop, sd) => dop.IsDel == 0 && dop.Diid == dto.DiId)
  13209. .Select((dop, sd) => new
  13210. {
  13211. dop.Id,
  13212. dop.Diid,
  13213. CurrencyCode = sd.Name,
  13214. dop.Cost
  13215. })
  13216. .ToList();
  13217. if (dayCosts.Count > 0)
  13218. {
  13219. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  13220. foreach (var dc in new_dayCosts)
  13221. {
  13222. var thisCurrency = dc.Key.ToUpper();
  13223. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  13224. if (thisRate == 0.00M) continue;
  13225. foreach (var dcSub in dc)
  13226. {
  13227. opDayCosts.Add(new Grp_DayAndCost()
  13228. {
  13229. Id = dcSub.Id,
  13230. DiId = dcSub.DiId,
  13231. Cost = dcSub.Cost,
  13232. SubTotal = dcSub.Cost * thisRate,
  13233. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  13234. });
  13235. }
  13236. }
  13237. if (opDayCosts.Count > 0)
  13238. {
  13239. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  13240. }
  13241. }
  13242. if (dayOtherCosts.Count > 0)
  13243. {
  13244. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  13245. foreach (var dc in new_dayOtherCosts)
  13246. {
  13247. var thisCurrency = dc.Key.ToUpper();
  13248. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  13249. if (thisRate == 0.00M) continue;
  13250. foreach (var dcSub in dc)
  13251. {
  13252. opDayOtherCosts.Add(new Grp_DayOtherPrice()
  13253. {
  13254. Id = dcSub.Id,
  13255. Diid = dcSub.Diid,
  13256. Cost = dcSub.Cost,
  13257. SubTotal = dcSub.Cost * thisRate,
  13258. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  13259. });
  13260. }
  13261. }
  13262. if (opDayOtherCosts.Count > 0)
  13263. {
  13264. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  13265. }
  13266. }
  13267. #endregion
  13268. //消息通知
  13269. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13270. //汇率信息记录
  13271. await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  13272. return Ok(JsonView(new { parentId = id }));
  13273. }
  13274. /// <summary>
  13275. /// 团组模块 - 出入境费用-移动端 - OP --> 复选框
  13276. /// </summary>
  13277. /// <returns></returns>
  13278. [HttpPost]
  13279. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13280. public async Task<IActionResult> EnterExitCostMobileOpCheckbox(PostEnterExitCostMobileFeeOpCheckboxDto dto)
  13281. {
  13282. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13283. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13284. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13285. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13286. var checkboxInfo = _mapper.Map<Grp_EnterExitCost>(dto);
  13287. checkboxInfo.LastUpdateUserId = dto.CurrUserId;
  13288. checkboxInfo.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13289. int id = dto.Id;
  13290. if (id <= 0) //add
  13291. {
  13292. checkboxInfo.CreateUserId = dto.CurrUserId;
  13293. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13294. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  13295. if (add < 1) return Ok(JsonView(false));
  13296. }
  13297. else //update
  13298. {
  13299. ////验证编辑权限
  13300. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13301. //if (!isEdit) return Ok(JsonView(false, msg));
  13302. var upd = await _sqlSugar.Updateable(checkboxInfo)
  13303. .UpdateColumns(x => new
  13304. {
  13305. x.ChoiceOne,
  13306. x.ChoiceTwo,
  13307. x.SumJJC,
  13308. x.SumGWC,
  13309. x.SumTDC,
  13310. x.ChoiceThree,
  13311. x.ChoiceFour,
  13312. x.ChoiceFive,
  13313. x.ChoiceSix,
  13314. x.OtherExpenses_Checked
  13315. })
  13316. .Where(x => x.Id == id)
  13317. .ExecuteCommandAsync();
  13318. if (upd < 1) return Ok(JsonView(false));
  13319. }
  13320. return Ok(JsonView(new { parentId = id }));
  13321. }
  13322. /// <summary>
  13323. /// 团组模块 - 出入境费用-移动端 - OP --> 3-7项复选框单个复选框更改
  13324. /// </summary>
  13325. /// <returns></returns>
  13326. [HttpPost]
  13327. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13328. public async Task<IActionResult> EnterExitCostMobileOpSingleCheckbox(EnterExitCostMobileOpSingleCheckboxDto dto)
  13329. {
  13330. int itemTypeId = dto.ItemType, id = dto.Id, currUserId = dto.CurrUserId, diId = dto.DiId, isSelected = dto.IsSelected;
  13331. // if (provinceId < 1) provinceId = 122;
  13332. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  13333. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13334. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13335. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13336. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  13337. var checkboxInfo = new Grp_EnterExitCost()
  13338. {
  13339. Id = id,
  13340. //ProvinceId = provinceId,
  13341. DiId = diId,
  13342. CreateUserId = currUserId,
  13343. LastUpdateUserId = dto.CurrUserId,
  13344. LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  13345. };
  13346. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  13347. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  13348. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  13349. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  13350. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  13351. if (id <= 0) //add
  13352. {
  13353. checkboxInfo.CreateUserId = dto.CurrUserId;
  13354. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13355. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  13356. if (add < 1) return Ok(JsonView(false));
  13357. }
  13358. else //update
  13359. {
  13360. ////验证编辑权限
  13361. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13362. //if (!isEdit) return Ok(JsonView(false, msg));
  13363. var upd = await _sqlSugar.Updateable<Grp_EnterExitCost>()
  13364. .SetColumns(it => it.LastUpdateUserId == dto.CurrUserId)
  13365. .SetColumns(it => it.LastUpdateTime == DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))
  13366. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  13367. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  13368. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  13369. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  13370. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  13371. .Where(x => x.Id == id)
  13372. .ExecuteCommandAsync();
  13373. if (upd < 1) return Ok(JsonView(false));
  13374. }
  13375. return Ok(JsonView(new { parentId = id }));
  13376. }
  13377. /// <summary>
  13378. /// 团组模块 - 出入境费用-移动端 - OP --> 境内费用 Step1
  13379. /// </summary>
  13380. /// <returns></returns>
  13381. [HttpPost]
  13382. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13383. public async Task<IActionResult> EnterExitCostMobileOpStep1(PostEnterExitCostMobileOpStep1Dto dto)
  13384. {
  13385. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13386. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13387. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13388. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13389. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  13390. info.FirstItemRemark = dto.FirstItemRemark;
  13391. info.LastUpdateUserId = dto.CurrUserId;
  13392. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13393. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  13394. int id = dto.Id;
  13395. if (id <= 0) //add
  13396. {
  13397. info.CreateUserId = dto.CurrUserId;
  13398. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13399. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  13400. if (add < 1) return Ok(JsonView(false));
  13401. id = add;
  13402. }
  13403. else //update
  13404. {
  13405. ////验证编辑权限
  13406. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13407. //if (!isEdit) return Ok(JsonView(false, msg));
  13408. var upd = await _sqlSugar.Updateable(info)
  13409. .UpdateColumns(x => new
  13410. {
  13411. x.ChoiceOne,
  13412. x.InsidePay,
  13413. x.VisaRemark,
  13414. x.Visa,
  13415. x.Service,
  13416. x.Safe,
  13417. x.Ticket,
  13418. x.HeSuan,
  13419. x.YiMiao,
  13420. x.FirstItemRemark,
  13421. x.LastUpdateUserId,
  13422. x.LastUpdateTime
  13423. })
  13424. .Where(x => x.Id == id)
  13425. .ExecuteCommandAsync();
  13426. if (upd < 1) return Ok(JsonView(false));
  13427. }
  13428. //消息通知
  13429. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13430. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  13431. }
  13432. /// <summary>
  13433. /// 团组模块 - 出入境费用-移动端 - OP --> 国际旅费 Step2
  13434. /// </summary>
  13435. /// <returns></returns>
  13436. [HttpPost]
  13437. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13438. public async Task<IActionResult> EnterExitCostMobileOpStep2(PostEnterExitCostMobileOpStep2Dto dto)
  13439. {
  13440. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13441. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13442. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13443. //if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13444. var info = _mapper.Map<Grp_EnterExitCost>(dto);
  13445. info.DiId = dto.DiId;
  13446. //info.ProvinceId = dto.ProvinceId;
  13447. info.OutsideJJPay = dto.OutsideJJPay;
  13448. info.OutsideGWPay = dto.OutsideGWPay;
  13449. info.OutsideTDPay = dto.OutsideTDPay;
  13450. info.AirJJ = dto.AirJJ;
  13451. info.AirGW = dto.AirGW;
  13452. info.AirTD = dto.AirTD;
  13453. info.CityTranffic = dto.CityTranffic;
  13454. info.CityTranffic1 = dto.CityTranffic1;
  13455. info.CityTranffic2 = dto.CityTranffic2;
  13456. info.TwoItemRemark = dto.TwoItemRemark;
  13457. info.SumJJC = dto.ChoiceTwoJJ;
  13458. info.SumGWC = dto.ChoiceTwoGW;
  13459. info.SumTDC = dto.ChoiceTwoTD;
  13460. info.LastUpdateUserId = dto.CurrUserId;
  13461. info.LastUpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  13462. int id = dto.Id;
  13463. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  13464. if (id <= 0) //add i
  13465. {
  13466. info.CreateUserId = dto.CurrUserId;
  13467. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  13468. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  13469. if (addId <= 0) return Ok(JsonView(false));
  13470. id = addId;
  13471. }
  13472. else //update
  13473. {
  13474. ////验证编辑权限
  13475. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13476. //if (!isEdit) return Ok(JsonView(false, msg));
  13477. var upd = await _sqlSugar.Updateable(info)
  13478. .UpdateColumns(x => new
  13479. {
  13480. x.SumJJC,
  13481. x.OutsideJJPay,
  13482. x.SumGWC,
  13483. x.OutsideGWPay,
  13484. x.SumTDC,
  13485. x.OutsideTDPay,
  13486. x.AirJJ,
  13487. x.AirGW,
  13488. x.AirTD,
  13489. x.CityTranffic,
  13490. x.CityTranffic1,
  13491. x.CityTranffic2,
  13492. x.TwoItemRemark,
  13493. x.LastUpdateTime,
  13494. x.LastUpdateUserId
  13495. })
  13496. .Where(x => x.Id == id)
  13497. .ExecuteCommandAsync();
  13498. if (upd < 1) return Ok(JsonView(false));
  13499. }
  13500. jjcItemTotal = info.AirJJ + info.CityTranffic;
  13501. gwcItemTotal = info.AirGW + info.CityTranffic1;
  13502. tdcItemTotal = info.AirTD + info.CityTranffic2;
  13503. //消息通知
  13504. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13505. return Ok(JsonView(new
  13506. {
  13507. parentId = id,
  13508. choiceTwoJJ = dto.ChoiceTwoJJ,
  13509. jjcItemTotal = jjcItemTotal,
  13510. choiceTwoGW = dto.ChoiceTwoGW,
  13511. gwcItemTotal = gwcItemTotal,
  13512. choiceTwoTD = dto.ChoiceTwoTD,
  13513. tdcItemTotal = tdcItemTotal
  13514. }));
  13515. }
  13516. /// <summary>
  13517. /// 团组模块 - 出入境费用-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  13518. /// </summary>
  13519. /// <returns></returns>
  13520. [HttpPost]
  13521. [ApiExplorerSettings(IgnoreApi = true)]
  13522. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13523. public async Task<IActionResult> EnterExitCostMobileOpBatchStep3To6(PostEnterExitCostMobileOpStep3To6Dto dto)
  13524. {
  13525. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13526. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13527. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13528. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  13529. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  13530. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  13531. var infos1 = _mapper.Map<List<Grp_DayAndCost>>(dto.Infos);
  13532. var infos = infos1.Select(x => new Grp_DayAndCost
  13533. {
  13534. Id = x.Id,
  13535. DiId = dto.DiId,
  13536. Type = dto.FeeType,
  13537. Days = x.Days,
  13538. NationalTravelFeeId = x.NationalTravelFeeId,
  13539. Cost = x.Cost,
  13540. Currency = x.Currency,
  13541. SubTotal = x.SubTotal,
  13542. CreateUserId = dto.CurrUserId
  13543. })
  13544. .ToList();
  13545. var adds = infos.Where(x => x.Id <= 0).ToList();
  13546. var upds = infos.Where(x => x.Id > 0).ToList();
  13547. if (adds.Count > 0)
  13548. {
  13549. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  13550. if (add < 1) return Ok(JsonView(false));
  13551. }
  13552. if (upds.Count > 0)
  13553. {
  13554. var upd = await _sqlSugar.Updateable(adds)
  13555. .UpdateColumns(x => new
  13556. {
  13557. x.Days,
  13558. x.NationalTravelFeeId,
  13559. x.Cost,
  13560. x.Currency,
  13561. x.SubTotal
  13562. })
  13563. .WhereColumns(x => new { x.Id })
  13564. .ExecuteCommandAsync();
  13565. if (upd < 1) return Ok(JsonView(false));
  13566. }
  13567. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  13568. //消息通知
  13569. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  13570. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13571. return Ok(JsonView(new { itemTotal = itemTotal }));
  13572. }
  13573. /// <summary>
  13574. /// 团组模块 - 出入境费用-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  13575. /// </summary>
  13576. /// <returns></returns>
  13577. [HttpPost]
  13578. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13579. public async Task<IActionResult> EnterExitCostMobileOpSingleStep3To6(PostEnterExitCostMobileOpSingleStep3To6Dto dto)
  13580. {
  13581. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  13582. int subId = dto.SubId, feeType = dto.FeeType;
  13583. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13584. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13585. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13586. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  13587. var subInfo = _mapper.Map<Grp_DayAndCost>(dto);
  13588. subInfo.Id = subId;
  13589. subInfo.DiId = dto.DiId;
  13590. if (feeType == 3) subInfo.Type = 1;
  13591. else if (feeType == 4) subInfo.Type = 2;
  13592. else if (feeType == 5) subInfo.Type = 3;
  13593. else if (feeType == 6) subInfo.Type = 4;
  13594. subInfo.CreateUserId = dto.CurrUserId;
  13595. int parentId = await EnterExitCostVerifyIsNull(dto.DiId, dto.CurrUserId); //主表验证
  13596. if (parentId < 1) return Ok(JsonView(false));
  13597. //子表op
  13598. if (subId < 1)
  13599. {
  13600. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  13601. if (subAdd < 1) return Ok(JsonView(false));
  13602. }
  13603. else
  13604. {
  13605. ////验证编辑权限
  13606. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.DiId, dto.CurrUserId, 2);
  13607. //if (!isEdit) return Ok(JsonView(false, msg));
  13608. var subUpd = await _sqlSugar.Updateable(subInfo)
  13609. .UpdateColumns(x => new
  13610. {
  13611. x.Days,
  13612. x.NationalTravelFeeId,
  13613. x.Cost,
  13614. x.Currency,
  13615. x.SubTotal
  13616. })
  13617. .WhereColumns(x => new { x.Id })
  13618. .ExecuteCommandAsync();
  13619. if (subUpd < 1) return Ok(JsonView(false));
  13620. }
  13621. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Type == feeType).Sum(x => x.SubTotal);
  13622. //await EnterExitCostMobileOpNotice(dto.DiId, parentId, dto.CurrUserId);
  13623. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  13624. }
  13625. /// <summary>
  13626. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-批量 Step7
  13627. /// </summary>
  13628. /// <returns></returns>
  13629. [HttpPost]
  13630. [ApiExplorerSettings(IgnoreApi = true)]
  13631. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13632. public async Task<IActionResult> EnterExitCostMobileOpBatchStep7(PostEnterExitCostMobileOpStep7Dto dto)
  13633. {
  13634. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13635. if (dto.DiId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13636. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13637. var infos1 = _mapper.Map<List<Grp_DayOtherPrice>>(dto.Infos);
  13638. var infos = infos1.Select(x => new Grp_DayOtherPrice()
  13639. {
  13640. Id = x.Id,
  13641. Diid = dto.DiId,
  13642. SetDataId = x.SetDataId,
  13643. Index = x.Index,
  13644. Cost = x.Cost,
  13645. Currency = x.Currency,
  13646. SubTotal = x.SubTotal,
  13647. CreateUserId = dto.CurrUserId,
  13648. Remark = x.Remark
  13649. }).ToList();
  13650. var adds = infos.Where(x => x.Id <= 0).ToList();
  13651. var upds = infos.Where(x => x.Id > 0).ToList();
  13652. if (adds.Count > 0)
  13653. {
  13654. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  13655. if (add < 1) return Ok(JsonView(false));
  13656. }
  13657. if (upds.Count > 0)
  13658. {
  13659. var upd = await _sqlSugar.Updateable(adds)
  13660. .UpdateColumns(x => new
  13661. {
  13662. x.Index,
  13663. x.SetDataId,
  13664. x.Cost,
  13665. x.Currency,
  13666. x.SubTotal,
  13667. x.Remark
  13668. })
  13669. .WhereColumns(x => new { x.Id })
  13670. .ExecuteCommandAsync();
  13671. if (upd < 1) return Ok(JsonView(false));
  13672. }
  13673. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == dto.DiId).Sum(x => x.SubTotal);
  13674. //消息通知
  13675. var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.DiId == dto.DiId).First()?.Id ?? 0;
  13676. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  13677. return Ok(JsonView(new { itemTotal = itemTotal }));
  13678. }
  13679. /// <summary>
  13680. /// 团组模块 - 出入境费用-移动端 - OP --> 其他费用-单条 Step7
  13681. /// </summary>
  13682. /// <returns></returns>
  13683. [HttpPost]
  13684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13685. public async Task<IActionResult> EnterExitCostMobileOpSingleStep7(PostEnterExitCostMobileOpSingleStep7Dto dto)
  13686. {
  13687. int subId = dto.SubId;
  13688. int diId = dto.Diid;
  13689. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13690. if (diId < 1) return Ok(JsonView(false, MsgTips.DiId));
  13691. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13692. var subInfo = _mapper.Map<Grp_DayOtherPrice>(dto);
  13693. subInfo.Id = subId;
  13694. subInfo.Diid = dto.Diid;
  13695. subInfo.CreateUserId = dto.CurrUserId;
  13696. int parentId = await EnterExitCostVerifyIsNull(diId, dto.CurrUserId); //主表验证
  13697. if (parentId < 1) return Ok(JsonView(false));
  13698. #region 子表op
  13699. if (subId < 1)//add
  13700. {
  13701. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  13702. if (subAdd < 1) return Ok(JsonView(false));
  13703. }
  13704. else //upd
  13705. {
  13706. ////验证编辑权限
  13707. //(bool isEdit, string msg) = await _enterExitCostRep.MobilePermissionsValidationAsync(dto.Diid, dto.CurrUserId, 2);
  13708. //if (!isEdit) return Ok(JsonView(false, msg));
  13709. var subUpd = await _sqlSugar.Updateable(subInfo)
  13710. .UpdateColumns(x => new
  13711. {
  13712. x.Index,
  13713. x.SetDataId,
  13714. x.Cost,
  13715. x.Currency,
  13716. x.SubTotal,
  13717. x.Remark
  13718. })
  13719. .WhereColumns(x => new { x.Id })
  13720. .ExecuteCommandAsync();
  13721. if (subUpd < 1) return Ok(JsonView(false));
  13722. }
  13723. #endregion
  13724. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPrice>().Where(x => x.IsDel == 0 && x.Diid == diId).Sum(x => x.SubTotal);
  13725. //消息通知
  13726. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  13727. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  13728. }
  13729. /// <summary>
  13730. /// 团组模块 - 出入境费用-移动端 - 3-6子项删除
  13731. /// </summary>
  13732. /// <returns></returns>
  13733. [HttpPost]
  13734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13735. public async Task<IActionResult> EnterExitCostMobileSubItemDel(EnterExitCostSubItemDelDto dto)
  13736. {
  13737. var data = await _enterExitCostRep.PostEnterExitCostSubItemDel(dto);
  13738. if (data.Code != 0)
  13739. {
  13740. return Ok(JsonView(false, data.Msg));
  13741. }
  13742. return Ok(JsonView(true, "操作成功!", data.Data));
  13743. }
  13744. /// <summary>
  13745. /// 团组模块 - 出入境费用-移动端 - 其他费用删除
  13746. /// </summary>
  13747. /// <param name="dto"></param>
  13748. /// <returns></returns>
  13749. [HttpPost]
  13750. public IActionResult EnterExitCostMobileOtherFeeDel(EnterExitCostSubItemDelDto dto)
  13751. {
  13752. var data = new Grp_DayOtherPrice()
  13753. {
  13754. Id = dto.Id,
  13755. IsDel = 1,
  13756. DeleteUserId = dto.DeleteUserId,
  13757. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  13758. };
  13759. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  13760. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  13761. return Ok(JsonView(false, "删除失败!"));
  13762. }
  13763. #endregion
  13764. #endregion
  13765. #region 团组经理模块 出入境费用-草稿 移动端(Android/IOS)
  13766. /// <summary>
  13767. /// 团组模块 - 出入境费用-草稿 - 基础数据源 - 省份归属
  13768. /// </summary>
  13769. /// <returns></returns>
  13770. [HttpGet]
  13771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13772. public async Task<IActionResult> EnterExitDraftMobileProvBelongCostDataSource()
  13773. {
  13774. var provData = await _groupRepository.ProvinceBasicSource();
  13775. return Ok(JsonView(true, "查询成功!", provData));
  13776. }
  13777. /// <summary>
  13778. /// 团组模块 - 出入境费用-草稿-移动端 - 草稿名称数据Data
  13779. /// </summary>
  13780. /// <returns></returns>
  13781. [HttpPost]
  13782. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13783. public async Task<IActionResult> EnterExitCostDraftMobileNameData(EnterExitCostDraftMobileNameDataDto dto)
  13784. {
  13785. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13786. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13787. RefAsync<int> total = 0;
  13788. var data = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>()
  13789. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.DraftName))
  13790. .WhereIF(!string.IsNullOrEmpty(dto.DraftName), x => x.DraftName.Contains(dto.DraftName))
  13791. .Select(x => new
  13792. {
  13793. Id = x.Id,
  13794. DraftName = x.DraftName,
  13795. IsViewOrEdit = SqlFunc.Subqueryable<Grp_EnterExitCostDraftPermission>()
  13796. .Where(x1 => x1.IsDel == 0 && x1.Permission == 1 && x1.DraftId == x.Id && x1.UserId == dto.CurrUserId)
  13797. .Any()
  13798. })
  13799. .OrderByDescending(x => x.Id)
  13800. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13801. return Ok(JsonView(true, "查询成功!", data, total));
  13802. }
  13803. /// <summary>
  13804. /// 出入境费用-草稿 移动端
  13805. /// 获取币种基础数据(含逻辑处理)
  13806. /// </summary>
  13807. /// <returns></returns>
  13808. private async Task<List<CurrencyInfo>> EnterExitCostDraftMobileGetCurrencyInit()
  13809. {
  13810. return await GeneralMethod.EnterExitCostInitRate();
  13811. }
  13812. /// <summary>
  13813. /// 团组模块 - 出入境费用-草稿-移动端 - 基础数据源(Word明细类型、Excel明细类型、默认币种显示)
  13814. /// </summary>
  13815. /// <returns></returns>
  13816. [HttpPost]
  13817. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13818. public async Task<IActionResult> EnterExitCostDraftMobileDataSource(EnterExitCostDraftMobileDataSourceDto dto)
  13819. {
  13820. //验证城市归属并给默认值
  13821. int provinceId = dto.ProvinceId;
  13822. if (provinceId < 1) provinceId = 122;
  13823. var dataSource = await _sqlSugar
  13824. .Queryable<Sys_SetData>()
  13825. .Where(x => x.IsDel == 0 && (x.STid == 72 || x.STid == 73) && x.Remark.Contains(provinceId.ToString()))
  13826. .ToListAsync();
  13827. //三公费用-Word明细类型
  13828. var wordTypeData = dataSource.Where(it => it.STid == 72)
  13829. .Select(x => new SetDataInfoView
  13830. {
  13831. Id = x.Id,
  13832. Name = x.Name,
  13833. Remark = x.Remark
  13834. })
  13835. .ToList();
  13836. //三公费用-Excel明细类型
  13837. var excelTypeData = dataSource.Where(it => it.STid == 73)
  13838. .Select(x => new SetDataInfoView
  13839. {
  13840. Id = x.Id,
  13841. Name = x.Name,
  13842. Remark = x.Remark
  13843. })
  13844. .ToList();
  13845. //默认币种显示
  13846. var _currencyInfos = await EnterExitCostMobileGetCurrencyInit();
  13847. var viewPermissionData = await _enterExitCostRep.PermissionViewUsersAsync();
  13848. return Ok(JsonView(true, "查询成功!", new
  13849. {
  13850. WordTypeData = wordTypeData,
  13851. ExcelTypeData = excelTypeData,
  13852. CurrencyInit = _currencyInfos,
  13853. viewPermissionData = viewPermissionData
  13854. }));
  13855. }
  13856. /// <summary>
  13857. /// 团组模块 - 出入境费用-草稿-移动端 - 团组基础数据Data
  13858. /// </summary>
  13859. /// <returns></returns>
  13860. [HttpPost]
  13861. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13862. public async Task<IActionResult> EnterExitCostDraftMobileGroupData(PostEnterExitCostDraftMobileGroupDataDto dto)
  13863. {
  13864. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13865. RefAsync<int> total = 0;
  13866. int diId = 0;
  13867. var status = int.TryParse(dto.GroupName, out diId);
  13868. var data = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  13869. .Where(x => x.IsDel == 0 && !string.IsNullOrEmpty(x.TeamName))
  13870. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && diId > 0, x => x.Id == diId)
  13871. .WhereIF(!string.IsNullOrEmpty(dto.GroupName) && !status, x => x.TeamName.Contains(dto.GroupName))
  13872. .OrderByDescending(x => x.VisitStartDate)
  13873. .Select(x => new
  13874. {
  13875. Id = x.Id,
  13876. GroupName = x.TeamName
  13877. })
  13878. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13879. return Ok(JsonView(true, "查询成功!", data, total));
  13880. }
  13881. /// <summary>
  13882. /// 团组模块 - 出入境费用-草稿-移动端 - 币种基础数据Data
  13883. /// </summary>
  13884. /// <returns></returns>
  13885. [HttpPost]
  13886. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13887. public async Task<IActionResult> EnterExitCostDraftMobileCurrencyData(PostEnterExitCostDraftMobileCurrencyDataDto dto)
  13888. {
  13889. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13890. RefAsync<int> total = 0;
  13891. var data = await _sqlSugar.Queryable<Sys_SetData>()
  13892. .Where(x => x.IsDel == 0 && x.STid == 66)
  13893. .WhereIF(!string.IsNullOrEmpty(dto.CurrencyName), x => x.Name.ToLower().Contains(dto.CurrencyName) || x.Remark.Contains(dto.CurrencyName))
  13894. .Select(x => new
  13895. {
  13896. id = x.Id,
  13897. name = x.Name,
  13898. remark = x.Remark,
  13899. })
  13900. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  13901. return Ok(JsonView(true, "查询成功!", data, total));
  13902. }
  13903. /// <summary>
  13904. /// 团组模块 - 出入境费用-草稿-移动端 - 其他款项 - 币种、费用类型基础数据Data
  13905. /// </summary>
  13906. /// <returns></returns>
  13907. [HttpPost]
  13908. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13909. public async Task<IActionResult> EnterExitCostDraftMobileOtherItemCurrencyData(PostEnterExitCostDraftMobileOtherItemCurrencyDataDto dto)
  13910. {
  13911. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13912. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  13913. var groupRateData = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, 2477, 98);
  13914. if (groupRateData == null) return Ok(JsonView(false, "请填写“团组汇率-->其他款项”汇率!"));
  13915. var groupOtherRateData = groupRateData.TeamRates;
  13916. var enterExitCostInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  13917. if (enterExitCostInfo == null) return Ok(JsonView(groupOtherRateData));
  13918. var eecRateData = (List<CurrencyInfo>?)CommonFun.GetCurrencyChinaToList(enterExitCostInfo.CurrencyRemark);
  13919. groupOtherRateData = groupOtherRateData
  13920. .Select(x => new TeamRateDescAddCurrencyIdView
  13921. {
  13922. CurrencyId = x.CurrencyId,
  13923. CurrencyName = x.CurrencyName,
  13924. CurrencyCode = x.CurrencyCode,
  13925. Rate = eecRateData.Find(it => it.CurrencyCode.ToUpper().Equals(x.CurrencyCode.ToUpper()))?.Rate ?? x.Rate
  13926. }).ToList();
  13927. var otherFeeTypeData = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 92).Select(x => new { x.Id, x.Name }).ToListAsync();
  13928. return Ok(JsonView(true, "查询成功!", new { groupOtherRateData = groupOtherRateData, otherFeeTypeData = otherFeeTypeData }));
  13929. }
  13930. /// <summary>
  13931. /// 团组模块 - 出入境费用-草稿-移动端 - 实时汇率、签证费用、机票费用 Tips
  13932. /// </summary>
  13933. /// <returns></returns>
  13934. [HttpPost]
  13935. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13936. public async Task<IActionResult> EnterExitCostDraftMobileFeeTips(EnterExitCostDraftMobileFeeTipsDto dto)
  13937. {
  13938. int portType = dto.PortType;
  13939. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  13940. var tipsData = new List<int>() { 1, 2, 3 };
  13941. if (!tipsData.Contains(dto.TipsType)) return Ok(JsonView(false, $"请传入有效的TipsType参数;1 实时汇率;2 签证费用;3 机票费用;"));
  13942. if (dto.TipsType == 1)
  13943. {
  13944. return Ok(JsonView(true, "查询成功!", await GeneralMethod.EnterExitCostLiveRate()));
  13945. }
  13946. else if (dto.TipsType == 2)
  13947. {
  13948. if (portType == 2)
  13949. {
  13950. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  13951. }
  13952. var cityIds = await _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  13953. .Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId)
  13954. .Select(x => x.NationalTravelFeeId)
  13955. .Distinct()
  13956. .ToListAsync();
  13957. if (portType == 2)
  13958. {
  13959. if (!cityIds.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  13960. }
  13961. var countrys = await _sqlSugar.Queryable<Grp_NationalTravelFee>()
  13962. .Where(x => x.IsDel == 0 && cityIds.Contains(x.Id))
  13963. .Select(x => x.Country)
  13964. .Distinct()
  13965. .ToArrayAsync();
  13966. if (portType == 2)
  13967. {
  13968. if (!countrys.Any()) return Ok(JsonView(false, "请先录入出入境费用明细!"));
  13969. }
  13970. (decimal totalAmt, string remark) = await _visaFeeInfoRep.EnterExitCostDraftVisaTips(countrys);
  13971. return Ok(JsonView(true, "查询成功!", new
  13972. {
  13973. totalAmt = totalAmt,
  13974. remark = remark
  13975. }));
  13976. }
  13977. else if (dto.TipsType == 3)
  13978. {
  13979. return Ok(JsonView(false, "暂无机票费用提示信息!"));
  13980. }
  13981. return Ok(JsonView(false));
  13982. }
  13983. /// <summary>
  13984. /// 团组模块 - 出入境费用-草稿-移动端 - 创建
  13985. /// </summary>
  13986. /// <returns></returns>
  13987. [HttpPost]
  13988. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  13989. public async Task<IActionResult> EnterExitCostDraftMobileCreate(EnterExitCostDraftMobileCreateDto dto)
  13990. {
  13991. if (string.IsNullOrEmpty(dto.DraftName)) return Ok(JsonView(false, "草稿名称为空!"));
  13992. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  13993. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  13994. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.DraftName.Equals(dto.DraftName) && it.IsDel == 0);
  13995. if (eecInfo != null) return Ok(JsonView(false, "草稿名称重复!"));
  13996. var rateInfos = await EnterExitCostMobileGetCurrencyInit();
  13997. var info = new Grp_EnterExitCostDraft()
  13998. {
  13999. ProvinceId = dto.ProvinceId,
  14000. DraftName = dto.DraftName,
  14001. CurrencyRemark = CommonFun.GetCurrencyChinaToString(rateInfos),
  14002. CreateUserId = dto.CurrUserId
  14003. };
  14004. _sqlSugar.BeginTran();
  14005. var draftId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  14006. if (draftId < 1)
  14007. {
  14008. _sqlSugar.RollbackTran();
  14009. return Ok(JsonView(false, "草稿创建失败!"));
  14010. }
  14011. //添加默认权限
  14012. await _enterExitCostDraftRep.InitPerm(draftId, dto.CurrUserId);
  14013. _sqlSugar.CommitTran();
  14014. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(draftId, dto.CurrUserId);
  14015. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  14016. mobileInfo.Id = draftId;
  14017. mobileInfo.DraftName = dto.DraftName;
  14018. mobileInfo.Currencys = rateInfos;
  14019. mobileInfo.IsAssignPerm = assignPerm;
  14020. return Ok(JsonView(mobileInfo));
  14021. }
  14022. /// <summary>
  14023. /// 出入境费用-草稿-移动端 查看编辑提示消息
  14024. /// </summary>
  14025. private static string _viewPermStr = $"未分配查看权限,如要查看,请联系市场部或国交部负责人!";
  14026. /// <summary>
  14027. /// 团组模块 - 出入境费用-草稿-移动端 - ParentInfo
  14028. /// </summary>
  14029. /// <returns></returns>
  14030. [HttpPost]
  14031. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14032. public async Task<IActionResult> EnterExitCostDraftMobileParentInfo(EnterExitCostDraftMobileParentInfoDto dto)
  14033. {
  14034. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14035. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14036. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  14037. var mobileInfo = new EnterExitCostDraftMobileParentInfoView();
  14038. mobileInfo.Currencys = await EnterExitCostMobileGetCurrencyInit();
  14039. if (eecInfo == null) return Ok(JsonView(mobileInfo));
  14040. //验证查看编辑权限
  14041. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14042. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14043. mobileInfo = _mapper.Map<EnterExitCostDraftMobileParentInfoView>(eecInfo);
  14044. mobileInfo.ProvinceId = eecInfo.ProvinceId;
  14045. mobileInfo.IsAssignPerm = assignPerm;
  14046. var dayAndCostData = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14047. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14048. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14049. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  14050. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14051. {
  14052. ParentId = dac.ParentId,
  14053. SubId = dac.Id,
  14054. Type = dac.Type,
  14055. Days = dac.Days,
  14056. NationalTravelFeeId = dac.NationalTravelFeeId,
  14057. Arae = $"{ntf.Country}-{ntf.City}",
  14058. Cost = dac.Cost,
  14059. Currency = dac.Currency,
  14060. CurrencyName = sd.Name,
  14061. SubTotal = dac.SubTotal,
  14062. })
  14063. .ToList();
  14064. mobileInfo.ChoiceOneTotalCost = eecInfo.InsidePay;
  14065. mobileInfo.ChoiceTwoJJ = eecInfo.SumJJC;
  14066. mobileInfo.ChoiceTwoGW = eecInfo.SumGWC;
  14067. mobileInfo.ChoiceTwoTD = eecInfo.SumTDC;
  14068. mobileInfo.Currencys = !string.IsNullOrEmpty(eecInfo.CurrencyRemark) ? CommonFun.GetCurrencyChinaToList(eecInfo.CurrencyRemark) : mobileInfo.Currencys;
  14069. mobileInfo.ChoiceThreeTotalCost = dayAndCostData.Where(it => it.Type == 1).Sum(x => x.SubTotal); //住宿费 1
  14070. mobileInfo.ChoiceFourTotalCost = dayAndCostData.Where(it => it.Type == 2).Sum(x => x.SubTotal); //伙食费 2
  14071. mobileInfo.ChoiceFiveTotalCost = dayAndCostData.Where(it => it.Type == 3).Sum(x => x.SubTotal); //公杂费 3
  14072. mobileInfo.ChoiceSixTotalCost = dayAndCostData.Where(it => it.Type == 4).Sum(x => x.SubTotal); //培训费 4
  14073. //其他款项
  14074. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  14075. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  14076. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  14077. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  14078. .OrderBy((dop, sd1, sd2) => dop.Index)
  14079. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  14080. {
  14081. ParentId = dop.ParentId,
  14082. SubId = dop.Id,
  14083. Index = dop.Index,
  14084. SetDataId = dop.SetDataId,
  14085. SetDataName = sd1.Name,
  14086. Cost = dop.Cost,
  14087. Currency = dop.Currency,
  14088. CurrencyName = sd2.Remark,
  14089. SubTotal = dop.SubTotal,
  14090. Remark = dop.Remark,
  14091. })
  14092. .ToArray();
  14093. mobileInfo.OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal);
  14094. return Ok(mobileInfo);
  14095. }
  14096. /// <summary>
  14097. /// 团组模块 - 出入境费用-草稿-移动端 - SubInfo
  14098. /// </summary>
  14099. /// <returns></returns>
  14100. [HttpPost]
  14101. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14102. public async Task<IActionResult> EnterExitCostDraftMobileSubInfo(PostEnterExitCostDraftMobileSubInfoDto dto)
  14103. {
  14104. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14105. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14106. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14107. var subTypes = new List<int>() { 1, 2, 3, 4, 5, 6, 7 };
  14108. if (!subTypes.Contains(dto.SubType)) return Ok(JsonView(false, $"请传入有效的subTypeId!"));
  14109. //验证查看编辑权限
  14110. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14111. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14112. var eecInfo = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().OrderByDescending(x => x.CreateTime).FirstAsync(it => it.Id == dto.DraftId && it.IsDel == 0);
  14113. if (eecInfo == null) return Ok(JsonView(false, $"出入境费用明细未录入!"));
  14114. var subType = dto.SubType;
  14115. if (subType == 1) //1:境内费用
  14116. {
  14117. var oneData = new ChoiceOneMobileSubInfoView()
  14118. {
  14119. Id = eecInfo.Id,
  14120. ChoiceOne = eecInfo.ChoiceOne,
  14121. ChoiceOneTotalCost = eecInfo.InsidePay,
  14122. Visa = eecInfo.Visa,
  14123. VisaRemark = eecInfo.VisaRemark,
  14124. YiMiao = eecInfo.YiMiao,
  14125. HeSuan = eecInfo.HeSuan,
  14126. Service = eecInfo.Service,
  14127. Ticket = eecInfo.Ticket,
  14128. Safe = eecInfo.Safe,
  14129. FirstItemRemark = eecInfo.FirstItemRemark
  14130. };
  14131. return Ok(JsonView(oneData));
  14132. }
  14133. else if (subType == 2) //2:国际旅费
  14134. {
  14135. var twoData = new ChoiceTwoMobileSubInfoView()
  14136. {
  14137. Id = eecInfo.Id,
  14138. ChoiceTwoJJ = eecInfo.SumJJC,
  14139. OutsideJJPay = eecInfo.OutsideJJPay,
  14140. ChoiceTwoGW = eecInfo.SumGWC,
  14141. OutsideGWPay = eecInfo.OutsideGWPay,
  14142. ChoiceTwoTD = eecInfo.SumTDC,
  14143. OutsideTDPay = eecInfo.OutsideTDPay,
  14144. AirJJ = eecInfo.AirJJ,
  14145. AirGW = eecInfo.AirGW,
  14146. AirTD = eecInfo.AirTD,
  14147. CityTranffic = eecInfo.CityTranffic,
  14148. TwoItemRemark = eecInfo.TwoItemRemark
  14149. };
  14150. return Ok(JsonView(twoData));
  14151. }
  14152. else if (subType == 3) //3:住宿费
  14153. {
  14154. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14155. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14156. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14157. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 1)
  14158. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14159. {
  14160. ParentId = dac.ParentId,
  14161. SubId = dac.Id,
  14162. Type = dac.Type,
  14163. Days = dac.Days,
  14164. NationalTravelFeeId = dac.NationalTravelFeeId,
  14165. Arae = $"{ntf.Country}-{ntf.City}",
  14166. Cost = dac.Cost,
  14167. Currency = dac.Currency,
  14168. CurrencyName = sd.Name,
  14169. SubTotal = dac.SubTotal,
  14170. })
  14171. .ToArray();
  14172. var data = new ChoiceDraftMobileSubInfo3To6View()
  14173. {
  14174. ParentId = eecInfo.Id,
  14175. Choice = eecInfo.ChoiceThree,
  14176. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14177. Details = dayAndCostDatas
  14178. };
  14179. return Ok(JsonView(data));
  14180. }
  14181. else if (subType == 4) //4:伙食费
  14182. {
  14183. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14184. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14185. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14186. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 2)
  14187. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14188. {
  14189. ParentId = dac.ParentId,
  14190. SubId = dac.Id,
  14191. Type = dac.Type,
  14192. Days = dac.Days,
  14193. NationalTravelFeeId = dac.NationalTravelFeeId,
  14194. Arae = $"{ntf.Country}-{ntf.City}",
  14195. Cost = dac.Cost,
  14196. Currency = dac.Currency,
  14197. CurrencyName = sd.Name,
  14198. SubTotal = dac.SubTotal,
  14199. })
  14200. .ToArray();
  14201. var data = new ChoiceDraftMobileSubInfo3To6View()
  14202. {
  14203. ParentId = eecInfo.Id,
  14204. Choice = eecInfo.ChoiceFour,
  14205. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14206. Details = dayAndCostDatas
  14207. };
  14208. return Ok(JsonView(data));
  14209. }
  14210. else if (subType == 5) //5:公杂费
  14211. {
  14212. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14213. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14214. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14215. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 3)
  14216. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14217. {
  14218. ParentId = dac.ParentId,
  14219. SubId = dac.Id,
  14220. Type = dac.Type,
  14221. Days = dac.Days,
  14222. NationalTravelFeeId = dac.NationalTravelFeeId,
  14223. Arae = $"{ntf.Country}-{ntf.City}",
  14224. Cost = dac.Cost,
  14225. Currency = dac.Currency,
  14226. CurrencyName = sd.Name,
  14227. SubTotal = dac.SubTotal,
  14228. })
  14229. .ToArray();
  14230. var data = new ChoiceDraftMobileSubInfo3To6View()
  14231. {
  14232. ParentId = eecInfo.Id,
  14233. Choice = eecInfo.ChoiceFive,
  14234. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14235. Details = dayAndCostDatas
  14236. };
  14237. return Ok(JsonView(data));
  14238. }
  14239. else if (subType == 6) //6:培训费
  14240. {
  14241. var dayAndCostDatas = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14242. .LeftJoin<Grp_NationalTravelFee>((dac, ntf) => dac.NationalTravelFeeId == ntf.Id)
  14243. .LeftJoin<Sys_SetData>((dac, ntf, sd) => dac.Currency == sd.Id)
  14244. .Where((dac, ntf, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId && dac.Type == 4)
  14245. .Select((dac, ntf, sd) => new DayAndCostDraftMobileInfoView
  14246. {
  14247. ParentId = dac.ParentId,
  14248. SubId = dac.Id,
  14249. Type = dac.Type,
  14250. Days = dac.Days,
  14251. NationalTravelFeeId = dac.NationalTravelFeeId,
  14252. Arae = $"{ntf.Country}-{ntf.City}",
  14253. Cost = dac.Cost,
  14254. Currency = dac.Currency,
  14255. CurrencyName = sd.Name,
  14256. SubTotal = dac.SubTotal,
  14257. })
  14258. .ToArray();
  14259. var data = new ChoiceDraftMobileSubInfo3To6View()
  14260. {
  14261. ParentId = eecInfo.Id,
  14262. Choice = eecInfo.ChoiceSix,
  14263. TotalCost = dayAndCostDatas.Sum(x => x.SubTotal),
  14264. Details = dayAndCostDatas
  14265. };
  14266. return Ok(JsonView(data));
  14267. }
  14268. else if (subType == 7) //7:其他
  14269. {
  14270. //其他款项
  14271. var otherData = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  14272. .LeftJoin<Sys_SetData>((dop, sd1) => dop.SetDataId == sd1.Id)
  14273. .LeftJoin<Sys_SetData>((dop, sd1, sd2) => dop.Currency == sd2.Id)
  14274. .Where((dop, sd1, sd2) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  14275. .OrderBy((dop, sd1, sd2) => dop.Index)
  14276. .Select((dop, sd1, sd2) => new DayOtherPriceDraftMobileInfoView
  14277. {
  14278. ParentId = dop.ParentId,
  14279. SubId = dop.Id,
  14280. Index = dop.Index,
  14281. SetDataId = dop.SetDataId,
  14282. SetDataName = sd1.Name,
  14283. Cost = dop.Cost,
  14284. Currency = dop.Currency,
  14285. CurrencyName = sd2.Name,
  14286. SubTotal = dop.SubTotal,
  14287. Remark = dop.Remark,
  14288. })
  14289. .ToArray();
  14290. var data = new ChoiceSevenDraftMobileSubInfoView()
  14291. {
  14292. ParentId = eecInfo.Id,
  14293. OtherExpenses_Checked = eecInfo.OtherExpenses_Checked,
  14294. OtherExpensesTotalCost = otherData.Sum(x => x.SubTotal),
  14295. Details = otherData
  14296. };
  14297. return Ok(JsonView(data));
  14298. }
  14299. return Ok(JsonView(false));
  14300. }
  14301. #region op
  14302. ///// <summary>
  14303. ///// 移动端更新费用消息通知
  14304. ///// </summary>
  14305. ///// <param name="draftId"></param>
  14306. ///// <param name="id"></param>
  14307. ///// <param name="currUserId"></param>
  14308. //private async Task EnterExitCostDraftMobileOpNotice(int draftId, int id, int currUserId)
  14309. //{
  14310. // try
  14311. // {
  14312. // ////生成默认文件pdf并且通知人员
  14313. // //var fileView = await GeneralMethod.EnterExitCostDownload(new EnterExitCostDownloadDto()
  14314. // //{
  14315. // // DiId = draftId,
  14316. // // ExportType = 1,
  14317. // // SubTypeId = 1005
  14318. // //}, "pdf");
  14319. // ////发送通知
  14320. // //string fileUrl = (string)fileView.Data.GetType().GetProperty("Url").GetValue(fileView.Data, null);
  14321. // //string md5Sign = GeneralMethod.Encrypt($"{id}&fileName={fileUrl}");
  14322. // //string url = string.Format("http://oa.pan-american-intl.com:4399/#/Sankunginfo?sign={0}&fileName={1}", id, fileUrl);
  14323. // //await AppNoticeLibrary.SendUserMsg_GroupShare_ToGM(draftId, new List<string>() { "208", "233", "21" }, currUserId, url);
  14324. // ////汇率信息记录
  14325. // //await GeneralMethod.RateRecordSave(currUserId, id, "出入境费用");
  14326. // }
  14327. // catch (Exception ex)
  14328. // {
  14329. // //记录日志
  14330. // throw;
  14331. // }
  14332. //}
  14333. /// <summary>
  14334. /// 验证出入境费用数据是否存在
  14335. /// 不存在添加
  14336. /// </summary>
  14337. /// <param name="draftId"></param>
  14338. /// <param name="currUserId"></param>
  14339. /// <returns></returns>
  14340. /// <exception cref="CustomException"></exception>
  14341. private async Task<int> EnterExitCostDraftVerifyIsNull(int draftId, int currUserId)
  14342. {
  14343. var parentId = 0;
  14344. var info = await _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == draftId).OrderByDescending(x => x.CreateTime).FirstAsync();
  14345. if (info != null) parentId = info.Id;
  14346. else
  14347. {
  14348. var currencys = await EnterExitCostDraftMobileGetCurrencyInit();
  14349. int addId = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { CreateUserId = currUserId, CurrencyRemark = JsonConvert.SerializeObject(currencys) }).ExecuteReturnIdentityAsync();
  14350. if (addId < 1) throw new CustomException("出入境费用添加失败!");
  14351. parentId = addId;
  14352. }
  14353. return parentId;
  14354. }
  14355. /// <summary>
  14356. /// 团组模块 - 出入境费用-草稿-移动端 - 查看权限用户
  14357. /// </summary>
  14358. /// <returns></returns>
  14359. [HttpPost]
  14360. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14361. public async Task<IActionResult> EnterExitCostDraftMobileViewPermissionUsers(EnterExitCostDraftMobileViewPermissionUsersDto dto)
  14362. {
  14363. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14364. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14365. //验证查看权限
  14366. (bool isView, bool isSet) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14367. if (!isView) return Ok(JsonView(false, _viewPermStr));
  14368. var userIds = await _sqlSugar
  14369. .Queryable<Grp_EnterExitCostDraftPermission>()
  14370. .Where(x => x.IsDel == 0 && x.DraftId == dto.DraftId)
  14371. .Select(x => x.UserId)
  14372. .ToArrayAsync();
  14373. var perUsers = await _enterExitCostDraftRep.PermissionViewUsersAsync();
  14374. var perUsersView = new List<dynamic>();
  14375. var feeBasePerm = AppSettingsHelper.Get<FeeBasePermView>("FeeBasePerm");
  14376. var viewPermissionData = new List<PermissionViewUserview>();
  14377. if (feeBasePerm.Any())
  14378. {
  14379. foreach (var item in feeBasePerm)
  14380. {
  14381. if (item.Users.Any())
  14382. {
  14383. viewPermissionData.AddRange(item.Users);
  14384. }
  14385. }
  14386. }
  14387. foreach (var item in perUsers)
  14388. {
  14389. bool isView1 = false;
  14390. if (userIds.Any(x => x == item.Id)) isView1 = true;
  14391. else if (viewPermissionData.Any(x => x.Id == dto.CurrUserId) && item.Id == dto.CurrUserId) isView1 = true;
  14392. perUsersView.Add(new { Id = item.Id, Name = item.Name, IsView = isView1 });
  14393. }
  14394. return Ok(JsonView(perUsersView));
  14395. }
  14396. /// <summary>
  14397. /// 团组模块 - 出入境费用-草稿-移动端 - 设置view权限
  14398. /// </summary>
  14399. /// <returns></returns>
  14400. [HttpPost]
  14401. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14402. public async Task<IActionResult> EnterExitCostDraftMobileSetViewPermissiion(EnterExitCostDraftMobileSetViewPermissiionDto dto)
  14403. {
  14404. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14405. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14406. if (dto.UserIds.Length < 1) return Ok(JsonView(false, "请传入有效的userId;"));
  14407. //验证查看编辑权限
  14408. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14409. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14410. var permissions = new List<Grp_EnterExitCostDraftPermission>() { };
  14411. foreach (var userId in dto.UserIds)
  14412. {
  14413. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = userId, CreateUserId = dto.CurrUserId });
  14414. }
  14415. if (permissions.Any())
  14416. {
  14417. if (!permissions.Any(x => x.UserId == dto.CurrUserId))
  14418. {
  14419. permissions.Add(new Grp_EnterExitCostDraftPermission { Permission = 1, DraftId = dto.DraftId, UserId = dto.CurrUserId, CreateUserId = dto.CurrUserId });
  14420. }
  14421. _sqlSugar.BeginTran();
  14422. await _sqlSugar.Deleteable<Grp_EnterExitCostDraftPermission>().Where(it => it.DraftId == dto.DraftId).ExecuteCommandAsync();
  14423. var result = await _sqlSugar.Insertable(permissions).ExecuteCommandAsync();
  14424. if (result < 1)
  14425. {
  14426. _sqlSugar.RollbackTran();
  14427. return Ok(JsonView(false));
  14428. }
  14429. _sqlSugar.CommitTran();
  14430. return Ok(JsonView(true));
  14431. }
  14432. return Ok(JsonView(false));
  14433. }
  14434. /// <summary>
  14435. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 省份
  14436. /// </summary>
  14437. /// <returns></returns>
  14438. [HttpPost]
  14439. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14440. public async Task<IActionResult> EnterExitCostDraftMobileOpProv(EnterExitCostDraftMobileOpProvDto dto)
  14441. {
  14442. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14443. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14444. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14445. if (dto.ProvinceId < 1) return Ok(JsonView(false, "请传入有效的省份Id!"));
  14446. int id = dto.DraftId;
  14447. if (id <= 0) //add
  14448. {
  14449. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14450. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  14451. if (add < 1) return Ok(JsonView(false));
  14452. id = add;
  14453. }
  14454. else //update
  14455. {
  14456. //验证查看编辑权限
  14457. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14458. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14459. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  14460. if (upd < 1) return Ok(JsonView(false));
  14461. }
  14462. return Ok(JsonView(new { parentId = id }));
  14463. }
  14464. /// <summary>
  14465. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 汇率
  14466. /// </summary>
  14467. /// <returns></returns>
  14468. [HttpPost]
  14469. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14470. public async Task<IActionResult> EnterExitCostDraftMobileOpRate(PostEnterExitCostDraftMobileFeeRateOpDto dto)
  14471. {
  14472. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14473. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14474. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14475. if (dto.Currencys.Length < 1) return Ok(JsonView(false, "请传入有效的汇率信息!"));
  14476. var currencyStr = CommonFun.GetCurrencyChinaToString(dto.Currencys.ToList());
  14477. int id = dto.DraftId;
  14478. if (id <= 0) //add
  14479. {
  14480. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14481. var add = await _sqlSugar.Insertable(new Grp_EnterExitCostDraft() { ProvinceId = dto.ProvinceId, CurrencyRemark = currencyStr, CreateUserId = dto.CurrUserId }).ExecuteCommandAsync();
  14482. if (add < 1) return Ok(JsonView(false));
  14483. id = add;
  14484. }
  14485. else //update
  14486. {
  14487. //验证查看编辑权限
  14488. (bool viewPerm, bool assignPerm) = await _enterExitCostDraftRep.PermissionValidationAsync(dto.DraftId, dto.CurrUserId);
  14489. if (!viewPerm) return Ok(JsonView(false, _viewPermStr));
  14490. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>().SetColumns(x => new Grp_EnterExitCostDraft() { CurrencyRemark = currencyStr }).Where(x => x.Id == dto.DraftId).ExecuteCommandAsync();
  14491. if (upd < 1) return Ok(JsonView(false));
  14492. }
  14493. #region 汇率变更时更改币种相关费用
  14494. var opDayCosts = new List<Grp_DayAndCostDraft>();
  14495. var opDayOtherCosts = new List<Grp_DayOtherPriceDraft>();
  14496. var eecCurrencys = dto.Currencys.Select(x => x.CurrencyCode.ToUpper()).ToList();
  14497. var dayCosts = _sqlSugar.Queryable<Grp_DayAndCostDraft>()
  14498. .LeftJoin<Sys_SetData>((dac, sd) => dac.Currency == sd.Id)
  14499. .Where((dac, sd) => dac.IsDel == 0 && dac.ParentId == dto.DraftId)
  14500. .Select((dac, sd) => new
  14501. {
  14502. dac.Id,
  14503. dac.ParentId,
  14504. CurrencyCode = sd.Name,
  14505. dac.Cost
  14506. })
  14507. .ToList();
  14508. var dayOtherCosts = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>()
  14509. .LeftJoin<Sys_SetData>((dop, sd) => dop.Currency == sd.Id)
  14510. .Where((dop, sd) => dop.IsDel == 0 && dop.ParentId == dto.DraftId)
  14511. .Select((dop, sd) => new
  14512. {
  14513. dop.Id,
  14514. dop.ParentId,
  14515. CurrencyCode = sd.Name,
  14516. dop.Cost
  14517. })
  14518. .ToList();
  14519. if (dayCosts.Count > 0)
  14520. {
  14521. var new_dayCosts = dayCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  14522. foreach (var dc in new_dayCosts)
  14523. {
  14524. var thisCurrency = dc.Key.ToUpper();
  14525. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  14526. if (thisRate == 0.00M) continue;
  14527. foreach (var dcSub in dc)
  14528. {
  14529. opDayCosts.Add(new Grp_DayAndCostDraft()
  14530. {
  14531. Id = dcSub.Id,
  14532. ParentId = dcSub.ParentId,
  14533. Cost = dcSub.Cost,
  14534. SubTotal = dcSub.Cost * thisRate,
  14535. Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now:yyyy-MM-dd HH:mm:ss}、opUserId:{dto.CurrUserId}]"
  14536. });
  14537. }
  14538. }
  14539. if (opDayCosts.Count > 0)
  14540. {
  14541. await _sqlSugar.Updateable(opDayCosts).UpdateColumns(x => new { x.SubTotal, x.Remark }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  14542. }
  14543. }
  14544. if (dayOtherCosts.Count > 0)
  14545. {
  14546. var new_dayOtherCosts = dayOtherCosts.Where(x => eecCurrencys.Contains(x.CurrencyCode.ToUpper())).GroupBy(x => x.CurrencyCode);
  14547. foreach (var dc in new_dayOtherCosts)
  14548. {
  14549. var thisCurrency = dc.Key.ToUpper();
  14550. var thisRate = dto.Currencys.Where(x => x.CurrencyCode.ToUpper().Equals(thisCurrency)).First()?.Rate ?? 0.00M;
  14551. if (thisRate == 0.00M) continue;
  14552. foreach (var dcSub in dc)
  14553. {
  14554. opDayOtherCosts.Add(new Grp_DayOtherPriceDraft()
  14555. {
  14556. Id = dcSub.Id,
  14557. ParentId = dcSub.ParentId,
  14558. Cost = dcSub.Cost,
  14559. SubTotal = dcSub.Cost * thisRate,
  14560. // Remark = $"[移动端->汇率变更时费用变更][变更信息:currency:{thisCurrency}、opDatetime:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}、opUserId:{dto.CurrUserId}]"
  14561. });
  14562. }
  14563. }
  14564. if (opDayOtherCosts.Count > 0)
  14565. {
  14566. await _sqlSugar.Updateable(opDayOtherCosts).UpdateColumns(x => new { x.SubTotal }).WhereColumns(x => new { x.Id }).ExecuteCommandAsync();
  14567. }
  14568. }
  14569. #endregion
  14570. ////消息通知
  14571. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14572. ////汇率信息记录
  14573. //await GeneralMethod.RateRecordSave(dto.CurrUserId, id, "出入境费用");
  14574. return Ok(JsonView(new { parentId = id }));
  14575. }
  14576. /// <summary>
  14577. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 复选框
  14578. /// </summary>
  14579. /// <returns></returns>
  14580. [HttpPost]
  14581. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14582. public async Task<IActionResult> EnterExitCostDraftMobileOpCheckbox(PostEnterExitCostDraftMobileFeeOpCheckboxDto dto)
  14583. {
  14584. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14585. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.Id));
  14586. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14587. var checkboxInfo = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  14588. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14589. int id = dto.DraftId;
  14590. if (id <= 0) //add
  14591. {
  14592. checkboxInfo.ProvinceId = dto.ProvinceId;
  14593. checkboxInfo.CreateUserId = dto.CurrUserId;
  14594. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostDraftMobileGetCurrencyInit());
  14595. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  14596. if (add < 1) return Ok(JsonView(false));
  14597. }
  14598. else //update
  14599. {
  14600. var upd = await _sqlSugar.Updateable(checkboxInfo)
  14601. .UpdateColumns(x => new
  14602. {
  14603. x.ChoiceOne,
  14604. x.ChoiceTwo,
  14605. x.SumJJC,
  14606. x.SumGWC,
  14607. x.SumTDC,
  14608. x.ChoiceThree,
  14609. x.ChoiceFour,
  14610. x.ChoiceFive,
  14611. x.ChoiceSix,
  14612. x.OtherExpenses_Checked
  14613. })
  14614. .Where(x => x.Id == id)
  14615. .ExecuteCommandAsync();
  14616. if (upd < 1) return Ok(JsonView(false));
  14617. }
  14618. return Ok(JsonView(new { parentId = id }));
  14619. }
  14620. /// <summary>
  14621. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 3-7项复选框单个复选框
  14622. /// </summary>
  14623. /// <returns></returns>
  14624. [HttpPost]
  14625. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14626. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleCheckbox(EnterExitCostDarftMobileOpSingleCheckboxDto dto)
  14627. {
  14628. int itemTypeId = dto.ItemType, currUserId = dto.CurrUserId, draftId = dto.DraftId, isSelected = dto.IsSelected;
  14629. var itemTypes = new List<int>() { 3, 4, 5, 6, 7 };
  14630. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14631. if (draftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14632. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14633. if (!itemTypes.Contains(itemTypeId)) return Ok(JsonView(false, $"请传入要修改的项类型;3:住宿费; 4:伙食费; 5:公杂费; 6:培训费;7:其他;"));
  14634. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14635. var checkboxInfo = new Grp_EnterExitCostDraft()
  14636. {
  14637. Id = draftId,
  14638. ProvinceId = dto.ProvinceId,
  14639. CreateUserId = currUserId
  14640. };
  14641. if (itemTypeId == 3) checkboxInfo.ChoiceThree = isSelected;
  14642. else if (itemTypeId == 4) checkboxInfo.ChoiceFour = isSelected;
  14643. else if (itemTypeId == 5) checkboxInfo.ChoiceFive = isSelected;
  14644. else if (itemTypeId == 6) checkboxInfo.ChoiceSix = isSelected;
  14645. else if (itemTypeId == 7) checkboxInfo.OtherExpenses_Checked = isSelected;
  14646. if (draftId <= 0) //add
  14647. {
  14648. checkboxInfo.CreateUserId = dto.CurrUserId;
  14649. checkboxInfo.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  14650. var add = await _sqlSugar.Insertable(checkboxInfo).ExecuteCommandAsync();
  14651. if (add < 1) return Ok(JsonView(false));
  14652. }
  14653. else //update
  14654. {
  14655. var upd = await _sqlSugar.Updateable<Grp_EnterExitCostDraft>()
  14656. .SetColumnsIF(itemTypeId == 3, it => it.ChoiceThree == isSelected)
  14657. .SetColumnsIF(itemTypeId == 4, it => it.ChoiceFour == isSelected)
  14658. .SetColumnsIF(itemTypeId == 5, it => it.ChoiceFive == isSelected)
  14659. .SetColumnsIF(itemTypeId == 6, it => it.ChoiceSix == isSelected)
  14660. .SetColumnsIF(itemTypeId == 7, it => it.OtherExpenses_Checked == isSelected)
  14661. .Where(x => x.Id == draftId)
  14662. .ExecuteCommandAsync();
  14663. if (upd < 1) return Ok(JsonView(false));
  14664. }
  14665. return Ok(JsonView(new { parentId = draftId }));
  14666. }
  14667. /// <summary>
  14668. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 境内费用 Step1
  14669. /// </summary>
  14670. /// <returns></returns>
  14671. [HttpPost]
  14672. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14673. public async Task<IActionResult> EnterExitCostDraftMobileOpStep1(PostEnterExitCostDraftMobileOpStep1Dto dto)
  14674. {
  14675. int id = dto.DraftId, currUserId = dto.CurrUserId;
  14676. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14677. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  14678. if (currUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14679. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14680. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  14681. info.ProvinceId = dto.ProvinceId;
  14682. info.FirstItemRemark = dto.FirstItemRemark;
  14683. info.InsidePay = dto.Visa + dto.Service + dto.Safe + dto.Ticket + dto.HeSuan + dto.YiMiao;
  14684. if (id <= 0) //add
  14685. {
  14686. info.CreateUserId = dto.CurrUserId;
  14687. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  14688. var add = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  14689. if (add < 1) return Ok(JsonView(false));
  14690. id = add;
  14691. }
  14692. else //update
  14693. {
  14694. var upd = await _sqlSugar.Updateable(info)
  14695. .UpdateColumns(x => new
  14696. {
  14697. x.ChoiceOne,
  14698. x.InsidePay,
  14699. x.VisaRemark,
  14700. x.Visa,
  14701. x.Service,
  14702. x.Safe,
  14703. x.Ticket,
  14704. x.HeSuan,
  14705. x.YiMiao,
  14706. x.FirstItemRemark
  14707. })
  14708. .Where(x => x.Id == id)
  14709. .ExecuteCommandAsync();
  14710. if (upd < 1) return Ok(JsonView(false));
  14711. }
  14712. ////消息通知
  14713. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14714. return Ok(JsonView(new { parentId = id, itemTotal = info.InsidePay }));
  14715. }
  14716. /// <summary>
  14717. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 国际旅费 Step2
  14718. /// </summary>
  14719. /// <returns></returns>
  14720. [HttpPost]
  14721. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14722. public async Task<IActionResult> EnterExitCostDraftMobileOpStep2(PostEnterExitCostDraftMobileOpStep2Dto dto)
  14723. {
  14724. int id = dto.DraftId;
  14725. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14726. if (id < 1) return Ok(JsonView(false, MsgTips.DiId));
  14727. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14728. if (dto.ProvinceId < 1) dto.ProvinceId = 122;
  14729. var info = _mapper.Map<Grp_EnterExitCostDraft>(dto);
  14730. info.ProvinceId = dto.ProvinceId;
  14731. info.OutsideJJPay = dto.OutsideJJPay;
  14732. info.OutsideGWPay = dto.OutsideGWPay;
  14733. info.OutsideTDPay = dto.OutsideTDPay;
  14734. info.AirJJ = dto.AirJJ;
  14735. info.AirGW = dto.AirGW;
  14736. info.AirTD = dto.AirTD;
  14737. info.CityTranffic = dto.CityTranffic;
  14738. info.TwoItemRemark = dto.TwoItemRemark;
  14739. info.SumJJC = dto.ChoiceTwoJJ;
  14740. info.SumGWC = dto.ChoiceTwoGW;
  14741. info.SumTDC = dto.ChoiceTwoTD;
  14742. decimal jjcItemTotal = 0.00M, gwcItemTotal = 0.00M, tdcItemTotal = 0.00M;
  14743. if (id <= 0) //add
  14744. {
  14745. info.CreateUserId = dto.CurrUserId;
  14746. info.CurrencyRemark = JsonConvert.SerializeObject(await EnterExitCostMobileGetCurrencyInit());
  14747. var addId = await _sqlSugar.Insertable(info).ExecuteReturnIdentityAsync();
  14748. if (addId <= 0) return Ok(JsonView(false));
  14749. id = addId;
  14750. }
  14751. else //update
  14752. {
  14753. var upd = await _sqlSugar.Updateable(info)
  14754. .UpdateColumns(x => new
  14755. {
  14756. x.SumJJC,
  14757. x.OutsideJJPay,
  14758. x.SumGWC,
  14759. x.OutsideGWPay,
  14760. x.SumTDC,
  14761. x.OutsideTDPay,
  14762. x.AirJJ,
  14763. x.AirGW,
  14764. x.AirTD,
  14765. x.CityTranffic,
  14766. x.TwoItemRemark
  14767. })
  14768. .Where(x => x.Id == id)
  14769. .ExecuteCommandAsync();
  14770. if (upd < 1) return Ok(JsonView(false));
  14771. }
  14772. jjcItemTotal = info.AirJJ + info.CityTranffic;
  14773. gwcItemTotal = info.AirGW + info.CityTranffic;
  14774. tdcItemTotal = info.AirTD + info.CityTranffic;
  14775. ////消息通知
  14776. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14777. return Ok(JsonView(new
  14778. {
  14779. parentId = id,
  14780. choiceTwoJJ = dto.ChoiceTwoJJ,
  14781. jjcItemTotal = jjcItemTotal,
  14782. choiceTwoGW = dto.ChoiceTwoGW,
  14783. gwcItemTotal = gwcItemTotal,
  14784. choiceTwoTD = dto.ChoiceTwoTD,
  14785. tdcItemTotal = tdcItemTotal
  14786. }));
  14787. }
  14788. /// <summary>
  14789. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 批量(住宿、伙食、公杂、培训) Step3-Step6
  14790. /// </summary>
  14791. /// <returns></returns>
  14792. [HttpPost]
  14793. [ApiExplorerSettings(IgnoreApi = true)]
  14794. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14795. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep3To6(PostEnterExitCostDraftMobileOpStep3To6Dto dto)
  14796. {
  14797. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14798. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14799. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14800. if (dto.Infos.Length < 1) return Ok(JsonView(false, "请传入有效的费用信息!"));
  14801. var feeTypeIds = new List<int>() { 1, 2, 3, 4, };
  14802. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  14803. var infos1 = _mapper.Map<List<Grp_DayAndCostDraft>>(dto.Infos);
  14804. var infos = infos1.Select(x => new Grp_DayAndCostDraft
  14805. {
  14806. Id = x.Id,
  14807. ParentId = dto.DraftId,
  14808. Type = dto.FeeType,
  14809. Days = x.Days,
  14810. NationalTravelFeeId = x.NationalTravelFeeId,
  14811. Cost = x.Cost,
  14812. Currency = x.Currency,
  14813. SubTotal = x.SubTotal,
  14814. CreateUserId = dto.CurrUserId
  14815. })
  14816. .ToList();
  14817. var adds = infos.Where(x => x.Id <= 0).ToList();
  14818. var upds = infos.Where(x => x.Id > 0).ToList();
  14819. if (adds.Count > 0)
  14820. {
  14821. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  14822. if (add < 1) return Ok(JsonView(false));
  14823. }
  14824. if (upds.Count > 0)
  14825. {
  14826. var upd = await _sqlSugar.Updateable(adds)
  14827. .UpdateColumns(x => new
  14828. {
  14829. x.Days,
  14830. x.NationalTravelFeeId,
  14831. x.Cost,
  14832. x.Currency,
  14833. x.SubTotal
  14834. })
  14835. .WhereColumns(x => new { x.Id })
  14836. .ExecuteCommandAsync();
  14837. if (upd < 1) return Ok(JsonView(false));
  14838. }
  14839. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == dto.FeeType).Sum(x => x.SubTotal);
  14840. ////消息通知
  14841. //var id = _sqlSugar.Queryable<Grp_EnterExitCost>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).First()?.Id ?? 0;
  14842. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14843. return Ok(JsonView(new { itemTotal = itemTotal }));
  14844. }
  14845. /// <summary>
  14846. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 单条(住宿、伙食、公杂、培训) Step3-Step6
  14847. /// </summary>
  14848. /// <returns></returns>
  14849. [HttpPost]
  14850. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14851. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep3To6(PostEnterExitCostDraftMobileOpSingleStep3To6Dto dto)
  14852. {
  14853. var feeTypeIds = new List<int>() { 3, 4, 5, 6 };
  14854. int subId = dto.SubId, feeType = dto.FeeType;
  14855. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14856. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14857. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14858. if (!feeTypeIds.Contains(dto.FeeType)) return Ok(JsonView(false, "请传入有效的费用类型!"));
  14859. var subInfo = _mapper.Map<Grp_DayAndCostDraft>(dto);
  14860. subInfo.Id = subId;
  14861. subInfo.ParentId = dto.DraftId;
  14862. if (feeType == 3) subInfo.Type = 1;
  14863. else if (feeType == 4) subInfo.Type = 2;
  14864. else if (feeType == 5) subInfo.Type = 3;
  14865. else if (feeType == 6) subInfo.Type = 4;
  14866. subInfo.CreateUserId = dto.CurrUserId;
  14867. int parentId = await EnterExitCostDraftVerifyIsNull(dto.DraftId, dto.CurrUserId); //主表验证
  14868. if (parentId < 1) return Ok(JsonView(false));
  14869. //子表op
  14870. if (subId < 1)
  14871. {
  14872. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  14873. if (subAdd < 1) return Ok(JsonView(false));
  14874. }
  14875. else
  14876. {
  14877. var subUpd = await _sqlSugar.Updateable(subInfo)
  14878. .UpdateColumns(x => new
  14879. {
  14880. x.Days,
  14881. x.NationalTravelFeeId,
  14882. x.Cost,
  14883. x.Currency,
  14884. x.SubTotal
  14885. })
  14886. .WhereColumns(x => new { x.Id })
  14887. .ExecuteCommandAsync();
  14888. if (subUpd < 1) return Ok(JsonView(false));
  14889. }
  14890. var itemTotal = _sqlSugar.Queryable<Grp_DayAndCostDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId && x.Type == feeType).Sum(x => x.SubTotal);
  14891. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  14892. }
  14893. /// <summary>
  14894. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-批量 Step7
  14895. /// </summary>
  14896. /// <returns></returns>
  14897. [HttpPost]
  14898. [ApiExplorerSettings(IgnoreApi = true)]
  14899. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14900. public async Task<IActionResult> EnterExitCostDraftMobileOpBatchStep7(PostEnterExitCostDraftMobileOpStep7Dto dto)
  14901. {
  14902. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14903. if (dto.DraftId < 1) return Ok(JsonView(false, MsgTips.DiId));
  14904. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14905. var infos1 = _mapper.Map<List<Grp_DayOtherPriceDraft>>(dto.Infos);
  14906. var infos = infos1.Select(x => new Grp_DayOtherPriceDraft()
  14907. {
  14908. Id = x.Id,
  14909. ParentId = dto.DraftId,
  14910. SetDataId = x.SetDataId,
  14911. Index = x.Index,
  14912. Cost = x.Cost,
  14913. Currency = x.Currency,
  14914. SubTotal = x.SubTotal,
  14915. CreateUserId = dto.CurrUserId,
  14916. Remark = x.Remark
  14917. }).ToList();
  14918. var adds = infos.Where(x => x.Id <= 0).ToList();
  14919. var upds = infos.Where(x => x.Id > 0).ToList();
  14920. if (adds.Count > 0)
  14921. {
  14922. var add = await _sqlSugar.Insertable(adds).ExecuteCommandAsync();
  14923. if (add < 1) return Ok(JsonView(false));
  14924. }
  14925. if (upds.Count > 0)
  14926. {
  14927. var upd = await _sqlSugar.Updateable(adds)
  14928. .UpdateColumns(x => new
  14929. {
  14930. x.Index,
  14931. x.SetDataId,
  14932. x.Cost,
  14933. x.Currency,
  14934. x.SubTotal,
  14935. x.Remark
  14936. })
  14937. .WhereColumns(x => new { x.Id })
  14938. .ExecuteCommandAsync();
  14939. if (upd < 1) return Ok(JsonView(false));
  14940. }
  14941. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == dto.DraftId).Sum(x => x.SubTotal);
  14942. //消息通知
  14943. //var id = _sqlSugar.Queryable<Grp_EnterExitCostDraft>().Where(x => x.IsDel == 0 && x.Id == dto.DraftId).First()?.Id ?? 0;
  14944. //await EnterExitCostMobileOpNotice(dto.DiId, id, dto.CurrUserId);
  14945. return Ok(JsonView(new { itemTotal = itemTotal }));
  14946. }
  14947. /// <summary>
  14948. /// 团组模块 - 出入境费用-草稿-移动端 - OP --> 其他费用-单条 Step7
  14949. /// </summary>
  14950. /// <returns></returns>
  14951. [HttpPost]
  14952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14953. public async Task<IActionResult> EnterExitCostDraftMobileOpSingleStep7(PostEnterExitCostDraftMobileOpSingleStep7Dto dto)
  14954. {
  14955. int subId = dto.SubId, id = dto.DraftId;
  14956. if (!_portTypeData.Contains(dto.PortType)) return Ok(JsonView(false, MsgTips.Port));
  14957. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  14958. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  14959. var subInfo = _mapper.Map<Grp_DayOtherPriceDraft>(dto);
  14960. subInfo.Id = subId;
  14961. subInfo.ParentId = id;
  14962. subInfo.CreateUserId = dto.CurrUserId;
  14963. int parentId = await EnterExitCostDraftVerifyIsNull(id, dto.CurrUserId); //主表验证
  14964. if (parentId < 1) return Ok(JsonView(false));
  14965. #region 子表op
  14966. if (subId < 1)//add
  14967. {
  14968. var subAdd = await _sqlSugar.Insertable(subInfo).ExecuteCommandAsync();
  14969. if (subAdd < 1) return Ok(JsonView(false));
  14970. }
  14971. else //upd
  14972. {
  14973. var subUpd = await _sqlSugar.Updateable(subInfo)
  14974. .UpdateColumns(x => new
  14975. {
  14976. x.Index,
  14977. x.SetDataId,
  14978. x.Cost,
  14979. x.Currency,
  14980. x.SubTotal,
  14981. x.Remark
  14982. })
  14983. .WhereColumns(x => new { x.Id })
  14984. .ExecuteCommandAsync();
  14985. if (subUpd < 1) return Ok(JsonView(false));
  14986. }
  14987. #endregion
  14988. var itemTotal = _sqlSugar.Queryable<Grp_DayOtherPriceDraft>().Where(x => x.IsDel == 0 && x.ParentId == id).Sum(x => x.SubTotal);
  14989. ////消息通知
  14990. //await EnterExitCostMobileOpNotice(dto.Diid, parentId, dto.CurrUserId);
  14991. return Ok(JsonView(new { parentId = parentId, itemTotal = itemTotal }));
  14992. }
  14993. /// <summary>
  14994. /// 团组模块 - 出入境费用-草稿-移动端 - 3-6子项删除
  14995. /// </summary>
  14996. /// <returns></returns>
  14997. [HttpPost]
  14998. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  14999. public async Task<IActionResult> EnterExitCostDraftMobileSubItemDel(EnterExitCostDraftSubItemDelDto dto)
  15000. {
  15001. var data = await _enterExitCostDraftRep.EnterExitCostDraftSubItemDel(dto);
  15002. if (data.Code != 0)
  15003. {
  15004. return Ok(JsonView(false, data.Msg));
  15005. }
  15006. return Ok(JsonView(true, "操作成功!", data.Data));
  15007. }
  15008. /// <summary>
  15009. /// 团组模块 - 出入境费用-草稿-移动端 - 其他费用删除
  15010. /// </summary>
  15011. /// <param name="dto"></param>
  15012. /// <returns></returns>
  15013. [HttpPost]
  15014. public IActionResult EnterExitCostDraftMobileOtherFeeDel(EnterExitCostDraftSubItemDelDto dto)
  15015. {
  15016. var data = new Grp_DayOtherPriceDraft()
  15017. {
  15018. Id = dto.Id,
  15019. IsDel = 1,
  15020. DeleteUserId = dto.DeleteUserId,
  15021. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")
  15022. };
  15023. var del = _sqlSugar.Updateable(data).UpdateColumns(it => new { it.IsDel, it.DeleteUserId, it.DeleteTime }).ExecuteCommand();
  15024. if (del > 0) return Ok(JsonView(true, "删除成功!"));
  15025. return Ok(JsonView(false, "删除失败!"));
  15026. }
  15027. #endregion
  15028. #endregion
  15029. #region 团组经理模块 出入境费用报价表
  15030. /// <summary>
  15031. /// 团组模块 - 出入境费用报价表 - 初始化数据源(币种类型)
  15032. /// </summary>
  15033. /// <returns></returns>
  15034. [HttpPost]
  15035. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15036. public async Task<IActionResult> EnterExitCostQuoteInitData(PortDtoBase dto)
  15037. {
  15038. var initRates = await GeneralMethod.EnterExitCostInitRate();
  15039. var liveRates = await GeneralMethod.EnterExitCostLiveRate();
  15040. var cnyInfo = new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.0000M };
  15041. initRates.Insert(0, cnyInfo);
  15042. liveRates.Insert(0, cnyInfo);
  15043. return Ok(JsonView(true, "查询成功!", new
  15044. {
  15045. InitRates = initRates,
  15046. LiveRates = liveRates
  15047. }));
  15048. }
  15049. /// <summary>
  15050. /// 团组模块 - 出入境费用报价表 - 报价表名称列表
  15051. /// </summary>
  15052. /// <returns></returns>
  15053. [HttpPost]
  15054. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15055. public async Task<IActionResult> EnterExitCostQuoteNameList(EnterExitCostQuoteNameListDto dto)
  15056. {
  15057. return Ok(await _enterExitCostQuoteRep.QuoteNameListAsync(dto));
  15058. }
  15059. /// <summary>
  15060. /// 团组模块 - 出入境费用报价表 - 团组名称列表
  15061. /// </summary>
  15062. /// <returns></returns>
  15063. [HttpPost]
  15064. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15065. public async Task<IActionResult> EnterExitCostQuoteGroupNameList(EnterExitCostQuoteGroupNameListDto dto)
  15066. {
  15067. return Ok(await _enterExitCostQuoteRep.GroupNameListAsync(dto));
  15068. }
  15069. /// <summary>
  15070. /// 团组模块 - 出入境费用报价表 - 根据团组Id获出入境费用相关信息
  15071. /// </summary>
  15072. /// <returns></returns>
  15073. [HttpPost]
  15074. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15075. public async Task<IActionResult> EnterExitCostQuoteEntryExitCosts(EnterExitCostInfobyDiIdDto dto)
  15076. {
  15077. int groupId = dto.DiId,
  15078. currUserId = dto.CurrUserId;
  15079. if (groupId < 1) return Ok(JsonView(false, "请传入有效的GroupId;"));
  15080. if (currUserId < 1) return Ok(JsonView(false, "请传入有效的CurrUserId;"));
  15081. //验证报价数据是否存在
  15082. var isNull = await _sqlSugar.Queryable<Grp_EnterExitCostQuote>().FirstAsync(x => x.IsDel == 0 && x.GroupId == dto.DiId);
  15083. if (isNull != null)
  15084. {
  15085. var info1 = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = isNull.Id });
  15086. if (!info1.Rates.Any())
  15087. {
  15088. var rates = await GeneralMethod.EnterExitCostInitRate();
  15089. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15090. info1.Rates = rates.ToArray();
  15091. }
  15092. return Ok(JsonView(info1));
  15093. }
  15094. var result = await _enterExitCostQuoteRep.InfoByGroupIdAsync(dto.DiId);
  15095. result.GroupId = groupId;
  15096. //处理报价名称
  15097. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.DiId && x.IsDel == 0);
  15098. if (groupInfo != null)
  15099. {
  15100. var visitCountry = groupInfo.VisitCountry;
  15101. if (!string.IsNullOrEmpty(visitCountry))
  15102. {
  15103. string quoteName = string.Empty;
  15104. if (visitCountry.Contains("|"))
  15105. {
  15106. var countrys = visitCountry.Split("|");
  15107. quoteName = string.Join("、", countrys);
  15108. }
  15109. else quoteName = visitCountry;
  15110. quoteName += $"团组报价表";
  15111. result.Name = quoteName;
  15112. }
  15113. }
  15114. var info = await _enterExitCostRep.GetEnterExitCostInfoByDiId(dto);
  15115. if (info.Code != StatusCodes.Status200OK)
  15116. {
  15117. if (!result.Rates.Any())
  15118. {
  15119. var rates = await GeneralMethod.EnterExitCostInitRate();
  15120. result.Rates = rates.ToArray();
  15121. }
  15122. return Ok(JsonView(true, $"出入境费用明细未填写!", result));
  15123. }
  15124. var infoView = info.Data as EnterExitCostInfoView;
  15125. if (infoView == null) return Ok(JsonView(false, "数据类型转换失败!;"));
  15126. var countryFees = await _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).ToListAsync();
  15127. var cityFilter = new List<string>() { "全部城市", "其他城市" };
  15128. var currencys = await _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.STid == 66).ToListAsync();
  15129. var eecRates = infoView.Currencys;
  15130. //默认添加人名币
  15131. if (!eecRates.Any(x => x.CurrencyCode.Equals("CNY")))
  15132. {
  15133. eecRates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15134. }
  15135. //处理团组人数
  15136. int pplNum = 1;
  15137. if (groupInfo != null) pplNum = groupInfo.VisitPNumber;
  15138. var views = new List<QuoteSubItemInfo>();
  15139. #region 数据填充
  15140. var intTravelCosts = new List<QuoteSubItemInfo>();
  15141. #region 机票费用 1354
  15142. int intTravelIndex = 1;
  15143. if (infoView.SumJJC == 1)
  15144. {
  15145. intTravelCosts.Add(new QuoteSubItemInfo
  15146. {
  15147. ItemId = 1354,
  15148. Index = intTravelIndex,
  15149. FeeName = "经济舱",
  15150. UnitPrice = infoView.AirJJ,
  15151. Currency = "CNY",
  15152. Quantity = 1,
  15153. PplNum = 1,
  15154. TotalAmt = infoView.AirJJ,
  15155. Remark = "",
  15156. });
  15157. intTravelIndex++;
  15158. }
  15159. if (infoView.SumGWC == 1)
  15160. {
  15161. intTravelCosts.Add(new QuoteSubItemInfo
  15162. {
  15163. ItemId = 1354,
  15164. Index = intTravelIndex,
  15165. FeeName = "公务舱",
  15166. UnitPrice = infoView.AirGW,
  15167. Currency = "CNY",
  15168. Quantity = 1,
  15169. PplNum = 1,
  15170. TotalAmt = infoView.AirGW,
  15171. Remark = "",
  15172. });
  15173. intTravelIndex++;
  15174. }
  15175. if (infoView.SumTDC == 1)
  15176. {
  15177. intTravelCosts.Add(new QuoteSubItemInfo
  15178. {
  15179. ItemId = 1354,
  15180. Index = intTravelIndex,
  15181. FeeName = "头等舱",
  15182. UnitPrice = infoView.AirTD,
  15183. Currency = "CNY",
  15184. Quantity = 1,
  15185. PplNum = 1,
  15186. TotalAmt = infoView.AirTD,
  15187. Remark = "",
  15188. });
  15189. intTravelIndex++;
  15190. }
  15191. intTravelCosts.Add(new QuoteSubItemInfo
  15192. {
  15193. ItemId = 1354,
  15194. Index = intTravelIndex,
  15195. FeeName = "城市间交通费用(经济舱)",
  15196. UnitPrice = infoView.CityTranffic,
  15197. Currency = "CNY",
  15198. Quantity = 1,
  15199. PplNum = pplNum,
  15200. TotalAmt = infoView.CityTranffic * pplNum,
  15201. Remark = "",
  15202. });
  15203. intTravelCosts.Add(new QuoteSubItemInfo
  15204. {
  15205. ItemId = 1354,
  15206. Index = intTravelIndex,
  15207. FeeName = "城市间交通费用(公务舱)",
  15208. UnitPrice = infoView.CityTranffic1,
  15209. Currency = "CNY",
  15210. Quantity = 1,
  15211. PplNum = pplNum,
  15212. TotalAmt = infoView.CityTranffic1 * pplNum,
  15213. Remark = "",
  15214. });
  15215. intTravelCosts.Add(new QuoteSubItemInfo
  15216. {
  15217. ItemId = 1354,
  15218. Index = intTravelIndex,
  15219. FeeName = "城市间交通费用(头等舱)",
  15220. UnitPrice = infoView.CityTranffic2,
  15221. Currency = "CNY",
  15222. Quantity = 1,
  15223. PplNum = pplNum,
  15224. TotalAmt = infoView.CityTranffic2 * pplNum,
  15225. Remark = "",
  15226. });
  15227. views.AddRange(intTravelCosts);
  15228. #endregion
  15229. var accomCosts = new List<QuoteSubItemInfo>();
  15230. #region 住宿费 1355
  15231. if (infoView.QuarterageData.Any())
  15232. {
  15233. int accomIndex = 1;
  15234. int accomItemTypeId = 1355;
  15235. var groupData = infoView.QuarterageData.GroupBy(x => x.NationalTravelFeeId);
  15236. foreach (var item in groupData)
  15237. {
  15238. string feeName = string.Empty;
  15239. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  15240. if (countryInfo != null)
  15241. {
  15242. feeName = countryInfo.Country;
  15243. var city = countryInfo.City;
  15244. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  15245. {
  15246. feeName += $"-{city}";
  15247. }
  15248. }
  15249. var hotelInfo = item.FirstOrDefault();
  15250. if (hotelInfo == null) continue;
  15251. var thisCurrency = currencys.FirstOrDefault(x => x.Id == hotelInfo.Currency)?.Name ?? "nuknow";
  15252. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  15253. int quantity = item.ToList().Count;
  15254. accomCosts.Add(new QuoteSubItemInfo
  15255. {
  15256. ItemId = accomItemTypeId,
  15257. Index = accomIndex,
  15258. FeeName = feeName,
  15259. UnitPrice = hotelInfo.Cost,
  15260. Currency = thisCurrency,
  15261. Quantity = quantity,
  15262. PplNum = pplNum,
  15263. TotalAmt = hotelInfo.Cost * thisRate * quantity * pplNum,
  15264. Remark = "",
  15265. });
  15266. accomIndex++;
  15267. }
  15268. views.AddRange(accomCosts);
  15269. }
  15270. #endregion
  15271. var mealCosts = new List<QuoteSubItemInfo>();
  15272. #region 餐饮费 1356
  15273. if (infoView.BoardWagesData.Any())
  15274. {
  15275. var mealIndex = 1;
  15276. int mealItemTypeId = 1356;
  15277. var groupData = infoView.BoardWagesData.GroupBy(x => x.NationalTravelFeeId);
  15278. foreach (var item in groupData)
  15279. {
  15280. string feeName = string.Empty;
  15281. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  15282. if (countryInfo != null)
  15283. {
  15284. feeName = countryInfo.Country;
  15285. var city = countryInfo.City;
  15286. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  15287. {
  15288. feeName += $"-{city}";
  15289. }
  15290. }
  15291. var mealInfo = item.FirstOrDefault();
  15292. if (mealInfo == null) continue;
  15293. var thisCurrency = currencys.FirstOrDefault(x => x.Id == mealInfo.Currency)?.Name ?? "nuknow";
  15294. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  15295. int quantity = item.ToList().Count;
  15296. mealCosts.Add(new QuoteSubItemInfo
  15297. {
  15298. ItemId = mealItemTypeId,
  15299. Index = mealIndex,
  15300. FeeName = feeName,
  15301. UnitPrice = mealInfo.Cost,
  15302. Currency = thisCurrency,
  15303. Quantity = quantity,
  15304. PplNum = pplNum,
  15305. TotalAmt = mealInfo.Cost * thisRate * quantity * pplNum,
  15306. Remark = "",
  15307. });
  15308. mealIndex++;
  15309. }
  15310. views.AddRange(mealCosts);
  15311. }
  15312. #endregion
  15313. var miscCosts = new List<QuoteSubItemInfo>();
  15314. #region 公杂费 1364
  15315. if (infoView.MiscellaneousFeeData.Any())
  15316. {
  15317. var miscIndex = 1;
  15318. int miscItemTypeId = 1364;
  15319. var groupData = infoView.MiscellaneousFeeData.GroupBy(x => x.NationalTravelFeeId);
  15320. foreach (var item in groupData)
  15321. {
  15322. string feeName = string.Empty;
  15323. var countryInfo = countryFees.FirstOrDefault(x => x.Id == item.Key);
  15324. if (countryInfo != null)
  15325. {
  15326. feeName = countryInfo.Country;
  15327. var city = countryInfo.City;
  15328. if (!string.IsNullOrEmpty(city) && cityFilter.Any(x => !x.Contains(city)))
  15329. {
  15330. feeName += $"-{city}";
  15331. }
  15332. }
  15333. var miscInfo = item.FirstOrDefault();
  15334. if (miscInfo == null) continue;
  15335. var thisCurrency = currencys.FirstOrDefault(x => x.Id == miscInfo.Currency)?.Name ?? "nuknow";
  15336. var thisRate = eecRates.FirstOrDefault(x => x.CurrencyCode.Equals(thisCurrency))?.Rate ?? 1.0000M;
  15337. int quantity = item.ToList().Count;
  15338. miscCosts.Add(new QuoteSubItemInfo
  15339. {
  15340. ItemId = miscItemTypeId,
  15341. Index = miscIndex,
  15342. FeeName = feeName,
  15343. UnitPrice = miscInfo.Cost,
  15344. Currency = thisCurrency,
  15345. Quantity = quantity,
  15346. PplNum = pplNum,
  15347. TotalAmt = miscInfo.Cost * thisRate * quantity * pplNum,
  15348. Remark = "",
  15349. });
  15350. miscIndex++;
  15351. }
  15352. views.AddRange(miscCosts);
  15353. }
  15354. #endregion
  15355. #region 签证+保险 1362
  15356. int visaInsIndex = 1;
  15357. int visaInsItemTypeId = 1362;
  15358. if (infoView.Visa > 0)
  15359. {
  15360. views.Add(new QuoteSubItemInfo()
  15361. {
  15362. ItemId = visaInsItemTypeId,
  15363. Index = visaInsIndex,
  15364. FeeName = $"签证",
  15365. UnitPrice = infoView.Visa,
  15366. Currency = $"CNY",
  15367. Quantity = 1,
  15368. PplNum = pplNum,
  15369. TotalAmt = infoView.Visa * pplNum,
  15370. Remark = "",
  15371. });
  15372. visaInsIndex++;
  15373. }
  15374. if (infoView.Safe > 0)
  15375. {
  15376. views.Add(new QuoteSubItemInfo()
  15377. {
  15378. ItemId = visaInsItemTypeId,
  15379. Index = visaInsIndex,
  15380. FeeName = $"保险",
  15381. UnitPrice = infoView.Safe,
  15382. Currency = $"CNY",
  15383. Quantity = 1,
  15384. PplNum = pplNum,
  15385. TotalAmt = infoView.Safe * pplNum,
  15386. Remark = "",
  15387. });
  15388. }
  15389. #endregion
  15390. #region 服务费 1363
  15391. int serviceFeeIndex = 1;
  15392. int serviceFeeItemTypeId = 1363;
  15393. if (infoView.Service > 0)
  15394. {
  15395. views.Add(new QuoteSubItemInfo()
  15396. {
  15397. ItemId = serviceFeeItemTypeId,
  15398. Index = serviceFeeIndex,
  15399. FeeName = $"服务费",
  15400. UnitPrice = infoView.Service,
  15401. Currency = $"CNY",
  15402. Quantity = 1,
  15403. PplNum = pplNum,
  15404. TotalAmt = infoView.Service * pplNum,
  15405. Remark = "",
  15406. });
  15407. }
  15408. #endregion
  15409. #endregion
  15410. if (result.FeeItems.Any())
  15411. {
  15412. result.FeeItems.Select(x =>
  15413. {
  15414. var feeInfos = views.Where(y => y.ItemId == x.ItemId).OrderBy(y => y.Index).ToArray();
  15415. if (feeInfos.Any()) x.Infos = feeInfos;
  15416. return x;
  15417. }
  15418. ).OrderBy(x => x.Index)
  15419. .ToList();
  15420. if (!result.Rates.Any())
  15421. {
  15422. if (eecRates.Any()) result.Rates = eecRates?.ToArray() ?? Array.Empty<CurrencyInfo>();
  15423. else
  15424. {
  15425. var rates = await GeneralMethod.EnterExitCostInitRate();
  15426. rates.Insert(0, new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15427. result.Rates = rates.ToArray();
  15428. }
  15429. }
  15430. }
  15431. return Ok(JsonView(result));
  15432. }
  15433. /// <summary>
  15434. /// 团组模块 - 出入境费用报价表 - Info
  15435. /// </summary>
  15436. /// <returns></returns>
  15437. [HttpPost]
  15438. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15439. public async Task<IActionResult> EnterExitCostQuoteInfo(EnterExitCostQuoteInfoDto dto)
  15440. {
  15441. var info = await _enterExitCostQuoteRep.InfoAsync(dto);
  15442. if (!info.Rates.Any())
  15443. {
  15444. var rates = await GeneralMethod.EnterExitCostInitRate();
  15445. rates.Add(new CurrencyInfo() { CurrencyCode = "CNY", CurrencyName = "人民币", Rate = 1.00000M });
  15446. info.Rates = rates.ToArray();
  15447. }
  15448. return Ok(JsonView(info));
  15449. }
  15450. /// <summary>
  15451. /// 团组模块 - 出入境费用报价表 - OP
  15452. /// </summary>
  15453. /// <returns></returns>
  15454. [HttpPost]
  15455. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15456. public async Task<IActionResult> EnterExitCostQuoteOp(EnterExitCostQuoteOpDto dto)
  15457. {
  15458. return Ok(await _enterExitCostQuoteRep.OpAsync(dto));
  15459. }
  15460. /// <summary>
  15461. /// 团组模块 - 出入境费用报价表 - 删除 项
  15462. /// </summary>
  15463. /// <returns></returns>
  15464. [HttpPost]
  15465. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15466. public async Task<IActionResult> EnterExitCostQuoteItemDel(EnterExitCostQuoteItemDelDto dto)
  15467. {
  15468. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  15469. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15470. return Ok(await _enterExitCostQuoteRep.ItemDelAsync(dto));
  15471. }
  15472. /// <summary>
  15473. /// 团组模块 - 出入境费用报价表 - 导出
  15474. /// </summary>
  15475. /// <returns></returns>
  15476. [HttpPost]
  15477. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15478. public async Task<IActionResult> EnterExitCostQuoteExcelExport(EnterExitCostQuoteExcelExportDto dto)
  15479. {
  15480. if (dto.Id < 1) return Ok(JsonView(false, MsgTips.Id));
  15481. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  15482. var info = await _enterExitCostQuoteRep.InfoAsync(new EnterExitCostQuoteInfoDto() { Id = dto.Id });
  15483. if (info == null) return Ok(JsonView(false, "报价信息未填写!"));
  15484. var rates = info.Rates;
  15485. var intTravelCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1354);//国际旅费
  15486. var accomCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1355); //住宿费
  15487. var mealCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1356); //餐饮费
  15488. var vehArranges = info.FeeItems.FirstOrDefault(x => x.ItemId == 1357); //车辆安排
  15489. var inviteTo = info.FeeItems.FirstOrDefault(x => x.ItemId == 1358); //邀请函发放对象
  15490. var inviteCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1359); //邀请函费用
  15491. var inviteTime = info.FeeItems.FirstOrDefault(x => x.ItemId == 1360); //邀请函发放时间
  15492. var officialActs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1361); //公务活动
  15493. var visaIns = info.FeeItems.FirstOrDefault(x => x.ItemId == 1362); //签证+保险
  15494. var serviceCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1363); //服务费
  15495. var pubMiscs = info.FeeItems.FirstOrDefault(x => x.ItemId == 1364); //公杂费
  15496. var taxCosts = info.FeeItems.FirstOrDefault(x => x.ItemId == 1365); //税费
  15497. //获取模板
  15498. string tempPath = AppSettingsHelper.Get("ExcelBasePath") + "Template/出入境费用明细报价表模板.xlsx";
  15499. var designer = new WorkbookDesigner();
  15500. designer.Workbook = new Workbook(tempPath);
  15501. designer.SetDataSource("QuoteName", info.Name);
  15502. designer.SetDataSource("CompanyTitle", "公司名称");
  15503. designer.SetDataSource("CompanyLabel", "");
  15504. #region 国际旅费
  15505. designer.SetDataSource("IntTravelTitle", intTravelCosts?.ItemWrapName ?? "国际旅费\r\n(公务舱和经济舱分别罗列)");
  15506. if (intTravelCosts != null && intTravelCosts.Infos.Any())
  15507. {
  15508. var cabClassFilter = new string[] { "经济舱", "公务舱", "头等舱" };
  15509. var label = new StringBuilder();
  15510. var infos = intTravelCosts.Infos.Where(x => cabClassFilter.Contains(x.FeeName)).ToArray();
  15511. if (infos.Any())
  15512. {
  15513. label.Append(infos.Sum(x => x.PplNum));
  15514. label.Append("人全程机票:");
  15515. label.Append(infos.Sum(x => x.TotalAmt).TruncDecimals(2));
  15516. label.AppendLine("元");
  15517. }
  15518. foreach (var item in intTravelCosts.Infos)
  15519. {
  15520. label.Append(item.FeeName);
  15521. label.Append(":");
  15522. label.Append(item.UnitPrice.TruncDecimals(2));
  15523. label.Append("元/人*");
  15524. label.Append(item.PplNum);
  15525. label.AppendLine("人");
  15526. }
  15527. if (label.HasValue())
  15528. {
  15529. label.Append("\r\n以上小计:");
  15530. label.Append(intTravelCosts.TotalAmt.TruncDecimals(2));
  15531. label.Append("元");
  15532. }
  15533. designer.SetDataSource("IntTravelLabel", label.ToString());
  15534. }
  15535. #endregion
  15536. #region 住宿费
  15537. designer.SetDataSource("AccomTitle", accomCosts?.ItemWrapName ?? "住宿费\r\n(请备注明酒店星级)");
  15538. if (accomCosts != null && accomCosts.Infos.Any())
  15539. {
  15540. string currencyName = string.Empty,
  15541. countryName = string.Empty;
  15542. decimal rate = 1.0000M;
  15543. var label = new StringBuilder();
  15544. label.AppendLine("全程五星酒店,每人1间房");
  15545. foreach (var item in accomCosts.Infos)
  15546. {
  15547. //乌兹别克斯坦: 塔什干:120美金/间/晚*2*6人
  15548. string name = string.Empty, thisCountryName = string.Empty;
  15549. if (item.FeeName.Contains('-'))
  15550. {
  15551. var feeName = item.FeeName.Split('-');
  15552. thisCountryName = feeName[0];
  15553. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  15554. name = feeName[1];
  15555. }
  15556. else name = item.FeeName;
  15557. string thisFeeName = string.Empty;
  15558. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  15559. else thisFeeName = $"\r\n{name}:";
  15560. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  15561. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  15562. rate = rateInfo?.Rate ?? 1.0000M;
  15563. string subLabel = string.Format("{0}{1}{2}/间/晚*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity.ToString("#0"), item.PplNum.ToString("#0"));
  15564. label.AppendLine(subLabel);
  15565. }
  15566. if (label.HasValue())
  15567. {
  15568. //以上小计:52440元(美金汇率:7.5 )
  15569. string subLabel = string.Format("\r\n以上小计:{0}元({1}汇率:{2})", accomCosts.TotalAmt.TruncDecimals(2), currencyName, rate.TruncDecimals(4));
  15570. label.AppendLine(subLabel);
  15571. }
  15572. designer.SetDataSource("AccomLabel", label.ToString());
  15573. }
  15574. #endregion
  15575. #region 餐饮费
  15576. designer.SetDataSource("MealTitle", mealCosts?.ItemWrapName ?? "餐饮费");
  15577. if (mealCosts != null && mealCosts.Infos.Any())
  15578. {
  15579. string currencyName = string.Empty;
  15580. decimal rate = 1.0000M;
  15581. var label = new StringBuilder();
  15582. label.Append("全程酒店含早,\r\n若因航班过早,\r\n酒店准备路早。\r\n\r\n");
  15583. foreach (var item in mealCosts.Infos)
  15584. {
  15585. string name = string.Empty;
  15586. if (item.FeeName.Contains('-'))
  15587. {
  15588. var feeName = item.FeeName.Split('-');
  15589. name = $"\r\n{feeName[0]}:\r\n{feeName[1]}:";
  15590. }
  15591. else name = $"\r\n{item.FeeName}:";
  15592. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  15593. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  15594. rate = rateInfo?.Rate ?? 1.0000M;
  15595. label.Append(name);
  15596. label.Append(item.UnitPrice.TruncDecimals(2));
  15597. label.Append(currencyName);
  15598. label.Append("/天*");
  15599. label.Append(item.Quantity.ToString("#0"));
  15600. label.Append('*');
  15601. label.Append(item.PplNum);
  15602. label.Append("人\r\n");
  15603. }
  15604. if (label.HasValue())
  15605. {
  15606. label.Append("\r\n以上小计:");
  15607. label.Append(accomCosts.TotalAmt.TruncDecimals(2));
  15608. label.Append("元\r\n(");
  15609. label.Append("汇率:");
  15610. label.Append(rate.TruncDecimals(4));
  15611. label.Append(')');
  15612. }
  15613. designer.SetDataSource("MealLabel", label.ToString());
  15614. }
  15615. #endregion
  15616. #region 车辆安排
  15617. designer.SetDataSource("VehArrangeTitle", vehArranges?.ItemWrapName ?? "车辆安排\r\n(司兼导分开的情况下,车辆品牌、座位及费用)");
  15618. if (vehArranges != null && vehArranges.Infos.Any())
  15619. {
  15620. string currencyName = string.Empty;
  15621. //decimal rate = 1.0000M;
  15622. var label = new StringBuilder();
  15623. foreach (var item in vehArranges.Infos)
  15624. {
  15625. label.AppendLine();
  15626. label.AppendLine();
  15627. label.Append(item.FeeName);
  15628. label.Append($"\r\n\r\n费用:{item.TotalAmt.TruncDecimals(2)}元");
  15629. }
  15630. designer.SetDataSource("VehArrangeLabel", label.ToString());
  15631. }
  15632. #endregion
  15633. #region 邀请函发放对象
  15634. designer.SetDataSource("InviteToTitle", inviteTo?.ItemWrapName ?? "邀请函发放对象");
  15635. designer.SetDataSource("InviteToContent", "");
  15636. #endregion
  15637. #region 邀请函费
  15638. designer.SetDataSource("InviteCostTitle", inviteCosts?.ItemWrapName ?? "邀请函费用");
  15639. var is_label = new StringBuilder();
  15640. if (inviteCosts != null && inviteCosts.Infos.Any())
  15641. {
  15642. string currencyName = string.Empty;
  15643. decimal rate = 1.0000M;
  15644. foreach (var item in inviteCosts.Infos)
  15645. {
  15646. //乌兹别克斯坦:2000美金
  15647. currencyName = item.Currency;
  15648. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  15649. string label = string.Format("{0}:{1}{2}", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName);
  15650. is_label.AppendLine(label);
  15651. }
  15652. if (is_label.HasValue())
  15653. {
  15654. //以上小计:28500元(美金汇率:7.5)
  15655. string label = string.Format("以上小计:{0}{1}({2}汇率:{3})", inviteCosts.TotalAmt.TruncDecimals(2), "元", currencyName, rate.TruncDecimals(4));
  15656. is_label.AppendLine(label);
  15657. }
  15658. }
  15659. designer.SetDataSource("InviteCostContent", is_label.ToString());
  15660. #endregion
  15661. #region 邀请函发放时间
  15662. designer.SetDataSource("InviteToTimeTitle", inviteTime?.ItemWrapName ?? "邀请函发放时间");
  15663. designer.SetDataSource("InviteToTimeContent", "拿到团员名单10-15工作日");
  15664. #endregion
  15665. #region 公务活动(含翻译)
  15666. designer.SetDataSource("OfficialActsTitle", officialActs?.ItemWrapName ?? "公务活动(含翻译)");
  15667. var oa_label = new StringBuilder();
  15668. if (officialActs != null && officialActs.Infos.Any())
  15669. {
  15670. string currencyName = string.Empty;
  15671. decimal rate = 1.0000M;
  15672. string label_title = string.Empty, label_content = "超出报价部分需额付费:\r\n";
  15673. foreach (var item in officialActs.Infos)
  15674. {
  15675. //乌兹别克斯坦:1000美金/场
  15676. currencyName = item.Currency;
  15677. rate = rates.FirstOrDefault(x => currencyName.Equals(x.CurrencyCode))?.Rate ?? 1.0000M;
  15678. string label_remark = string.Empty;
  15679. if (!string.IsNullOrEmpty(item.Remark)) label_remark = $"({item.Remark})";
  15680. label_content += string.Format("{0}:{1}{2}/场{3}\r\n", item.FeeName, item.UnitPrice.TruncDecimals(2), currencyName, label_remark);
  15681. }
  15682. label_content += "*总费用中未含超出公务活动价格";
  15683. //8场公务活动(以上小计:60000元)
  15684. var quantity = officialActs.Infos.Sum(x => x.Quantity);
  15685. label_title = string.Format("{0}场公务活动(以上小计:{1}元)", quantity, officialActs.TotalAmt.TruncDecimals(2));
  15686. oa_label.AppendLine(label_title);
  15687. oa_label.AppendLine(label_content);
  15688. }
  15689. designer.SetDataSource("OfficialActsContent", oa_label.ToString());
  15690. #endregion
  15691. #region 签证+保险
  15692. designer.SetDataSource("VisaInsTitle", visaIns?.ItemWrapName ?? "签证+保险\r\n(单位:元)");
  15693. var vi_label = new StringBuilder();
  15694. if (visaIns != null && visaIns.Infos.Any())
  15695. {
  15696. foreach (var item in visaIns.Infos)
  15697. {
  15698. //签证:500元/人
  15699. string label = string.Format("{0}:{1}元/人*{2}人", item.FeeName, item.UnitPrice.TruncDecimals(2), item.PplNum);
  15700. vi_label.AppendLine(label);
  15701. }
  15702. if (vi_label.HasValue())
  15703. {
  15704. //以上小计:6000元
  15705. string label = string.Format("以上小计:{0}元", visaIns.TotalAmt.TruncDecimals(2));
  15706. vi_label.AppendLine(label);
  15707. }
  15708. }
  15709. designer.SetDataSource("VisaInsContent", vi_label.ToString());
  15710. #endregion
  15711. #region 服务费
  15712. designer.SetDataSource("ServiceCostTitle", serviceCosts?.ItemWrapName ?? "服务费");
  15713. designer.SetDataSource("ServiceCostContent", serviceCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  15714. #endregion
  15715. #region 公杂费
  15716. designer.SetDataSource("PubMiscsTitle", pubMiscs?.ItemWrapName ?? "公杂费\r\n(发给团组成员)");
  15717. var pm_label = new StringBuilder();
  15718. if (pubMiscs != null && pubMiscs.Infos.Any())
  15719. {
  15720. string currencyName = string.Empty,
  15721. countryName = string.Empty;
  15722. decimal rate = 1.0000M;
  15723. foreach (var item in pubMiscs.Infos)
  15724. {
  15725. //乌兹别克斯坦:塔什干:32美金 / 天 * 3 * 6人
  15726. string name = string.Empty, thisCountryName = string.Empty;
  15727. if (item.FeeName.Contains('-'))
  15728. {
  15729. var feeName = item.FeeName.Split('-');
  15730. thisCountryName = feeName[0];
  15731. if (!thisCountryName.Equals(countryName)) countryName = feeName[0];
  15732. name = feeName[1];
  15733. }
  15734. else name = item.FeeName;
  15735. string thisFeeName = string.Empty;
  15736. if (!thisCountryName.Equals(countryName)) thisFeeName = $"{countryName}:\r\n{name}:";
  15737. else thisFeeName = $"\r\n{name}:";
  15738. var rateInfo = rates.FirstOrDefault(x => item.Currency.Equals(x.CurrencyCode));
  15739. currencyName = rateInfo?.CurrencyName ?? "UnKnow";
  15740. rate = rateInfo?.Rate ?? 1.0000M;
  15741. string label = string.Format("{0}:{1}{2}/天*{3}*{4}人", thisFeeName, item.UnitPrice.TruncDecimals(2), currencyName, item.Quantity, item.PplNum);
  15742. pm_label.AppendLine(label);
  15743. }
  15744. if (pm_label.HasValue())
  15745. {
  15746. //以上小计:13497.6元\r\n(美金汇率:7.5 )\r\n部分发放成员
  15747. pm_label.AppendLine(string.Format("以上小计:{0}元", pubMiscs.TotalAmt.TruncDecimals(2)));
  15748. pm_label.AppendLine(string.Format("({0}汇率:{1})", currencyName, rate.TruncDecimals(4)));
  15749. pm_label.AppendLine(string.Format("部分发放成员"));
  15750. }
  15751. }
  15752. designer.SetDataSource("PubMiscsContent", pm_label.ToString());
  15753. #endregion
  15754. #region 税费
  15755. designer.SetDataSource("TaxCostTitle", taxCosts?.ItemWrapName ?? "税费");
  15756. designer.SetDataSource("TaxCostContent", taxCosts?.TotalAmt.TruncDecimals(2) ?? 0.00M);
  15757. #endregion
  15758. #region 合计(单位:元)
  15759. designer.SetDataSource("CostTotalTitle", "合计\r\n(单位:元)");
  15760. designer.SetDataSource("CostTotalContent", info.FeeItems.Sum(x => x.TotalAmt).TruncDecimals(2));
  15761. #endregion
  15762. #region 汇率 Remark
  15763. var rate_label = new StringBuilder();
  15764. var rateGroups = rates.GroupBy(x => x.CurrencyName);
  15765. foreach (var item in rateGroups)
  15766. {
  15767. //美元汇率按\r\n1:7.5
  15768. string label = string.Format("{0}汇率按\r\n1:{1}", item.Key, item.FirstOrDefault()?.Rate.TruncDecimals(4) ?? 0.0000M);
  15769. rate_label.AppendLine(label);
  15770. }
  15771. designer.SetDataSource("RateLabel", rate_label.ToString());
  15772. #endregion
  15773. designer.Process();
  15774. //文件名
  15775. string fileName = $"{info.Name}{DateTime.Now:yyyyMMddHHmmss}.xls";
  15776. designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + "EnterExitCostQuote/" + fileName);
  15777. string url = AppSettingsHelper.Get("ExcelBaseUrl") + "Office/Excel/EnterExitCostQuote/" + fileName;
  15778. return Ok(JsonView(true, "成功", url));
  15779. }
  15780. #endregion
  15781. #region 签证费用录入
  15782. /// <summary>
  15783. /// 根据diid查询签证费用列表
  15784. /// </summary>
  15785. /// <param name="dto"></param>
  15786. /// <returns></returns>
  15787. [HttpPost]
  15788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15789. public async Task<IActionResult> QueryVisaByDiId(VisaPriceDto dto)
  15790. {
  15791. Result groupData = await _visaPriceRep.PostVisaByDiId(dto);
  15792. if (groupData.Code != 0)
  15793. {
  15794. return Ok(JsonView(false, groupData.Msg));
  15795. }
  15796. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15797. }
  15798. /// <summary>
  15799. /// 根据签证费用Id查询单条数据及c表数据
  15800. /// </summary>
  15801. /// <param name="dto"></param>
  15802. /// <returns></returns>
  15803. [HttpPost]
  15804. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15805. public async Task<IActionResult> QueryVisaById(PostVisaByIdDto dto)
  15806. {
  15807. Result groupData = await _visaPriceRep.PostVisaById(dto);
  15808. if (groupData.Code != 0)
  15809. {
  15810. return Ok(JsonView(false, groupData.Msg));
  15811. }
  15812. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15813. }
  15814. /// <summary>
  15815. /// 签证费用删除
  15816. /// </summary>
  15817. /// <param name="dto"></param>
  15818. /// <returns></returns>
  15819. [HttpPost]
  15820. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15821. public async Task<IActionResult> DelVisaPrice(DelBaseDto dto)
  15822. {
  15823. _sqlSugar.BeginTran();
  15824. var res = await _visaPriceRep.SoftDeleteByIdAsync<Grp_VisaInfo>(dto.Id.ToString(), dto.DeleteUserId);
  15825. if (!res)
  15826. {
  15827. _sqlSugar.RollbackTran();
  15828. return Ok(JsonView(false, "删除失败"));
  15829. }
  15830. var resSub = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  15831. .Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 80)
  15832. .SetColumns(a => new Grp_CreditCardPayment()
  15833. {
  15834. IsDel = 1,
  15835. DeleteUserId = dto.DeleteUserId,
  15836. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  15837. })
  15838. .ExecuteCommand();
  15839. if (resSub < 1)
  15840. {
  15841. _sqlSugar.RollbackTran();
  15842. return Ok(JsonView(false, "删除失败"));
  15843. }
  15844. _sqlSugar.CommitTran();
  15845. return Ok(JsonView(true, "删除成功!"));
  15846. }
  15847. /// <summary>
  15848. /// 签证费用录入下拉框初始化
  15849. /// </summary>
  15850. /// <returns></returns>
  15851. [HttpPost]
  15852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15853. public async Task<IActionResult> VisaPriceAddSelect()
  15854. {
  15855. //支付方式
  15856. List<Sys_SetData> Payment = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 14 && a.IsDel == 0).ToList();
  15857. List<SetDataInfoView> _Payment = _mapper.Map<List<SetDataInfoView>>(Payment);
  15858. //币种
  15859. List<Sys_SetData> CurrencyList = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 66 && a.IsDel == 0).ToList();
  15860. List<SetDataInfoView> _CurrencyList = _mapper.Map<List<SetDataInfoView>>(CurrencyList);
  15861. //乘客类型
  15862. List<Sys_SetData> PassengerType = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 69 && a.IsDel == 0).ToList();
  15863. List<SetDataInfoView> _PassengerType = _mapper.Map<List<SetDataInfoView>>(PassengerType);
  15864. //卡类型
  15865. List<Sys_SetData> BankCard = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.STid == 15 && a.IsDel == 0).ToList();
  15866. List<SetDataInfoView> _BankCard = _mapper.Map<List<SetDataInfoView>>(BankCard);
  15867. //代办费类型
  15868. var agencyFeeTypeData = new List<dynamic>() {
  15869. new { id = 0 , Text = "未选择" },
  15870. new { id = 1 , Text = "小公务" },
  15871. new { id = 2 , Text = "大公务" },
  15872. };
  15873. //签证费用标准国家Data
  15874. var visaSql = string.Format(@"select
  15875. id,
  15876. case
  15877. when FeeType = 0 then Country+'(因公)'
  15878. when FeeType = 1 then Country+'(因私)'
  15879. else Country+'(未设置)'
  15880. end as 'country'
  15881. from Res_VisaFeeStandard where isdel = 0");
  15882. var visaCountryFeeData = _sqlSugar.SqlQueryable<dynamic>(visaSql).ToList();
  15883. var data = new
  15884. {
  15885. Payment = _Payment,
  15886. CurrencyList = _CurrencyList,
  15887. PassengerType = _PassengerType,
  15888. BankCard = _BankCard,
  15889. AgencyFeeType = agencyFeeTypeData,
  15890. CountryFeeData = visaCountryFeeData
  15891. };
  15892. return Ok(JsonView(true, "查询成功!", data));
  15893. }
  15894. /// <summary>
  15895. /// 签证费用录入操作(Status:1.新增,2.修改)
  15896. /// </summary>
  15897. /// <param name="dto"></param>
  15898. /// <returns></returns>
  15899. [HttpPost]
  15900. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15901. public async Task<IActionResult> OpVisaPrice(OpVisaPriceDto dto)
  15902. {
  15903. Result groupData = await _visaPriceRep.OpVisaPrice(dto);
  15904. if (groupData.Code != 0)
  15905. {
  15906. return Ok(JsonView(false, groupData.Msg));
  15907. }
  15908. #region 应用推送
  15909. try
  15910. {
  15911. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  15912. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  15913. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  15914. //2024-10-21 新增LZ UID
  15915. var userIds = new List<int>() { 21 };
  15916. string title = $"系统通知";
  15917. string content = "";
  15918. var diId = dto.DiId;
  15919. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  15920. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  15921. if (dto.Status == 1) content = $"[新增-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  15922. else if (dto.Status == 2) content = $"[更新-签证费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate):#0.00} CNY;";
  15923. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  15924. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "80" };
  15925. await APNsTools.iOS_PushNotifications1("051", $"签证费用审核", "", content, true, "ExpenseAuditWebView", h5);
  15926. }
  15927. catch (Exception ex)
  15928. {
  15929. }
  15930. #endregion
  15931. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  15932. }
  15933. #endregion
  15934. #region 签证提成录入
  15935. /// <summary>
  15936. /// 签证提成录入
  15937. /// 基础数据
  15938. /// </summary>
  15939. /// <returns></returns>
  15940. [HttpGet]
  15941. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15942. public async Task<IActionResult> VisaCommissionInit()
  15943. {
  15944. return Ok(await _visaCommissionRep.Init());
  15945. }
  15946. /// <summary>
  15947. /// 签证提成录入
  15948. /// Item
  15949. /// </summary>
  15950. /// <param name="_dto"></param>
  15951. /// <returns></returns>
  15952. [HttpPost]
  15953. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15954. public async Task<IActionResult> VisaCommissionItem(VisaCommissionItemDto _dto)
  15955. {
  15956. var validator = new VisaCommissionItemDtoValidator();
  15957. var validatorRes = await validator.ValidateAsync(_dto);
  15958. if (!validatorRes.IsValid)
  15959. {
  15960. var sb = new StringBuilder();
  15961. foreach (var item in validatorRes.Errors)
  15962. {
  15963. sb.AppendLine(item.ErrorMessage);
  15964. }
  15965. return Ok(JsonView(false, sb.ToString()));
  15966. }
  15967. return Ok(await _visaCommissionRep.Item(_dto));
  15968. }
  15969. /// <summary>
  15970. /// 签证提成录入
  15971. /// Save
  15972. /// </summary>
  15973. /// <param name="_dto"></param>
  15974. /// <returns></returns>
  15975. [HttpPost]
  15976. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15977. public async Task<IActionResult> VisaCommissionSave(VisaCommissionSaveDto _dto)
  15978. {
  15979. //参数验证
  15980. if (_dto.Items.Length < 1) return Ok(JsonView(false, "请输入有效的请求!"));
  15981. foreach (var item in _dto.Items)
  15982. {
  15983. if (item.CurrUserId < 1) return Ok(JsonView(false, "请输入有效的CurrUserId!"));
  15984. if (item.DiId < 1) return Ok(JsonView(false, "请输入有效的DiId!"));
  15985. if (string.IsNullOrEmpty(item.Country)) return Ok(JsonView(false, "国家为空!"));
  15986. //if (item.Quantity < 1) return Ok(JsonView(false, "请输入有效的Qauntity!"));
  15987. }
  15988. return Ok(await _visaCommissionRep.Save(_dto));
  15989. }
  15990. /// <summary>
  15991. /// 签证提成录入
  15992. /// Create
  15993. /// </summary>
  15994. /// <param name="_dto"></param>
  15995. /// <returns></returns>
  15996. [HttpPost]
  15997. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  15998. public async Task<IActionResult> VisaCommissionCreate(VisaCommissionCreateDto _dto)
  15999. {
  16000. var validator = new VisaCommissionCreateDtoValidator();
  16001. var validatorRes = await validator.ValidateAsync(_dto);
  16002. if (!validatorRes.IsValid)
  16003. {
  16004. var sb = new StringBuilder();
  16005. foreach (var item in validatorRes.Errors)
  16006. {
  16007. sb.AppendLine(item.ErrorMessage);
  16008. }
  16009. return Ok(JsonView(false, sb.ToString()));
  16010. }
  16011. return Ok(await _visaCommissionRep.Create(_dto));
  16012. }
  16013. /// <summary>
  16014. /// 签证提成录入
  16015. /// Put(编辑)
  16016. /// </summary>
  16017. /// <param name="id"></param>
  16018. /// <param name="_dto"></param>
  16019. /// <returns></returns>
  16020. [HttpPut]
  16021. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16022. public async Task<IActionResult> VisaCommissionEdit(int id, VisaCommissionCreateDto _dto)
  16023. {
  16024. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  16025. var validator = new VisaCommissionCreateDtoValidator();
  16026. var validatorRes = await validator.ValidateAsync(_dto);
  16027. if (!validatorRes.IsValid)
  16028. {
  16029. var sb = new StringBuilder();
  16030. foreach (var item in validatorRes.Errors)
  16031. {
  16032. sb.AppendLine(item.ErrorMessage);
  16033. }
  16034. return Ok(JsonView(false, sb.ToString()));
  16035. }
  16036. return Ok(await _visaCommissionRep.Edit(id, _dto));
  16037. }
  16038. /// <summary>
  16039. /// 签证提成录入
  16040. /// Del
  16041. /// </summary>
  16042. /// <param name="id"></param>
  16043. /// <param name="currUserId"></param>
  16044. /// <returns></returns>
  16045. [HttpPost]
  16046. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16047. public async Task<IActionResult> VisaCommissionDel(int id, int currUserId)
  16048. {
  16049. if (id < 1) return Ok(JsonView(false, "请输入正确的id参数!"));
  16050. if (currUserId < 1) return Ok(JsonView(false, "请输入正确的currUserId参数!"));
  16051. return Ok(await _visaCommissionRep.Del(id, currUserId));
  16052. }
  16053. #endregion
  16054. #region op费用录入
  16055. /// <summary>
  16056. /// 根据diid查询op费用列表
  16057. /// </summary>
  16058. /// <param name="dto"></param>
  16059. /// <returns></returns>
  16060. [HttpPost]
  16061. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16062. public async Task<IActionResult> QueryCarTouristGuideGroundByDiId(CarTouristGuideGroundDto dto)
  16063. {
  16064. Result groupData = await _carTouristGuideGroundRep.QueryCarTouristGuideGroundByDiId(dto);
  16065. if (groupData.Code != 0)
  16066. {
  16067. return Ok(JsonView(false, groupData.Msg));
  16068. }
  16069. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16070. }
  16071. /// <summary>
  16072. /// 根据op费用Id查询单条数据及c表数据
  16073. /// </summary>
  16074. /// <param name="dto"></param>
  16075. /// <returns></returns>
  16076. [HttpPost]
  16077. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16078. public async Task<IActionResult> QueryCarTouristGuideGroundById(CarTouristGuideGroundIdDto dto)
  16079. {
  16080. try
  16081. {
  16082. Grp_CarTouristGuideGroundReservations _groupData = await _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().FirstAsync(a => a.Id == dto.Id && a.IsDel == 0);
  16083. Grp_CreditCardPayment _creditCardPayment = await _sqlSugar.Queryable<Grp_CreditCardPayment>().FirstAsync(a => a.CId == dto.Id && a.CTable == 79 && a.IsDel == 0);
  16084. var data = new
  16085. {
  16086. CarTouristGuideGround = _groupData,
  16087. CreditCardPayment = _creditCardPayment
  16088. };
  16089. return Ok(JsonView(true, "查询成功!", data));
  16090. }
  16091. catch (Exception ex)
  16092. {
  16093. return Ok(JsonView(false, "程序错误!"));
  16094. }
  16095. }
  16096. /// <summary>
  16097. /// op费用删除
  16098. /// </summary>
  16099. /// <param name="dto"></param>
  16100. /// <returns></returns>
  16101. [HttpPost]
  16102. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16103. public async Task<IActionResult> DelCarTouristGuideGround(DelBaseDto dto)
  16104. {
  16105. try
  16106. {
  16107. _sqlSugar.BeginTran();
  16108. var res = await _carTouristGuideGroundRep.SoftDeleteByIdAsync<Grp_CarTouristGuideGroundReservations>(dto.Id.ToString(), dto.DeleteUserId);
  16109. if (!res)
  16110. {
  16111. return Ok(JsonView(false, "删除失败"));
  16112. }
  16113. var result = await _sqlSugar.Updateable<Grp_CarTouristGuideGroundReservationsContent>().Where(a => a.CTGGRId == dto.Id && a.IsDel == 0).SetColumns(a => new Grp_CarTouristGuideGroundReservationsContent()
  16114. {
  16115. IsDel = 1,
  16116. DeleteUserId = dto.DeleteUserId,
  16117. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16118. }).ExecuteCommandAsync();
  16119. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 79).SetColumns(a => new Grp_CreditCardPayment()
  16120. {
  16121. IsDel = 1,
  16122. DeleteUserId = dto.DeleteUserId,
  16123. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16124. }).ExecuteCommandAsync();
  16125. #region 删除超支相关数据
  16126. //删除导入的超支数据
  16127. var ids = _sqlSugar.Queryable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.LocalGuideId == dto.Id && x.IsDel == 0).Select(x => x.OverspendId).ToList();
  16128. var count = _sqlSugar.Updateable<Fin_GroupExtraCost>().Where(x => ids.Contains(x.Id) && x.IsDel == 0).SetColumns(x => new Fin_GroupExtraCost
  16129. {
  16130. IsDel = 1,
  16131. DeleteUserId = dto.DeleteUserId,
  16132. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16133. }).ExecuteCommand();
  16134. count = _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(x => x.CTable == 1015 && x.IsDel == 0 && ids.Contains(x.CId)).SetColumns(x => new Grp_CreditCardPayment
  16135. {
  16136. IsDel = 1,
  16137. DeleteUserId = dto.DeleteUserId,
  16138. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16139. }).ExecuteCommand();
  16140. count = _sqlSugar.Updateable<Fin_LocalGuideRelevancyOverspend>().Where(x => x.IsDel == 0 && x.LocalGuideId == dto.Id).SetColumns(x => new Fin_LocalGuideRelevancyOverspend
  16141. {
  16142. IsDel = 1,
  16143. DeleteUserId = dto.DeleteUserId,
  16144. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16145. }).ExecuteCommand();
  16146. #endregion
  16147. _sqlSugar.CommitTran();
  16148. return Ok(JsonView(true, "删除成功!"));
  16149. }
  16150. catch (Exception ex)
  16151. {
  16152. _sqlSugar.RollbackTran();
  16153. return Ok(JsonView(false, "程序错误!" + ex.Message));
  16154. }
  16155. }
  16156. /// <summary>
  16157. /// op费用录入操作(Status:1.新增,2.修改)
  16158. /// </summary>
  16159. /// <param name="dto"></param>
  16160. /// <returns></returns>
  16161. [HttpPost]
  16162. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16163. public async Task<IActionResult> OpCarTouristGuideGround(OpCarTouristGuideGroundDto dto)
  16164. {
  16165. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGround(dto);
  16166. if (groupData.Code != 0)
  16167. {
  16168. return Ok(JsonView(false, groupData.Msg));
  16169. }
  16170. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16171. }
  16172. /// <summary>
  16173. /// 填写费用详细页面初始化绑定
  16174. /// </summary>
  16175. /// <param name="dto"></param>
  16176. /// <returns></returns>
  16177. [HttpPost]
  16178. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16179. public IActionResult CarTouristGuideGroundContentInitialize(CarTouristGuideGroundContentDto dto)
  16180. {
  16181. try
  16182. {
  16183. Result groupData = _carTouristGuideGroundRep.CarTouristGuideGroundContent(dto);
  16184. if (groupData.Code != 0)
  16185. {
  16186. return Ok(JsonView(false, groupData.Msg));
  16187. }
  16188. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16189. }
  16190. catch (Exception ex)
  16191. {
  16192. return Ok(JsonView(false, ex.Message));
  16193. }
  16194. }
  16195. /// <summary>
  16196. /// 根据op费用Id查询详细数据
  16197. /// </summary>
  16198. /// <param name="dto"></param>
  16199. /// <returns></returns>
  16200. [HttpPost]
  16201. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16202. public IActionResult OpCarTouristGuideGroundContentById(CarTouristGuideGroundIdDto dto)
  16203. {
  16204. try
  16205. {
  16206. Result groupData = _carTouristGuideGroundRep.OpCarTouristGuideGroundContentById(dto);
  16207. if (groupData.Code != 0)
  16208. {
  16209. return Ok(JsonView(false, groupData.Msg));
  16210. }
  16211. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16212. }
  16213. catch (Exception ex)
  16214. {
  16215. return Ok(JsonView(false, ex.Message));
  16216. }
  16217. }
  16218. /// <summary>
  16219. /// OP费用录入填写详情
  16220. /// </summary>
  16221. /// <param name="dto"></param>
  16222. /// <returns></returns>
  16223. [HttpPost]
  16224. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  16225. public async Task<IActionResult> OpCarTouristGuideGroundContent(OpCarTouristGuideGroundContentDto dto)
  16226. {
  16227. try
  16228. {
  16229. #region 参数校验
  16230. if (dto.Currency <= 0) return Ok(JsonView(false, "币种错误!"));
  16231. var di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.DiId && x.IsDel == 0);
  16232. if (di == null) return Ok(JsonView(false, "团组错误!"));
  16233. #endregion
  16234. Result groupData = await _carTouristGuideGroundRep.OpCarTouristGuideGroundContent(dto);
  16235. if (groupData.Code != 0)
  16236. {
  16237. return Ok(JsonView(false, groupData.Msg));
  16238. }
  16239. //自动审核
  16240. await _feeAuditRep.FeeAutomaticAudit(2, dto.DiId, dto.CTGGRId);
  16241. #region 尾款自动审核
  16242. var opinfos = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  16243. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.Id == dto.CTGGRId);
  16244. if (opinfos.PriceType == 1062)
  16245. {
  16246. var isAuto = false;
  16247. //找对应的首付款
  16248. var firstPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>()
  16249. .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))
  16250. .First(x => x.IsDel == 0 && x.DiId == dto.DiId && x.PriceName == opinfos.PriceName &&
  16251. x.ServiceStartTime == opinfos.ServiceStartTime && x.ServiceEndTime == opinfos.ServiceEndTime && x.Area == opinfos.Area &&
  16252. x.PriceType == 1061 && x.DiId == dto.DiId);
  16253. if (firstPrice != null && !(opinfos.SelectCheck.Contains("超时") || opinfos.SelectCheck.Contains("超支")) && firstPrice.CId == opinfos.CId)
  16254. {
  16255. var cprice = _sqlSugar.Queryable<Grp_CreditCardPayment>().First(x => x.IsDel == 0 && x.CId == firstPrice.Id && x.CTable == 79);
  16256. var balance = firstPrice.ServiceQuotedPrice * (100 - cprice.PayPercentage) / 100;
  16257. //合计中排除城市税
  16258. var cityPrice = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent>()
  16259. .Where(x => x.SId == 1452 && x.IsDel == 0 && x.DiId == dto.DiId && x.CTGGRId == dto.CTGGRId)
  16260. .Sum(x => x.Price * x.Count);
  16261. opinfos.ServiceQuotedPrice = opinfos.ServiceQuotedPrice - cityPrice;
  16262. if (balance >= opinfos.ServiceQuotedPrice)
  16263. {
  16264. isAuto = true;
  16265. }
  16266. }
  16267. if (isAuto)
  16268. {
  16269. var execCount = _sqlSugar.Updateable<Grp_CreditCardPayment>()
  16270. .SetColumns(a => new Grp_CreditCardPayment
  16271. {
  16272. IsAuditGM = 3, //自动审核通过
  16273. AuditGMOperate = 4,
  16274. AuditGMDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  16275. })
  16276. .Where(a => a.CId == dto.CTGGRId && a.CTable == 79 && a.DIId == dto.DiId)
  16277. .ExecuteCommand();
  16278. }
  16279. }
  16280. #endregion
  16281. #region 应用推送
  16282. try
  16283. {
  16284. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  16285. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  16286. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  16287. //2024-10-21 新增LZ UID
  16288. var userIds = new List<int>() { 21 };
  16289. string title = $"系统通知";
  16290. var diId = dto.DiId;
  16291. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  16292. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  16293. string content = $"[更新-OP费用录入填写详情({groupInfo?.TeamName ?? "-"})]一项费用:{(((ccpInfo.PayMoney * ccpInfo.DayRate) / 100) * ccpInfo.PayPercentage):#0.00} CNY;";
  16294. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  16295. var h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "79" };
  16296. await APNsTools.iOS_PushNotifications1("051", $"OP费用审核", "", content, true, "ExpenseAuditWebView", h5);
  16297. }
  16298. catch (Exception ex)
  16299. {
  16300. }
  16301. #endregion
  16302. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  16303. }
  16304. catch (Exception ex)
  16305. {
  16306. return Ok(JsonView(false, ex.Message));
  16307. }
  16308. }
  16309. /// <summary>
  16310. /// 获取三公详细所有城市
  16311. /// </summary>
  16312. /// <returns></returns>
  16313. [HttpGet]
  16314. public IActionResult OpCarCityResult()
  16315. {
  16316. var jw = JsonView(false);
  16317. var data = _sqlSugar.Queryable<Grp_NationalTravelFee>().Where(x => x.IsDel == 0).Select(x => new
  16318. {
  16319. x.Id,
  16320. x.Country,
  16321. x.City,
  16322. }).ToList();
  16323. if (data.Count > 0)
  16324. {
  16325. jw = JsonView(true, "获取成功!", data);
  16326. }
  16327. else
  16328. {
  16329. jw.Msg = "城市数据为空!";
  16330. jw.Data = Array.Empty<string>();
  16331. }
  16332. return Ok(jw);
  16333. }
  16334. /// <summary>
  16335. /// 导出地接费用明细
  16336. /// </summary>
  16337. /// <param name="dto"></param>
  16338. /// <returns></returns>
  16339. [HttpPost]
  16340. public IActionResult ExportLocalGuidePriceDetail(ExportLocalGuidePriceDetailDto dto)
  16341. {
  16342. var jw = JsonView(false);
  16343. if (dto.Diid < 1)
  16344. {
  16345. jw.Msg = "请输入正确的diid!";
  16346. return Ok(jw);
  16347. }
  16348. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  16349. if (group == null)
  16350. {
  16351. jw.Msg = "未找到团组信息!";
  16352. return Ok(jw);
  16353. }
  16354. var localGuideArr = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  16355. if (localGuideArr.Count == 0)
  16356. {
  16357. jw.Msg = "该团组暂无地接信息!";
  16358. return Ok(jw);
  16359. }
  16360. var localGroup = localGuideArr.GroupBy(x => x.Area).ToList();
  16361. var overspendSoure = new Dictionary<int, int>
  16362. {
  16363. { 91, 982 }, //车
  16364. { 92 , 1059} ,//导游
  16365. { 994 , 1073}, //翻译
  16366. { 988 , 1074 }, //早餐
  16367. { 93 , 1075 }, //午餐
  16368. { 989 , 1076 }, //晚餐
  16369. };
  16370. var Zips = new Dictionary<string, Stream>();
  16371. foreach (var groupArr in localGroup)
  16372. {
  16373. var keyValue = groupArr.Key;
  16374. if (int.TryParse(keyValue, out int cityid))
  16375. {
  16376. var city = _sqlSugar.Queryable<Grp_NationalTravelFee>().First(x => x.Id == cityid && x.IsDel == 0);
  16377. keyValue = city == null ? keyValue : city.Country + "-" + city.City;
  16378. }
  16379. var contentArr = new List<List<Grp_CarTouristGuideGroundReservationsContentExtend>>();
  16380. foreach (var item in groupArr)
  16381. {
  16382. var content = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservationsContent, Sys_SetData>((a, b) => a.SId == b.Id
  16383. ).Where((a, b) => a.CTGGRId == item.Id && a.Price != 0M && a.IsDel == 0 && b.IsDel == 0).Select((a, b) =>
  16384. new Grp_CarTouristGuideGroundReservationsContentExtend
  16385. {
  16386. Count = a.Count,
  16387. CreateTime = a.CreateTime,
  16388. CreateUserId = a.CreateUserId,
  16389. CTGGRId = a.CTGGRId,
  16390. Currency = a.Currency,
  16391. DatePrice = a.DatePrice,
  16392. DeleteTime = a.DeleteTime,
  16393. DeleteUserId = a.DeleteUserId,
  16394. DiId = a.DiId,
  16395. Id = a.Id,
  16396. IsDel = a.IsDel,
  16397. Price = a.Price,
  16398. PriceContent = a.PriceContent,
  16399. Remark = a.Remark,
  16400. SId = a.SId,
  16401. SidName = b.Name,
  16402. Units = a.Units,
  16403. }
  16404. ).ToList();
  16405. if (content.Count > 0)
  16406. {
  16407. contentArr.Add(content);
  16408. }
  16409. }
  16410. //open excel
  16411. //set excel
  16412. //save excel
  16413. try
  16414. {
  16415. string filePath = AppSettingsHelper.Get("ExcelBasePath") + "\\Template\\地接费用明细.xlsx";
  16416. IWorkbook workbook;
  16417. if (Path.GetExtension(filePath).ToLower() == ".xls")
  16418. {
  16419. workbook = new NPOI.HSSF.UserModel.HSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  16420. }
  16421. else
  16422. {
  16423. workbook = new XSSFWorkbook(new FileStream(filePath, FileMode.Open, FileAccess.Read));
  16424. }
  16425. ISheet sheet = workbook.GetSheetAt(0);
  16426. var rowStartIndex = 2;
  16427. var clounmCount = 10;
  16428. var initStyleRow = sheet.GetRow(2);
  16429. var arr = contentArr.SelectMany(x => x).OrderBy(x => x.SId).ToList();
  16430. //var overspendArrDetail =
  16431. var existsId = new List<CarCompare>();
  16432. var lastElem = arr.Last();
  16433. var thisSid = -1;
  16434. var curr = arr.Count > 0 ? arr[0].Currency : -1;
  16435. var currObj = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == curr && x.IsDel == 0) ?? new Sys_SetData
  16436. {
  16437. Name = "未知币种!",
  16438. Remark = "未知币种!",
  16439. };
  16440. sheet.GetRow(0).GetCell(1).SetCellValue($"{keyValue}费用明细(货币:{currObj.Remark})");
  16441. Action cloneRowFn = () =>
  16442. {
  16443. rowStartIndex++;
  16444. var cloneRow = sheet.CreateRow(rowStartIndex);
  16445. // 复制样式
  16446. for (int i = initStyleRow.FirstCellNum; i < initStyleRow.LastCellNum; i++)
  16447. {
  16448. ICell sourceCell = initStyleRow.GetCell(i);
  16449. ICell targetCell = cloneRow.GetCell(i) ?? cloneRow.CreateCell(i);
  16450. // 确保单元格存在样式
  16451. if (sourceCell.CellStyle != null)
  16452. {
  16453. targetCell.CellStyle = sourceCell.CellStyle;
  16454. }
  16455. }
  16456. };
  16457. var mergeRow = () =>
  16458. {
  16459. for (int i = 2; i < sheet.LastRowNum; i++)
  16460. {
  16461. var row = sheet.GetRow(i);
  16462. var cellFirst = row.GetCell(0);
  16463. var thisIndex = i + 1;
  16464. while (thisIndex < sheet.LastRowNum)
  16465. {
  16466. var nextRow = sheet.GetRow(thisIndex);
  16467. var nextCellFirst = nextRow.GetCell(0);
  16468. if (cellFirst != null && nextCellFirst != null && cellFirst.ToString().Trim() == nextCellFirst.ToString().Trim())
  16469. {
  16470. thisIndex++;
  16471. }
  16472. else
  16473. {
  16474. break;
  16475. }
  16476. }
  16477. thisIndex--;
  16478. if (thisIndex != i)
  16479. {
  16480. //合并row
  16481. var cellRangeAddress = new CellRangeAddress(
  16482. i, // 起始行索引(0-based)
  16483. thisIndex, // 结束行索引(0-based)
  16484. 0, // 起始列索引(0-based)
  16485. 0 // 结束列索引(0-based)
  16486. );
  16487. sheet.AddMergedRegion(cellRangeAddress);
  16488. i = thisIndex;
  16489. }
  16490. }
  16491. };
  16492. var chaoshiNumber = 0;
  16493. var totalNumber = 0.00M;
  16494. string lastStr = "";
  16495. var queryCarArrByCityAndDiid = _sqlSugar.Queryable<Grp_CarTouristGuideGroundReservations, Grp_CreditCardPayment>((x, b) => x.Id == b.CId && b.IsDel == 0 && b.CTable == 79)
  16496. .Where(x => x.DiId == dto.Diid && x.Area == groupArr.Key).Select((x, b) => new
  16497. {
  16498. b.IsAuditGM,
  16499. x.Id,
  16500. x.Area,
  16501. b.PayPercentage,
  16502. b.PayMoney,
  16503. }).ToList();
  16504. string yesPayment = "", noPayment = "";
  16505. foreach (var item in queryCarArrByCityAndDiid)
  16506. {
  16507. if (item.IsAuditGM == 1)
  16508. {
  16509. yesPayment += $"已支付团款({(int)item.PayPercentage}%):{item.PayMoney} {currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  16510. }
  16511. else
  16512. {
  16513. noPayment += $"剩余团款:{item.PayMoney}{currObj.Remark}(如有需要,请在此处填写明细)\r\n";
  16514. }
  16515. }
  16516. lastStr = yesPayment + noPayment;
  16517. foreach (var item in arr)
  16518. {
  16519. if (existsId.FirstOrDefault(x => x.Sid == item.SId && DateTime.Compare(x.DataPrice, item.DatePrice.ObjToDate()) == 0) == null && !overspendSoure.ContainsValue(item.SId))
  16520. {
  16521. if (thisSid != item.SId)
  16522. {
  16523. if (thisSid == -1)
  16524. {
  16525. thisSid = item.SId;
  16526. }
  16527. else
  16528. {
  16529. //合并小计行
  16530. //创建合并区域的实例
  16531. var cellRangeAddress = new CellRangeAddress(
  16532. rowStartIndex, // 起始行索引(0-based)
  16533. rowStartIndex, // 结束行索引(0-based)
  16534. 0, // 起始列索引(0-based)
  16535. 3 // 结束列索引(0-based)
  16536. );
  16537. sheet.AddMergedRegion(cellRangeAddress);
  16538. var CellStyle = workbook.CreateCellStyle();
  16539. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16540. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  16541. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  16542. for (int i = 0; i <= clounmCount; i++)
  16543. {
  16544. if (i > 6)
  16545. {
  16546. var CellStyle1 = workbook.CreateCellStyle();
  16547. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16548. IFont Font = workbook.CreateFont(); // 创建字体
  16549. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  16550. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  16551. CellStyle1.SetFont(Font);
  16552. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  16553. }
  16554. else
  16555. {
  16556. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  16557. }
  16558. }
  16559. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  16560. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  16561. //超时合计
  16562. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  16563. //超时数
  16564. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  16565. //超时合计费用
  16566. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  16567. thisSid = item.SId;
  16568. cloneRowFn();
  16569. chaoshiNumber = 0;
  16570. totalNumber = 0;
  16571. }
  16572. }
  16573. IRow row = sheet.GetRow(rowStartIndex);
  16574. var whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  16575. var isOpenOverspendSoure = overspendSoure.ContainsKey(item.SId);
  16576. List<Grp_CarTouristGuideGroundReservationsContentExtend> overspendWhereForResult = null;
  16577. if (isOpenOverspendSoure)
  16578. {
  16579. overspendWhereForResult = arr.Where(x => x.SId == overspendSoure[item.SId] && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  16580. chaoshiNumber += overspendWhereForResult.Sum(x => x.Count);
  16581. totalNumber += overspendWhereForResult.Sum(x => x.Count * x.Price);
  16582. }
  16583. for (int i = 0; i <= clounmCount; i++)
  16584. {
  16585. var cell = row.GetCell(i);
  16586. var setCellValue = InIndexOutFunction(i, whereForResult, overspendWhereForResult);
  16587. if (cell == null)
  16588. {
  16589. cell = row.CreateCell(i);
  16590. }
  16591. var fontRed = workbook.CreateCellStyle(); // 创建单元格样式
  16592. fontRed.CloneStyleFrom(cell.CellStyle);
  16593. IFont Font = workbook.CreateFont(); // 创建字体
  16594. Font.CloneStyleFrom(cell.CellStyle.GetFont(workbook));
  16595. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  16596. fontRed.SetFont(Font);
  16597. byte[] rgb = new byte[3] { 255, 242, 204 };
  16598. var BackgroundColor255_242_204 = workbook.CreateCellStyle();
  16599. BackgroundColor255_242_204.CloneStyleFrom(cell.CellStyle);
  16600. byte[] rgb1 = new byte[3] { 189, 215, 238 };
  16601. if (workbook is XSSFWorkbook)
  16602. {
  16603. BackgroundColor255_242_204.FillForegroundColor = 0;
  16604. ((XSSFColor)BackgroundColor255_242_204.FillForegroundColorColor).SetRgb(rgb);
  16605. BackgroundColor255_242_204.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  16606. }
  16607. else
  16608. {
  16609. BackgroundColor255_242_204.FillForegroundColor = (((NPOI.HSSF.UserModel.HSSFWorkbook)workbook).GetCustomPalette().FindSimilarColor(rgb[0], rgb[1], rgb[2])).Indexed;
  16610. }
  16611. if (i == 1 || i > 6)
  16612. {
  16613. if (i > 6)
  16614. {
  16615. fontRed.FillForegroundColor = 0;
  16616. ((XSSFColor)fontRed.FillForegroundColorColor).SetRgb(rgb1);
  16617. fontRed.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground;
  16618. }
  16619. cell.CellStyle = fontRed;
  16620. }
  16621. if (i > 2 && i < 7)
  16622. {
  16623. cell.CellStyle = BackgroundColor255_242_204;
  16624. }
  16625. cell.SetCellValue(setCellValue); //写入单元格
  16626. }
  16627. if (overspendSoure.ContainsKey(thisSid))
  16628. {
  16629. var overspendId = overspendSoure[thisSid];
  16630. whereForResult = arr.Where(x => x.SId == item.SId && DateTime.Compare(x.DatePrice.ObjToDate(), item.DatePrice.ObjToDate()) == 0).ToList();
  16631. }
  16632. cloneRowFn();
  16633. existsId.Add(new CarCompare
  16634. {
  16635. DataPrice = item.DatePrice.ObjToDate(),
  16636. Sid = item.SId
  16637. });
  16638. }
  16639. if (item.Equals(lastElem))
  16640. {
  16641. //合并小计行
  16642. //创建合并区域的实例
  16643. var cellRangeAddress = new CellRangeAddress(
  16644. rowStartIndex, // 起始行索引(0-based)
  16645. rowStartIndex, // 结束行索引(0-based)
  16646. 0, // 起始列索引(0-based)
  16647. 3 // 结束列索引(0-based)
  16648. );
  16649. sheet.AddMergedRegion(cellRangeAddress);
  16650. var CellStyle = workbook.CreateCellStyle();
  16651. CellStyle.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16652. CellStyle.FillForegroundColor = IndexedColors.Yellow.Index; // 选择填充颜色
  16653. CellStyle.FillPattern = NPOI.SS.UserModel.FillPattern.SolidForeground; // 填充方式
  16654. for (int i = 0; i <= clounmCount; i++)
  16655. {
  16656. if (i > 6)
  16657. {
  16658. var CellStyle1 = workbook.CreateCellStyle();
  16659. CellStyle1.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(0).CellStyle);
  16660. IFont Font = workbook.CreateFont(); // 创建字体
  16661. Font.CloneStyleFrom(sheet.GetRow(rowStartIndex).GetCell(i).CellStyle.GetFont(workbook));
  16662. Font.Color = IndexedColors.Red.Index; // 选择字体颜色
  16663. CellStyle1.SetFont(Font);
  16664. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle1;
  16665. }
  16666. else
  16667. {
  16668. sheet.GetRow(rowStartIndex).GetCell(i).CellStyle = CellStyle;
  16669. }
  16670. }
  16671. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue("合计:");
  16672. sheet.GetRow(rowStartIndex).GetCell(4).SetCellValue(arr.Where(x => x.SId == thisSid).Sum(x => x.Count * x.Price).ToString("F2"));
  16673. //超时合计
  16674. sheet.GetRow(rowStartIndex).GetCell(7).SetCellValue("超时合计:");
  16675. //超时数
  16676. sheet.GetRow(rowStartIndex).GetCell(8).SetCellValue(chaoshiNumber == 0 ? "" : chaoshiNumber.ToString());
  16677. //超时合计费用
  16678. sheet.GetRow(rowStartIndex).GetCell(9).SetCellValue(totalNumber == 0 ? "" : totalNumber.ToString());
  16679. cloneRowFn();
  16680. // 创建合并区域的实例
  16681. cellRangeAddress = new CellRangeAddress(
  16682. rowStartIndex, // 起始行索引(0-based)
  16683. rowStartIndex, // 结束行索引(0-based)
  16684. 0, // 起始列索引(0-based)
  16685. initStyleRow.LastCellNum - 1 // 结束列索引(0-based)
  16686. );
  16687. // 添加合并区域
  16688. sheet.AddMergedRegion(cellRangeAddress);
  16689. sheet.GetRow(rowStartIndex).Height = 30 * 30;
  16690. sheet.GetRow(rowStartIndex).GetCell(0).SetCellValue(lastStr);
  16691. }
  16692. }
  16693. mergeRow();
  16694. // 保存修改后的Excel文件到新文件
  16695. //string newFilePath = Path.Combine(Path.GetDirectoryName(filePath), keyValue +"_" + Path.GetFileName(filePath));
  16696. // new FileStream(newFilePath, FileMode.CreateNew)
  16697. using (var stream = new MemoryStream())
  16698. {
  16699. workbook.Write(stream, true);
  16700. stream.Flush();
  16701. stream.Seek(0, SeekOrigin.Begin);
  16702. var memoryStream = new MemoryStream();
  16703. stream.CopyTo(memoryStream);
  16704. memoryStream.Seek(0, SeekOrigin.Begin);
  16705. Zips.Add(keyValue + "_" + "费用明细表.xlsx", memoryStream);
  16706. }
  16707. workbook.Close();
  16708. workbook.Dispose();
  16709. }
  16710. catch (Exception ex)
  16711. {
  16712. jw.Msg = "出现异常!" + ex.Message;
  16713. return Ok(jw);
  16714. }
  16715. }
  16716. if (Zips.Count > 0)
  16717. {
  16718. var io = new IOOperatorHelper();
  16719. var byts = io.ConvertZipStream(Zips);
  16720. io.ByteToFile(byts, AppSettingsHelper.Get("ExcelBasePath") + $"\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip");
  16721. //http://132.232.92.186:24/Office/Word/EnterExitCost/File/
  16722. jw = JsonView(true, "success", new { url = AppSettingsHelper.Get("OfficeBaseUrl") + $"\\Office\\Excel\\ExportLocalGuidePriceDetail\\{group.TeamName}_地接费用明细.zip" });
  16723. }
  16724. else
  16725. {
  16726. jw.Msg = "暂无生成文件!";
  16727. }
  16728. return Ok(jw);
  16729. }
  16730. private string InIndexOutFunction(int i, List<Grp_CarTouristGuideGroundReservationsContentExtend> arr, List<Grp_CarTouristGuideGroundReservationsContentExtend> arrOverspendSoure)
  16731. {
  16732. string outStr = string.Empty;
  16733. switch (i)
  16734. {
  16735. case 0:
  16736. outStr = arr[0].SidName;
  16737. break;
  16738. case 1:
  16739. outStr = arr[0].DataPriceStr;
  16740. break;
  16741. case 2:
  16742. outStr = string.Join("-", arr.Select(x => x.PriceContent));
  16743. break;
  16744. case 4:
  16745. outStr = arr.Sum(x => x.Subtotal).ToString("F2");
  16746. break;
  16747. case 7:
  16748. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16749. {
  16750. var curr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Currency && x.IsDel == 0);
  16751. var unit = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == arrOverspendSoure[0].Units && x.IsDel == 0);
  16752. outStr = arrOverspendSoure.Sum(x => x.Price).ToString("F2") + curr?.Remark + "/" + unit?.Name;
  16753. }
  16754. break;
  16755. case 8:
  16756. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16757. {
  16758. outStr = arrOverspendSoure.Sum(x => x.Count).ToString();
  16759. }
  16760. break;
  16761. case 9:
  16762. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16763. {
  16764. outStr = arrOverspendSoure.Sum(x => x.Count * x.Price).ToString();
  16765. }
  16766. break;
  16767. case 10:
  16768. if (arrOverspendSoure != null && arrOverspendSoure.Count > 0)
  16769. {
  16770. outStr = string.Join("-", arrOverspendSoure.Select(x => x.PriceContent));
  16771. }
  16772. break;
  16773. }
  16774. return outStr;
  16775. }
  16776. #region OP行程单
  16777. /// <summary>
  16778. /// OP行程单初始化
  16779. /// </summary>
  16780. /// <param name="dto"></param>
  16781. /// <returns></returns>
  16782. [HttpPost]
  16783. public IActionResult InitOpTravel(InitOpTravelDto dto)
  16784. {
  16785. var jw = JsonView(false);
  16786. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  16787. var group = groupList.First();
  16788. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  16789. if (group == null)
  16790. {
  16791. jw.Msg = "暂无团组!";
  16792. return Ok(jw);
  16793. }
  16794. group = groupList.Find(x => x.Id == diid);
  16795. if (group == null)
  16796. {
  16797. jw.Msg = "请输入正确的团组ID!";
  16798. return Ok(jw);
  16799. }
  16800. string city = string.Empty;
  16801. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).ToList();
  16802. if (blackCode.Count > 0)
  16803. {
  16804. var black = blackCode.First();
  16805. black.BlackCode = black.BlackCode ?? "";
  16806. var blackSp = Regex.Split(black.BlackCode, "\\d+\\.", RegexOptions.IgnoreCase).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
  16807. if (blackSp.Length > 0)
  16808. {
  16809. try
  16810. {
  16811. var cityArrCode = new List<string>(20);
  16812. foreach (var item in blackSp)
  16813. {
  16814. var itemSp = item.Split(' ').Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
  16815. var IndexSelect = itemSp[2];
  16816. var cityArrCodeLength = cityArrCode.Count - 1;
  16817. var startCity = IndexSelect.Substring(0, 3);
  16818. if (cityArrCodeLength > 0)
  16819. {
  16820. var arrEndCity = cityArrCode[cityArrCodeLength];
  16821. if (arrEndCity != startCity)
  16822. {
  16823. cityArrCode.Add(startCity.ToUpper());
  16824. }
  16825. }
  16826. else
  16827. {
  16828. cityArrCode.Add(startCity.ToUpper());
  16829. }
  16830. var endCity = IndexSelect.Substring(3, 3);
  16831. cityArrCode.Add(endCity.ToUpper());
  16832. }
  16833. var cityThree = string.Empty;
  16834. cityArrCode.ForEach(x => cityThree += "'" + x + "',");
  16835. cityThree = cityThree.TrimEnd(',');
  16836. if (string.IsNullOrWhiteSpace(cityThree))
  16837. {
  16838. throw new
  16839. Exception("error");
  16840. }
  16841. string sql = $"SELECT * FROM Res_ThreeCode rtc WHERE UPPER(rtc.Three) in ({cityThree}) ";
  16842. var cityArr = _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToList();
  16843. foreach (var item in cityArrCode)
  16844. {
  16845. var find = cityArr.Find(x => x.Three.ToUpper() == item.ToUpper());
  16846. if (find != null)
  16847. {
  16848. city += find.City + "/";
  16849. }
  16850. else
  16851. {
  16852. city += item + "三字码未收入/";
  16853. }
  16854. }
  16855. city = city.TrimEnd('/');
  16856. }
  16857. catch (Exception e)
  16858. {
  16859. city = "黑屏代码格式不正确!";
  16860. }
  16861. }
  16862. }
  16863. else
  16864. {
  16865. city = "未录入黑屏代码";
  16866. }
  16867. var OpTravelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0).OrderBy(x => x.Days).Select(x => new TravelArrView
  16868. {
  16869. Date = x.Date,
  16870. Days = x.Days,
  16871. Diffgroup = x.Diffgroup,
  16872. Diid = x.Diid,
  16873. Traffic_First = x.Traffic_First,
  16874. Traffic_Second = x.Traffic_Second,
  16875. Trip = x.Trip,
  16876. WeekDay = x.WeekDay,
  16877. Id = x.Id
  16878. }).ToList();
  16879. jw.Data = new
  16880. {
  16881. groupList = groupList.Select(x => new
  16882. {
  16883. x.Id,
  16884. x.TeamName,
  16885. x.TourCode
  16886. }).ToList(),
  16887. groupInfo = new
  16888. {
  16889. group.VisitDays,
  16890. group.TourCode,
  16891. group.VisitPNumber,
  16892. group.TeamName,
  16893. city
  16894. },
  16895. OpTravelList
  16896. };
  16897. jw.Code = 200;
  16898. jw.Msg = "操作成功!";
  16899. return Ok(jw);
  16900. }
  16901. /// <summary>
  16902. /// 删除团组行程单
  16903. /// </summary>
  16904. /// <returns></returns>
  16905. [HttpPost]
  16906. public IActionResult DelTravel(DelOpTravelDto dto)
  16907. {
  16908. var jw = JsonView(false);
  16909. if (dto.UserId <= 0 || dto.Diid <= 0)
  16910. {
  16911. jw.Msg = "请输入正确的参数!";
  16912. return Ok(jw);
  16913. }
  16914. var isTrue = _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Diid == dto.Diid && x.IsDel == 0)
  16915. .SetColumns(x => new Grp_TravelList
  16916. {
  16917. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  16918. DeleteUserId = dto.UserId,
  16919. IsDel = 1,
  16920. }).ExecuteCommand();
  16921. jw = JsonView(true);
  16922. return Ok(jw);
  16923. }
  16924. /// <summary>
  16925. /// 行程单保存
  16926. /// </summary>
  16927. /// <returns></returns>
  16928. [HttpPost]
  16929. public IActionResult TravelSave(TravelSaveDto dto)
  16930. {
  16931. var jw = JsonView(false);
  16932. if (dto.Arr.Count > 0)
  16933. {
  16934. try
  16935. {
  16936. var travelList_DB = _sqlSugar.Queryable<Grp_TravelList>()
  16937. .Where(x => dto.Arr.Select(x => x.Id).Contains(x.Id))
  16938. .ToList();
  16939. _sqlSugar.BeginTran();
  16940. foreach (var item in dto.Arr)
  16941. {
  16942. if (item.Id == 0)
  16943. {
  16944. throw new Exception("请传入正确的Id");
  16945. }
  16946. //比较上一次的差异
  16947. var findTravel = travelList_DB.Find(x => x.Id == item.Id);
  16948. if (findTravel != null)
  16949. {
  16950. item.Trip = item.Trip.Replace("[++]", string.Empty);
  16951. findTravel.Trip = findTravel.Trip.Replace("[++]", string.Empty);
  16952. item.Trip = CheckStr(findTravel.Trip, item.Trip);
  16953. }
  16954. _sqlSugar.Updateable<Grp_TravelList>().Where(x => x.Id == item.Id)
  16955. .SetColumns(x => new Grp_TravelList
  16956. {
  16957. Trip = item.Trip
  16958. }).ExecuteCommand();
  16959. }
  16960. _sqlSugar.CommitTran();
  16961. jw = JsonView(true);
  16962. }
  16963. catch (Exception ex)
  16964. {
  16965. _sqlSugar.RollbackTran();
  16966. jw.Msg = "程序异常!" + ex.Message;
  16967. }
  16968. }
  16969. else
  16970. {
  16971. jw.Msg = "请传入正确的参数!";
  16972. }
  16973. return Ok(jw);
  16974. }
  16975. private static string CheckStr(string original, string changed)
  16976. {
  16977. // 创建diff_match_patch对象
  16978. var dmp = new diff_match_patch();
  16979. // 计算差异
  16980. List<Diff> diffs = dmp.diff_main(original, changed);
  16981. // 清理和合并差异
  16982. dmp.diff_cleanupSemantic(diffs);
  16983. // 使用StringBuilder构建最终的字符串
  16984. var finalString = new StringBuilder();
  16985. // 输出差异结果,并构建变动后的字符串
  16986. foreach (Diff diff in diffs)
  16987. {
  16988. switch (diff.operation)
  16989. {
  16990. case Operation.EQUAL:
  16991. // 相等的部分,直接添加到最终字符串
  16992. finalString.Append(diff.text);
  16993. break;
  16994. case Operation.INSERT:
  16995. // 插入的部分,添加标记并添加到最终字符串
  16996. finalString.Append("[++]" + diff.text + "[++]");
  16997. break;
  16998. case Operation.DELETE:
  16999. // 删除的部分,不添加到最终字符串
  17000. //finalString.Append("[++]" + diff.text + "[++]");
  17001. break;
  17002. }
  17003. }
  17004. // 输出变动后的字符串
  17005. return finalString.ToString();
  17006. }
  17007. private class tagContent
  17008. {
  17009. public DateTime Date { get; set; }
  17010. public string StartTag { get; set; }
  17011. public string EndTag { get; set; }
  17012. public string Content { get; set; }
  17013. public static int tagLength { get { return 3; } }
  17014. public static Tuple<string, string> TagFormat { get { return new Tuple<string, string>("【#", "#】"); } }
  17015. public string QueryTag { get { return this.StartTag + this.EndTag; } }
  17016. public bool IsFinally { get; set; }
  17017. }
  17018. private static List<string> ExtractContentBetweenTags(string input, string tag)
  17019. {
  17020. var results = new List<string>();
  17021. // 构造正则表达式,匹配形如 [++]内容[++] 的部分
  17022. string pattern = $@"{Regex.Escape(tag)}(.*?){Regex.Escape(tag)}";
  17023. // 添加 RegexOptions.Singleline 选项使 . 匹配包括换行符在内的所有字符
  17024. MatchCollection matches = Regex.Matches(input, pattern, RegexOptions.Singleline);
  17025. string[] strValueArr = new string[1];
  17026. foreach (System.Text.RegularExpressions.Match match in matches)
  17027. {
  17028. var strValue = match.Groups[1].Value;
  17029. strValueArr = Regex.Split(strValue, @"\r\n|\n");
  17030. }
  17031. results.AddRange(strValueArr.Where(x => !string.IsNullOrWhiteSpace(x)));
  17032. return results;
  17033. }
  17034. /// <summary>
  17035. /// 导出行程单
  17036. /// </summary>
  17037. /// <param name="dto"></param>
  17038. /// <returns></returns>
  17039. [HttpPost]
  17040. public IActionResult ExportTravel(ExportTravelDto dto)
  17041. {
  17042. var jw = JsonView(false);
  17043. jw.Data = "";
  17044. int diid = 0;
  17045. var Find = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid);
  17046. if (Find == null)
  17047. {
  17048. jw.Msg = "请选择正确的团组!";
  17049. return Ok(jw);
  17050. }
  17051. else
  17052. {
  17053. diid = Find.Id;
  17054. }
  17055. //数据源
  17056. var _travelList = new List<Grp_TravelList>();
  17057. DataTable dtBlack = null;
  17058. try
  17059. {
  17060. dtBlack = GeneralMethod.GetTableByBlackCode(diid);
  17061. }
  17062. catch (Exception)
  17063. {
  17064. jw.Msg = "机票黑屏代码有误!";
  17065. return Ok(jw);
  17066. }
  17067. string CityStr = string.Empty;
  17068. if (dtBlack.Rows.Count == 0)
  17069. {
  17070. jw.Msg = "机票黑屏代码有误!";
  17071. return Ok(jw);
  17072. }
  17073. else
  17074. {
  17075. foreach (DataRow row in dtBlack.Rows)
  17076. {
  17077. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  17078. {
  17079. jw.Msg = "机票黑屏代码有误!" + row["Error"].ToString();
  17080. return Ok(jw);
  17081. }
  17082. }
  17083. CityStr = GeneralMethod.GetGroupCityLine(diid, "/");
  17084. _travelList = _sqlSugar.Queryable<Grp_TravelList>().Where(x => x.Diid == diid && x.IsDel == 0 && x.Issel == 1).ToList();
  17085. }
  17086. // 指定的文字
  17087. var targetTextDic = new Dictionary<string, List<string>>();
  17088. //创建数据源Table
  17089. var dtSource = new DataTable();
  17090. dtSource.Columns.Add("Days", typeof(string));
  17091. dtSource.Columns.Add("Date", typeof(string));
  17092. dtSource.Columns.Add("Week", typeof(string));
  17093. dtSource.Columns.Add("Traffic", typeof(string));
  17094. dtSource.Columns.Add("Trip", typeof(string));
  17095. //获取数据,放到datatable
  17096. foreach (var item in _travelList)
  17097. {
  17098. targetTextDic.Add(item.Date, ExtractContentBetweenTags(item.Trip, "[++]"));
  17099. item.Trip = item.Trip.Replace(tagContent.TagFormat.Item1, string.Empty)
  17100. .Replace(tagContent.TagFormat.Item2, string.Empty)
  17101. .Replace("[++]", string.Empty);
  17102. DataRow dr = dtSource.NewRow();
  17103. dr["Days"] = item.Days;
  17104. dr["Date"] = item.Date;
  17105. dr["Week"] = item.WeekDay;
  17106. dr["Traffic"] = item.Traffic_First
  17107. + "\r\n"
  17108. + item.Traffic_Second;
  17109. dr["Trip"] = item.Trip;
  17110. dtSource.Rows.Add(dr);
  17111. }
  17112. var dic = new Dictionary<string, string>
  17113. {
  17114. { "Dele", Find.TeamName.ToString() + GetNum(Find.VisitDays.ToString()) },
  17115. { "City", CityStr },
  17116. { "Days", Find.VisitDays.ToString() },
  17117. { "DeleCode", Find.TourCode },
  17118. { "Pnum", Find.VisitPNumber.ToString() }
  17119. };
  17120. //模板路径
  17121. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Travel/日行程3.docx";
  17122. //载入模板
  17123. Document doc = null;
  17124. DocumentBuilder builder = null;
  17125. try
  17126. {
  17127. //载入模板
  17128. doc = new Document(tempPath);
  17129. builder = new DocumentBuilder(doc);
  17130. }
  17131. catch (Exception)
  17132. {
  17133. jw.Msg = "模板位置不存在!";
  17134. return Ok(jw);
  17135. }
  17136. foreach (var key in dic.Keys)
  17137. {
  17138. Bookmark bookmark = doc.Range.Bookmarks[key];
  17139. if (bookmark != null)
  17140. {
  17141. builder.MoveToBookmark(key);
  17142. builder.Write(dic[key]);
  17143. }
  17144. }
  17145. //获取word里所有表格
  17146. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  17147. //获取所填表格的序数
  17148. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  17149. try
  17150. {
  17151. //循环赋值
  17152. for (int i = 0; i < dtSource.Rows.Count; i++)
  17153. {
  17154. builder.MoveToCell(0, i + 1, 0, 0);
  17155. builder.Write(dtSource.Rows[i]["Days"].ToString());
  17156. builder.MoveToCell(0, i + 1, 1, 0);
  17157. builder.Write(dtSource.Rows[i]["Date"].ToString() + "\r\n" + dtSource.Rows[i]["Week"].ToString());
  17158. builder.MoveToCell(0, i + 1, 2, 0);
  17159. builder.Write(dtSource.Rows[i]["Traffic"].ToString());
  17160. var trip = dtSource.Rows[i]["Trip"].ToString();
  17161. builder.MoveToCell(0, i + 1, 3, 0);
  17162. builder.Write(trip);
  17163. var cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 1, true);
  17164. var paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  17165. // 获取特定索引的段落
  17166. Paragraph paragraph = (Paragraph)paragraphs[0];
  17167. Run run = paragraph.Runs[0];
  17168. Aspose.Words.Font font = run.Font;
  17169. font.Name = "黑体";
  17170. //设置双休红色
  17171. cell = (Aspose.Words.Tables.Cell)doc.GetChild(NodeType.Cell, ((i + 2) * 4) - 3, true);
  17172. paragraphs = cell.GetChildNodes(NodeType.Paragraph, true);
  17173. paragraph = (Paragraph)paragraphs[1];
  17174. if (paragraph.GetText().Contains("星期六") || paragraph.GetText().Contains("星期日"))
  17175. {
  17176. run = paragraph.Runs[0];
  17177. font = run.Font;
  17178. font.Color = Color.Red;
  17179. }
  17180. }
  17181. }
  17182. catch (Exception ex)
  17183. {
  17184. }
  17185. //删除多余行
  17186. while (tableOne.Rows.Count > 1 + dtSource.Rows.Count)
  17187. {
  17188. tableOne.Rows.RemoveAt(1 + dtSource.Rows.Count);//(1+dtSource.Rows.Count + 1)-1
  17189. }
  17190. var targetTextList = new List<string>();
  17191. // 遍历文档中的表格
  17192. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  17193. {
  17194. foreach (Aspose.Words.Tables.Row row in table.Rows)
  17195. {
  17196. var cellIndex = 0;
  17197. foreach (Cell cell in row.Cells)
  17198. {
  17199. if (cellIndex == 1 && row.Cells.Count == 4)
  17200. {
  17201. foreach (var target in targetTextDic.Keys)
  17202. {
  17203. if (cell.GetText().Contains(target))
  17204. {
  17205. targetTextList = targetTextDic[target];
  17206. break;
  17207. }
  17208. }
  17209. }
  17210. // 遍历单元格中的所有段落
  17211. foreach (Paragraph paragraph in cell.Paragraphs)
  17212. {
  17213. // 使用临时列表存储原始 Runs,避免修改时影响遍历
  17214. var runs = new List<Run>();
  17215. foreach (Run run in paragraph.Runs)
  17216. {
  17217. runs.Add(run);
  17218. }
  17219. foreach (Run run in runs)
  17220. {
  17221. foreach (var targetText in targetTextList)
  17222. {
  17223. // 检查文字是否包含指定文字
  17224. if (run.Text.Contains(targetText))
  17225. {
  17226. // 将包含的部分设置为红色
  17227. HighlightText(run, targetText, Color.Red);
  17228. }
  17229. }
  17230. }
  17231. }
  17232. cellIndex++;
  17233. }
  17234. }
  17235. }
  17236. string savePath = AppSettingsHelper.Get("WordBasePath") + "Travel/export/";
  17237. if (!Directory.Exists(savePath))
  17238. {
  17239. try
  17240. {
  17241. Directory.CreateDirectory(savePath);
  17242. }
  17243. catch
  17244. {
  17245. }
  17246. }
  17247. string path = savePath + Find.TeamName + "出访日程";
  17248. string ftpPath = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + "Travel/export/" + Find.TeamName + "出访日程";
  17249. try
  17250. {
  17251. Aspose.Words.SaveFormat saveFormat = Aspose.Words.SaveFormat.Doc;
  17252. string postfix = ".docx";
  17253. if (dto.IsPDF == 1)
  17254. {
  17255. saveFormat = Aspose.Words.SaveFormat.Pdf;
  17256. postfix = ".pdf";
  17257. }
  17258. doc.Save(path + postfix, saveFormat);
  17259. jw = JsonView(true, "导出成功", ftpPath + postfix);
  17260. }
  17261. catch (Exception)
  17262. {
  17263. jw = JsonView(false);
  17264. }
  17265. return Ok(jw);
  17266. }
  17267. /// <summary>
  17268. /// 根据大写数字返回小写数字或根据小写数字返回大写数字
  17269. /// </summary>
  17270. /// <param name="num"></param>
  17271. /// <returns></returns>
  17272. static string GetNum(string num)
  17273. {
  17274. string str = "";
  17275. switch (num)
  17276. {
  17277. case "1":
  17278. str = "一";
  17279. break;
  17280. case "2":
  17281. str = "二";
  17282. break;
  17283. case "3":
  17284. str = "三";
  17285. break;
  17286. case "4":
  17287. str = "四";
  17288. break;
  17289. case "5":
  17290. str = "五";
  17291. break;
  17292. case "6":
  17293. str = "六";
  17294. break;
  17295. case "7":
  17296. str = "七";
  17297. break;
  17298. case "8":
  17299. str = "八";
  17300. break;
  17301. case "9":
  17302. str = "九";
  17303. break;
  17304. case "10":
  17305. str = "十";
  17306. break;
  17307. case "11":
  17308. str = "十一";
  17309. break;
  17310. case "12":
  17311. str = "十二";
  17312. break;
  17313. case "一":
  17314. str = "1";
  17315. break;
  17316. case "二":
  17317. str = "2";
  17318. break;
  17319. case "三":
  17320. str = "3";
  17321. break;
  17322. case "四":
  17323. str = "4";
  17324. break;
  17325. case "五":
  17326. str = "5";
  17327. break;
  17328. case "六":
  17329. str = "6";
  17330. break;
  17331. case "七":
  17332. str = "7";
  17333. break;
  17334. case "八":
  17335. str = "8";
  17336. break;
  17337. case "九":
  17338. str = "9";
  17339. break;
  17340. case "十":
  17341. str = "10";
  17342. break;
  17343. case "十一":
  17344. str = "11";
  17345. break;
  17346. case "十二":
  17347. str = "12";
  17348. break;
  17349. }
  17350. return str;
  17351. }
  17352. /// <summary>
  17353. /// 高亮包含指定文字的部分
  17354. /// </summary>
  17355. /// <param name="run"></param>
  17356. /// <param name="targetText"></param>
  17357. /// <param name="color"></param>
  17358. static void HighlightText(Run run, string targetText, Color color)
  17359. {
  17360. string text = run.Text;
  17361. int startIndex = text.IndexOf(targetText, StringComparison.Ordinal);
  17362. if (startIndex >= 0)
  17363. {
  17364. Paragraph parentParagraph = (Paragraph)run.ParentNode;
  17365. // 前部分
  17366. if (startIndex > 0)
  17367. {
  17368. Run beforeRun = (Run)run.Clone(true);
  17369. beforeRun.Text = text.Substring(0, startIndex);
  17370. parentParagraph.InsertBefore(beforeRun, run);
  17371. }
  17372. // 匹配部分
  17373. Run matchRun = (Run)run.Clone(true);
  17374. matchRun.Text = text.Substring(startIndex, targetText.Length);
  17375. matchRun.Font.Color = color;
  17376. parentParagraph.InsertBefore(matchRun, run);
  17377. // 后部分
  17378. if (startIndex + targetText.Length < text.Length)
  17379. {
  17380. Run afterRun = (Run)run.Clone(true);
  17381. afterRun.Text = text.Substring(startIndex + targetText.Length);
  17382. parentParagraph.InsertBefore(afterRun, run);
  17383. }
  17384. // 删除原始Run
  17385. run.Remove();
  17386. }
  17387. }
  17388. #endregion
  17389. #endregion
  17390. #region 团组成本
  17391. /// <summary>
  17392. /// 团组成本数据初始化
  17393. /// </summary>
  17394. /// <param name="dto"></param>
  17395. /// <returns></returns>
  17396. [HttpPost]
  17397. public async Task<IActionResult> GroupCostInit(GroupCostInItDto dto)
  17398. {
  17399. var groupList = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  17400. Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  17401. WHEN COUNT(*) >= 0 THEN 'True'
  17402. ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  17403. Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  17404. ").ToList(); //团组列表
  17405. int diid = dto.Diid == -1 ? groupList.First().Id : dto.Diid;
  17406. var groupInfo = await _groupRepository.PostShareGroupInfo(new ShareGroupInfoDto { PortType = 1, Id = diid }); //团组信息
  17407. var visaCountryInfoArr = new ArrayList();
  17408. var groupinfoValue = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == diid && x.IsDel == 0);
  17409. if (groupinfoValue != null)
  17410. {
  17411. var countryArr = groupinfoValue.VisitCountry ??= string.Empty;
  17412. var dicity = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == groupinfoValue.CityId);
  17413. dicity ??= new Sys_Cities()
  17414. {
  17415. ParentId = 122
  17416. };
  17417. var diparent = _sqlSugar.Queryable<Sys_Cities>().First(x => x.IsDel == 0 && x.Id == dicity.ParentId);
  17418. var spArr = new string[1] { countryArr };
  17419. if (countryArr.Contains("|"))
  17420. {
  17421. spArr = countryArr.Split("|");
  17422. }
  17423. else if (countryArr.Contains("、"))
  17424. {
  17425. spArr = countryArr.Split("、");
  17426. }
  17427. foreach (var item in spArr.Where(x => !string.IsNullOrWhiteSpace(x)).ToList())
  17428. {
  17429. try
  17430. {
  17431. var visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  17432. .Where(x => x.IsDel == 0 && x.Country == item)
  17433. .ToList();
  17434. if (!visa.Any())
  17435. {
  17436. visa = _sqlSugar.Queryable<Res_VisaFeeStandard>()
  17437. .Where(x => x.IsDel == 0 && x.Country.Contains(item))
  17438. .ToList();
  17439. }
  17440. if (visa.Any())
  17441. {
  17442. var visainfo = _sqlSugar.Queryable<Res_VisaFeeStandardDetails>()
  17443. .Where(x => x.IsDel == 0 && visa.Select(x => x.Id).Contains(x.ParentId))
  17444. .ToList();
  17445. var visaMain = visainfo.FirstOrDefault(x => x.ProvinceId == diparent.Id);
  17446. var visayinsiValue = visainfo.FirstOrDefault(x => x.ParentId == visa.FirstOrDefault(x => x.FeeType == 1)?.Id);
  17447. visaCountryInfoArr.Add(new
  17448. {
  17449. country = item,
  17450. yinsi = new
  17451. {
  17452. Id = visayinsiValue.Id,
  17453. value = visayinsiValue.SmallVisaPrice
  17454. },
  17455. visaMain = new
  17456. {
  17457. Id = visaMain.Id,
  17458. IsVisaOnArrival = visaMain.IsVisaOnArrival ? "是" : "否",
  17459. IsElectronicSign = visaMain.IsElectronicSign ? "是" : "否",
  17460. VisaTime = visaMain.VisaTime,
  17461. IsVisaExemptionLarge = visaMain.IsVisaExemptionLarge ? "是" : "否",
  17462. LargeVisaPrice = visaMain.LargeVisaPrice,
  17463. LargeAgencyFee = visaMain.LargeAgencyFee,
  17464. IsVisaExemptionSmall = visaMain.IsVisaExemptionSmall ? "是" : "否",
  17465. SmallVisaPrice = visaMain.SmallVisaPrice,
  17466. SmallAgencyFee = visaMain.SmallAgencyFee,
  17467. NormExtFee = visaMain.NormExtFee,
  17468. UrgExtFee = visaMain.UrgExtFee,
  17469. IsUrgent = visaMain.IsUrgent ? "是" : "否",
  17470. UrgentTime = visaMain.UrgentTime,
  17471. UrgentPrice = visaMain.UrgentPrice,
  17472. UrgentPriceDesc = visaMain.UrgentPriceDesc,
  17473. Remark = visaMain.Remark,
  17474. }
  17475. });
  17476. }
  17477. }
  17478. catch (Exception ex)
  17479. {
  17480. //写入日志
  17481. _logger.LogError(ex, "团组成本解析签证异常!");
  17482. }
  17483. }
  17484. }
  17485. var groupChecks = _checkBoxs.GetCheckBoxsByDiid(diid); //团组选中信息 可枚举
  17486. var groupCost = _GroupCostRepository.GetAllByDiid(diid); //团组列表信息
  17487. #region 屏蔽黑屏代码生成
  17488. //var create = _GroupCostRepository.
  17489. // CreateGroupCostByBlackCode(dto.Diid);
  17490. //if (groupCost.Count == 0 && create.Code == 0)
  17491. //{
  17492. // groupCost = (create.Data as List<Grp_GroupCost>) ?? new List<Grp_GroupCost>();
  17493. //}
  17494. #endregion
  17495. var groupCostMap = _mapper.Map<List<Grp_GroupCostDto>>(groupCost);
  17496. var hotelNumber = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(diid); //酒店数量 可枚举
  17497. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(diid); //成本系数 可枚举
  17498. groupCostMap = groupCostMap.Select(x =>
  17499. {
  17500. if (DateTime.TryParse(x.Date, out DateTime dataForamt))
  17501. {
  17502. x.Date = dataForamt.ToString("yyyy-MM-dd");
  17503. }
  17504. return x;
  17505. }).ToList();
  17506. //GroupCostParameter.Add(new
  17507. // Grp_GroupCostParameter());
  17508. var GroupCostParameterMap = _mapper.Map<List<Grp_GroupCostParameterDto>>(GroupCostParameter);
  17509. bool hotelIsTrue = _sqlSugar.Queryable<Grp_HotelInquiry>().Where(x => x.DiId == diid && x.IsDel == 0).Count() > 0;
  17510. var groupModuleOperators = GeneralMethod.GetGroupModuleOperators(diid);
  17511. return Ok(JsonView(new
  17512. {
  17513. groupList,
  17514. groupInfo,
  17515. groupChecks,
  17516. groupCost = groupCostMap,
  17517. hotelNumber,
  17518. GroupCostParameter = GroupCostParameterMap,
  17519. visaCountryInfoArr = visaCountryInfoArr,
  17520. baoPi = _GroupCostParameterRepository.GetBaoPi(diid),
  17521. blackCodeIsTrue = _sqlSugar.Queryable<Air_TicketBlackCode>().Where(x => x.IsDel == 0 && x.DiId == diid).Any(), //create.Code == 0 ? true : false,
  17522. hotelIsTrue,
  17523. groupModuleOperators
  17524. }));
  17525. }
  17526. /// <summary>
  17527. /// 团组成本信息保存
  17528. /// </summary>
  17529. /// <param name="dto"></param>
  17530. /// <returns></returns>
  17531. [HttpPost]
  17532. public async Task<IActionResult> SaveGroupCost(GroupCostSavaDto dto)
  17533. {
  17534. if (dto.Diid <= 0 || dto.Userid <= 0)
  17535. {
  17536. return Ok(JsonView(false));
  17537. }
  17538. JsonView jw = null;
  17539. bool isTrue = false;
  17540. #region 复制团组成本
  17541. //if (dto.Diid == 2581)
  17542. //{
  17543. // dto.Diid = 2599;
  17544. // dto.CheckBoxs.ForEach(x =>
  17545. // {
  17546. // x.Diid = 2599;
  17547. // });
  17548. // dto.GroupCosts.ForEach(x =>
  17549. // {
  17550. // x.Diid = 2599;
  17551. // });
  17552. // dto.CostTypeHotelNumbers.ForEach(x =>
  17553. // {
  17554. // x.Diid = 2599;
  17555. // });
  17556. // dto.GroupCostParameters.ForEach(x =>
  17557. // {
  17558. // x.DiId = 2599;
  17559. // });
  17560. //}
  17561. #endregion
  17562. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  17563. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  17564. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  17565. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  17566. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  17567. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  17568. try
  17569. {
  17570. _sqlSugar.BeginTran();
  17571. isTrue = await _GroupCostRepository.
  17572. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  17573. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  17574. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  17575. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  17576. _sqlSugar.CommitTran();
  17577. jw = JsonView(true, "保存成功!", isTrue);
  17578. }
  17579. catch (Exception)
  17580. {
  17581. _sqlSugar.RollbackTran();
  17582. jw = JsonView(false);
  17583. }
  17584. return Ok(jw);
  17585. }
  17586. /// <summary>
  17587. /// 复制团组成本信息
  17588. /// </summary>
  17589. /// <param name="dto"></param>
  17590. /// <returns></returns>
  17591. [HttpPost]
  17592. public async Task<IActionResult> CopyGroupCost(CopyGroupCostDto dto)
  17593. {
  17594. if (dto.Diid <= 0 || dto.Userid <= 0 || dto.ToGroupId <= 0)
  17595. {
  17596. return Ok(JsonView(false, "参数有误!"));
  17597. }
  17598. #region 复制团组成本
  17599. dto.Diid = dto.ToGroupId;
  17600. dto.CheckBoxs.ForEach(x =>
  17601. {
  17602. x.Diid = dto.ToGroupId;
  17603. });
  17604. dto.GroupCosts.ForEach(x =>
  17605. {
  17606. x.Diid = dto.ToGroupId;
  17607. });
  17608. dto.CostTypeHotelNumbers.ForEach(x =>
  17609. {
  17610. x.Diid = dto.ToGroupId;
  17611. });
  17612. dto.GroupCostParameters.ForEach(x =>
  17613. {
  17614. x.DiId = dto.ToGroupId;
  17615. });
  17616. #endregion
  17617. JsonView jw = null;
  17618. bool isTrue = false;
  17619. var Grp_groups = _mapper.Map<List<Grp_GroupCost>>(dto.GroupCosts);
  17620. Grp_groups.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; }); //.ToString("yyyy-MM-dd HH:mm:ss")
  17621. var Grp_CheckBoxs = _mapper.Map<List<Grp_CheckBoxs>>(dto.CheckBoxs);
  17622. Grp_CheckBoxs.ForEach(x => { x.CreateUserId = dto.Userid; x.CreateTime = DateTime.Now; });
  17623. var Grp_HotelNumber = _mapper.Map<List<Grp_CostTypeHotelNumber>>(dto.CostTypeHotelNumbers);
  17624. var Grp_CostParameters = _mapper.Map<List<Grp_GroupCostParameter>>(dto.GroupCostParameters);
  17625. try
  17626. {
  17627. _sqlSugar.BeginTran();
  17628. isTrue = await _GroupCostRepository.
  17629. SaveGroupCostList(Grp_groups, dto.Diid, dto.Userid); //列表
  17630. isTrue = await _checkBoxs.SaveCheckBoxs(Grp_CheckBoxs, dto.Diid); //选中项
  17631. isTrue = await _CostTypeHotelNumberRepository.SaveHotelNumber(Grp_HotelNumber, dto.Userid, dto.Diid); //酒店房间数量
  17632. isTrue = await _GroupCostParameterRepository.SaveAsync(Grp_CostParameters, dto.Userid, dto.Diid); //系数
  17633. _sqlSugar.CommitTran();
  17634. jw = JsonView(true, "保存成功!", isTrue);
  17635. }
  17636. catch (Exception)
  17637. {
  17638. _sqlSugar.RollbackTran();
  17639. jw = JsonView(false);
  17640. }
  17641. return Ok(jw);
  17642. }
  17643. /// <summary>
  17644. /// 司兼导数据
  17645. /// </summary>
  17646. /// <param name="dto"></param>
  17647. /// <returns></returns>
  17648. [HttpPost]
  17649. public IActionResult GetCarGuides(CarGuidesDto dto)
  17650. {
  17651. var Data = _sqlSugar.SqlQueryable<Grp_CarGuides>($@" select * from Grp_CarGuides where isdel = 0 ").ToList();
  17652. return Ok(JsonView(true, "获取成功!", Data));
  17653. }
  17654. /// <summary>
  17655. /// 导游数据
  17656. /// </summary>
  17657. /// <param name="dto"></param>
  17658. /// <returns></returns>
  17659. [HttpPost]
  17660. public IActionResult GetGuidesInfo(CarGuidesDto dto)
  17661. {
  17662. //var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" SELECT* FROM (
  17663. // 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
  17664. // where RowNumber BETWEEN {(dto.Page - 1) * dto.Size + 1} and {(dto.Page) * dto.Size}").ToList();
  17665. var Data = _sqlSugar.SqlQueryable<Grp_GuidesInfo>($@" select * from Grp_GuidesInfo where isdel = 0 ").ToList();
  17666. return Ok(JsonView(true, "获取成功!", Data));
  17667. }
  17668. /// <summary>
  17669. /// 成本车数据
  17670. /// </summary>
  17671. /// <param name="dto"></param>
  17672. /// <returns></returns>
  17673. [HttpPost]
  17674. public IActionResult GetCarInfo(CarGuidesDto dto)
  17675. {
  17676. var Data = _sqlSugar.SqlQueryable<Grp_CarInfo>($@" select * from Grp_CarInfo where isdel = 0 ").ToList();
  17677. return Ok(JsonView(true, "获取成功!", Data));
  17678. }
  17679. /// <summary>
  17680. /// 景点数据
  17681. /// </summary>
  17682. /// <param name="dto"></param>
  17683. /// <returns></returns>
  17684. [HttpPost]
  17685. public IActionResult GetScenicSpotInfo(CarGuidesDto dto)
  17686. {
  17687. var Data = _sqlSugar.SqlQueryable<Grp_ScenicSpotInfo>($@" select * from Grp_ScenicSpotInfo where isdel = 0 ").ToList();
  17688. return Ok(JsonView(true, "获取成功!", Data));
  17689. }
  17690. /// <summary>
  17691. /// 成本通知
  17692. /// </summary>
  17693. /// <param name="dto"></param>
  17694. /// <returns></returns>
  17695. [HttpPost]
  17696. public async Task<IActionResult> GroupIsShare(GroupIsShareDto dto)
  17697. {
  17698. if (dto.Diid < 0)
  17699. {
  17700. return Ok(JsonView(false));
  17701. }
  17702. JsonView jw;
  17703. var GroupCostParameter = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  17704. if (GroupCostParameter != null)
  17705. {
  17706. int IsShare = 0;
  17707. if (GroupCostParameter.IsShare == 0) IsShare = 1;
  17708. else if (GroupCostParameter.IsShare == 1) IsShare = 0;
  17709. bool isTrue = await _GroupCostParameterRepository.UpdateIsShareById(GroupCostParameter.Id, IsShare);
  17710. string msg = string.Empty;
  17711. if (isTrue)
  17712. {
  17713. if (IsShare == 0)
  17714. {
  17715. msg = "禁止通知,其他模块操作人员不可见此成本信息!";
  17716. }
  17717. else
  17718. {
  17719. #region 企微通知对应岗位用户
  17720. try
  17721. {
  17722. await AppNoticeLibrary.SendUserMsg_GroupShare_ToJob(dto.Diid);
  17723. //机票预算群通知
  17724. await AppNoticeLibrary.SendChatMsg_AirCostChat(dto.Diid, QiyeWeChatEnum.AirCostChat01);
  17725. }
  17726. catch (Exception)
  17727. {
  17728. }
  17729. #endregion
  17730. msg = "通知成功,其他模块操作人员可见此成本信息!";
  17731. }
  17732. jw = JsonView(isTrue, msg, new { IsShare });
  17733. }
  17734. else
  17735. {
  17736. msg = "修改失败!";
  17737. jw = JsonView(isTrue, msg);
  17738. }
  17739. }
  17740. else
  17741. {
  17742. jw = JsonView(false, "该团没有数据,请添加数据,保存后再操作!");
  17743. }
  17744. return Ok(jw);
  17745. }
  17746. /// <summary>
  17747. /// 导出报价单
  17748. /// </summary>
  17749. /// <param name="dto"></param>
  17750. /// <returns></returns>
  17751. [HttpPost]
  17752. public async Task<IActionResult> ExportPriceCheckWordFile(GroupCostExportWordFile dto)
  17753. {
  17754. if (dto.Diid == 0)
  17755. {
  17756. return Ok(JsonView(false, "请传递团组id"));
  17757. }
  17758. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  17759. if (deleInfo.Code != 0)
  17760. {
  17761. return Ok(JsonView(false, "团组信息查询失败!"));
  17762. }
  17763. var di = deleInfo.Data as DelegationInfoWebView;
  17764. if (di != null)
  17765. {
  17766. di.TeamName = di.TeamName.Replace("|", "、");
  17767. di.VisitCountry = di.VisitCountry.Replace("|", "、");
  17768. //文件名
  17769. string strFileName = di.TeamName + "-收款账单.doc";
  17770. //获取模板
  17771. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  17772. //载入模板
  17773. Document doc = new Document(tmppath);
  17774. decimal TotalPrice = 0.00M;
  17775. string itemStr = string.Empty;
  17776. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  17777. //airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  17778. airSouer.Add("JJCTBR", "经济舱及酒店双人间");
  17779. airSouer.Add("JJCSGR", "经济舱及酒店单人间");
  17780. airSouer.Add("GWCSGR", "公务舱及酒店单人间");
  17781. airSouer.Add("GWCJSES", "公务舱及酒店小套房");
  17782. airSouer.Add("GWCSUITE", "公务舱及酒店套房");
  17783. airSouer.Add("JJCSUITE", "经济舱及酒店套房");
  17784. var groupCostType = dto.airs.GroupBy(x => x.costType).OrderBy(x => x.Key);
  17785. foreach (var cost in groupCostType)
  17786. {
  17787. var List = cost.ToList();
  17788. if (cost.Key == "A")
  17789. {
  17790. foreach (var ListItem in List)
  17791. {
  17792. if (ListItem.number > 0)
  17793. {
  17794. if (ListItem.code.Contains("TBR"))
  17795. {
  17796. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17797. }
  17798. else
  17799. {
  17800. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17801. }
  17802. TotalPrice += (ListItem.number * ListItem.price);
  17803. }
  17804. }
  17805. }
  17806. else
  17807. {
  17808. itemStr = itemStr.Insert(0, "A段\r\n");
  17809. itemStr += "B段\r\n";
  17810. foreach (var ListItem in List)
  17811. {
  17812. if (ListItem.number > 0)
  17813. {
  17814. if (ListItem.code.Contains("TBR"))
  17815. {
  17816. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + (ListItem.number / 2) + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17817. }
  17818. else
  17819. {
  17820. itemStr += "团费(" + airSouer[ListItem.code] + ") RMB " + ListItem.price.ToString("F2") + "/人*" + ListItem.number + "(" + ListItem.number + "间) ............合计 RMB " + (ListItem.number * ListItem.price).ToString("#0.00") + "\n";
  17821. }
  17822. TotalPrice += (ListItem.number * ListItem.price);
  17823. }
  17824. }
  17825. }
  17826. }
  17827. #region 替换Word模板书签内容
  17828. Dictionary<string, string> marks = new Dictionary<string, string>();
  17829. marks.Add("To", di.ClientUnit);//付款方
  17830. marks.Add("ToTel", di.TellPhone);//付款方电话
  17831. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  17832. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  17833. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  17834. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  17835. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  17836. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  17837. marks.Add("PayItemContent", itemStr);//详细信息
  17838. marks.Add("Total", TotalPrice.ToString("F2"));//合计
  17839. #endregion
  17840. ////注
  17841. //if (doc.Range.Bookmarks["Attention"] != null)
  17842. //{
  17843. // Bookmark mark = doc.Range.Bookmarks["Attention"];
  17844. // mark.Text = frList[0].Attention;
  17845. //}
  17846. foreach (var item in marks.Keys)
  17847. {
  17848. if (doc.Range.Bookmarks[item] != null)
  17849. {
  17850. Bookmark mark = doc.Range.Bookmarks[item];
  17851. mark.Text = marks[item];
  17852. }
  17853. }
  17854. byte[] bytes = null;
  17855. using (MemoryStream stream = new MemoryStream())
  17856. {
  17857. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  17858. bytes = stream.ToArray();
  17859. }
  17860. //doc.Save((AppSettingsHelper.Get("WordBasePath") + "Template/") + strFileName);
  17861. return Ok(JsonView(true, "", new
  17862. {
  17863. Data = bytes,
  17864. strFileName,
  17865. }));
  17866. }
  17867. else
  17868. {
  17869. return Ok(JsonView(false, "团组信息不存在!"));
  17870. }
  17871. }
  17872. /// <summary>
  17873. /// 导出团组成本
  17874. /// </summary>
  17875. /// <param name="dto"></param>
  17876. /// <returns></returns>
  17877. [HttpPost]
  17878. public async Task<IActionResult> ExportGroupCostExcelFile(GroupCostExportExcelFile dto)
  17879. {
  17880. var jw = JsonView(false);
  17881. if (dto.Diid == 0)
  17882. {
  17883. return Ok(JsonView(false, "请传递团组id"));
  17884. }
  17885. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  17886. if (deleInfo.Code != 0)
  17887. {
  17888. return Ok(JsonView(false, "团组信息查询失败!"));
  17889. }
  17890. var di = deleInfo.Data as DelegationInfoWebView;
  17891. if (di == null)
  17892. {
  17893. return Ok(JsonView(false, "团组信息查询失败!"));
  17894. }
  17895. List<GroupCost_Excel> List_GC1 = new List<GroupCost_Excel>();
  17896. WorkbookDesigner designer = new WorkbookDesigner();
  17897. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/团组-成本.xls"));
  17898. var List_GC = _GroupCostRepository.GetAllByDiid(dto.Diid);
  17899. List<int> hideColumnList = new List<int>();
  17900. var ColumnSetting = new[]
  17901. {
  17902. new { tag = "VF", Index = 4, P = "CarCost" },
  17903. new { tag = "VN", Index = 5, P = "CarNumber" },
  17904. new { tag = "VRD", Index = 6, P = "CarTiming" },
  17905. new { tag = "T/G S", Index = 7, P = "TGS" },
  17906. new { tag = "TGWH", Index = 8, P = "TGWH" },
  17907. new { tag = "T/G OF", Index = 9, P = "TGOF" },
  17908. new { tag = "T/G M", Index = 10, P = "TGM" },
  17909. new { tag = "T/G A", Index = 11, P = "TGA" },
  17910. new { tag = "T/G TF", Index = 12, P = "TGTF" },
  17911. new { tag = "T/G EF", Index = 13, P = "TGEF" },
  17912. new { tag = "C/F S", Index = 14, P = "CFS" },
  17913. new { tag = "C/F M", Index = 15, P = "CFM" },
  17914. new { tag = "C/F OF", Index = 16, P = "CFOF" },
  17915. new { tag = "B", Index = 17, P = "B" },
  17916. new { tag = "L", Index = 18, P = "L" },
  17917. new { tag = "D", Index = 19, P = "D" },
  17918. new { tag = "TBR", Index = 20, P = "TBR" },
  17919. new { tag = "SGR", Index = 21, P = "SGR" },
  17920. new { tag = "JS/ES", Index = 22, P = "JS_ES" },
  17921. new { tag = "Suite", Index = 23, P = "Suite" },
  17922. new { tag = "ACCO N", Index = 24, P = "ACCON" },
  17923. new { tag = "T/V", Index = 25, P = "TV" },
  17924. new { tag = "1/L", Index = 26, P = "iL" },
  17925. new { tag = "I/F", Index = 27, P = "IF" },
  17926. new { tag = "EF", Index = 28, P = "EF" },
  17927. new { tag = "B/R/F", Index = 29, P = "B_R_F" },
  17928. new { tag = "TE", Index = 30, P = "TE" },
  17929. new { tag = "T/G T", Index = 31, P = "TGTips" },
  17930. new { tag = "DRV T", Index = 32, P = "DRVTips" },
  17931. new { tag = "P/C", Index = 33, P = "PC" },
  17932. new { tag = "T/L F", Index = 34, P = "TLF" },
  17933. new { tag = "E/C T", Index = 35, P = "ECT" }
  17934. };
  17935. Func<string, bool> isEmpty = (str) =>
  17936. {
  17937. if (decimal.TryParse(str, out decimal str_De) && str_De == 0)
  17938. {
  17939. return true;
  17940. }
  17941. if (string.IsNullOrWhiteSpace(str))
  17942. {
  17943. return true;
  17944. }
  17945. return false;
  17946. };
  17947. for (int i = 0; i < List_GC.Count; i++)
  17948. {
  17949. GroupCost_Excel gc = new GroupCost_Excel();
  17950. gc.Id = List_GC[i].Id;
  17951. gc.Diid = List_GC[i].Diid.ToString();
  17952. gc.DAY = List_GC[i].DAY;
  17953. string week = "";
  17954. if (!string.IsNullOrEmpty(List_GC[i].Date.Trim()))
  17955. week = CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(Convert.ToDateTime(List_GC[i].Date).DayOfWeek);
  17956. gc.Date = (List_GC[i].Date + "\n" + week).ToString();
  17957. gc.ITIN = List_GC[i].ITIN;
  17958. gc.CarType = List_GC[i].CarType;
  17959. gc.CarTiming = isEmpty(List_GC[i].CarTiming.ToString()) ? "" : List_GC[i].CarTiming.ToString();
  17960. gc.CarCost = isEmpty(List_GC[i].CarCost.ToString()) ? "" : List_GC[i].CarCost.ToString();
  17961. gc.CarNumber = isEmpty(List_GC[i].CarNumber.ToString()) ? "" : List_GC[i].CarNumber.ToString();
  17962. gc.TGS = isEmpty(List_GC[i].TGS.ToString()) ? "" : List_GC[i].TGS.ToString();
  17963. gc.TGWH = isEmpty(List_GC[i].TGWH.ToString()) ? "" : List_GC[i].TGWH.ToString();
  17964. gc.TGN = isEmpty(List_GC[i].TGN.ToString()) ? "" : List_GC[i].TGN.ToString();
  17965. gc.TGOF = isEmpty(List_GC[i].TGOF.ToString()) ? "" : List_GC[i].TGOF.ToString();
  17966. gc.TGM = isEmpty(List_GC[i].TGM.ToString()) ? "" : List_GC[i].TGM.ToString();
  17967. gc.TGA = isEmpty(List_GC[i].TGA.ToString()) ? "" : List_GC[i].TGA.ToString();
  17968. gc.TGTF = isEmpty(List_GC[i].TGTF.ToString()) ? "" : List_GC[i].TGTF.ToString();
  17969. gc.TGEF = isEmpty(List_GC[i].TGEF.ToString()) ? "" : List_GC[i].TGEF.ToString();
  17970. gc.CFS = isEmpty(List_GC[i].CFS.ToString()) ? "" : List_GC[i].CFS.ToString();
  17971. gc.CFM = isEmpty(List_GC[i].CFM.ToString()) ? "" : List_GC[i].CFM.ToString();
  17972. gc.CFOF = isEmpty(List_GC[i].CFOF.ToString()) ? "" : List_GC[i].CFOF.ToString();
  17973. gc.B = isEmpty(List_GC[i].B.ToString()) ? "" : List_GC[i].B.ToString();
  17974. gc.L = isEmpty(List_GC[i].L.ToString()) ? "" : List_GC[i].L.ToString();
  17975. gc.D = isEmpty(List_GC[i].D.ToString()) ? "" : List_GC[i].D.ToString();
  17976. gc.TBR = isEmpty(List_GC[i].TBR.ToString()) ? "" : List_GC[i].TBR.ToString();
  17977. gc.SGR = isEmpty(List_GC[i].SGR.ToString()) ? "" : List_GC[i].SGR.ToString();
  17978. gc.JS_ES = isEmpty(List_GC[i].JS_ES.ToString()) ? "" : List_GC[i].JS_ES.ToString();
  17979. gc.Suite = isEmpty(List_GC[i].Suite.ToString()) ? "" : List_GC[i].Suite.ToString();
  17980. gc.ACCON = isEmpty(List_GC[i].ACCON.ToString()) ? "" : List_GC[i].ACCON.ToString();
  17981. gc.TV = isEmpty(List_GC[i].TV.ToString()) ? "" : List_GC[i].TV.ToString();
  17982. gc.iL = isEmpty(List_GC[i].iL.ToString()) ? "" : List_GC[i].iL.ToString();
  17983. gc.IF = isEmpty(List_GC[i].IF.ToString()) ? "" : List_GC[i].IF.ToString();
  17984. gc.EF = isEmpty(List_GC[i].EF.ToString()) ? "" : List_GC[i].EF.ToString();
  17985. gc.B_R_F = isEmpty(List_GC[i].B_R_F.ToString()) ? "" : List_GC[i].B_R_F.ToString();
  17986. gc.TE = isEmpty(List_GC[i].TE.ToString()) ? "" : List_GC[i].TE.ToString();
  17987. gc.TGTips = isEmpty(List_GC[i].TGTips.ToString()) ? "" : List_GC[i].TGTips.ToString();
  17988. gc.DRVTips = isEmpty(List_GC[i].DRVTips.ToString()) ? "" : List_GC[i].DRVTips.ToString();
  17989. gc.PC = isEmpty(List_GC[i].PC.ToString()) ? "" : List_GC[i].PC.ToString();
  17990. gc.TLF = isEmpty(List_GC[i].TLF.ToString()) ? "" : List_GC[i].TLF.ToString();
  17991. gc.ECT = isEmpty(List_GC[i].ECT.ToString()) ? "" : List_GC[i].ECT.ToString();
  17992. gc.EFR = List_GC[i].EFR;
  17993. List_GC1.Add(gc);
  17994. }
  17995. if (List_GC1.Count > 0)
  17996. {
  17997. var p = List_GC1[0];
  17998. var prs = p.GetType().GetProperties();
  17999. foreach (var item in prs)
  18000. {
  18001. var tp = item.PropertyType;
  18002. if (tp == typeof(int))
  18003. {
  18004. var val = List_GC1.Sum(x => (int)x.GetType().GetProperty(item.Name).GetValue(x));
  18005. if (val == 0)
  18006. {
  18007. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  18008. if (columnSetting != null)
  18009. {
  18010. hideColumnList.Add(columnSetting.Index);
  18011. }
  18012. }
  18013. }
  18014. if (tp == typeof(decimal))
  18015. {
  18016. var val = List_GC1.Sum(x => (decimal)x.GetType().GetProperty(item.Name).GetValue(x));
  18017. if (val == 0)
  18018. {
  18019. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  18020. if (columnSetting != null)
  18021. {
  18022. hideColumnList.Add(columnSetting.Index);
  18023. }
  18024. }
  18025. }
  18026. if (tp == typeof(string))
  18027. {
  18028. var val = List_GC1.Sum(x =>
  18029. {
  18030. var str = (string)x.GetType().GetProperty(item.Name).GetValue(x);
  18031. if (decimal.TryParse(str, out decimal str_De))
  18032. {
  18033. return str_De;
  18034. }
  18035. else
  18036. {
  18037. return string.IsNullOrEmpty((string)x.GetType().GetProperty(item.Name).GetValue(x)) ? 0 : 1;
  18038. }
  18039. });
  18040. if (val == 0)
  18041. {
  18042. var columnSetting = ColumnSetting.FirstOrDefault(x => x.P == item.Name);
  18043. if (columnSetting != null)
  18044. {
  18045. hideColumnList.Add(columnSetting.Index);
  18046. }
  18047. }
  18048. }
  18049. }
  18050. }
  18051. var dt = CommonFun.GetDataTableFromIList(List_GC1);
  18052. dt.TableName = "TB";
  18053. //报表标题等不用dt的值
  18054. designer.SetDataSource("TeamName", dto.title.TeamName);
  18055. designer.SetDataSource("Pnumber", dto.title.GroupNumber);
  18056. designer.SetDataSource("Tax", dto.title.Tax);
  18057. //designer.SetDataSource("FFYS", lblHotelCB.Text);
  18058. designer.SetDataSource("Currency", dto.title.Currency);
  18059. //designer.SetDataSource("HotelXS", txtHotelXS.Text);
  18060. designer.SetDataSource("Rate", dto.title.Rate);
  18061. var hotels = _CostTypeHotelNumberRepository.GetCostTypeHotelNumberByDiid(dto.Diid);
  18062. var Aparams = hotels.Find(x => x.Type == "Default");
  18063. if (Aparams == null)
  18064. {
  18065. return Ok(jw);
  18066. }
  18067. //酒店数量
  18068. var txtSGRNumber = Aparams.SGR.ToString();
  18069. var txtTBRNumber = Aparams.TBR.ToString();
  18070. var txtJSESNumber = Aparams.JSES.ToString();
  18071. var txtSUITENumbe = Aparams.SUITE.ToString();
  18072. if (dto.costType == "B")
  18073. {
  18074. Aparams = hotels.Find(x => x.Type == "A");
  18075. var Bparams = hotels.Find(x => x.Type == "B");
  18076. if (Aparams == null || Bparams == null)
  18077. {
  18078. return Ok(jw);
  18079. }
  18080. txtSGRNumber = "A段人数:" + Aparams.SGR.ToString() + " B段人数:" + Bparams.SGR.ToString();
  18081. txtTBRNumber = "A段人数:" + Aparams.TBR.ToString() + " B段人数:" + Bparams.TBR.ToString();
  18082. txtJSESNumber = "A段人数:" + Aparams.JSES.ToString() + " B段人数:" + Bparams.JSES.ToString();
  18083. txtSUITENumbe = "A段人数:" + Aparams.SUITE.ToString() + " B段人数:" + Bparams.SUITE.ToString();
  18084. }
  18085. designer.SetDataSource("SGRNumber", txtSGRNumber);
  18086. designer.SetDataSource("TBRNumber", txtTBRNumber);
  18087. designer.SetDataSource("JSESNumber", txtJSESNumber);
  18088. designer.SetDataSource("SUITENumber", txtSUITENumbe);
  18089. var ws = designer.Workbook.Worksheets[1];
  18090. int Row = List_GC.Count;
  18091. int startIndex = 0;
  18092. int HideRows = 0;
  18093. Row = 0;
  18094. List<int> hideRowsList = new List<int>();
  18095. decimal TzZCB2 = 0.00M, TzZLR2 = 0.00M, TzZBJ2 = 0.00M;
  18096. #region A段left数据
  18097. var left = dto.leftInfo.Find(x => x.Type == "A");
  18098. if (left == null)
  18099. {
  18100. return Ok(jw);
  18101. }
  18102. var leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("签证"));
  18103. if (leftBindData != null)
  18104. {
  18105. designer.SetDataSource("VisaDRCB", leftBindData.cb);
  18106. designer.SetDataSource("VisaRS", leftBindData.rs);
  18107. designer.SetDataSource("VisaXS", leftBindData.xs);
  18108. designer.SetDataSource("VisaZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18109. designer.SetDataSource("VisaDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18110. designer.SetDataSource("VisaZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18111. designer.SetDataSource("VisaDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18112. designer.SetDataSource("VisaZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18113. }
  18114. else
  18115. {
  18116. hideRowsList.Add(Row + startIndex + HideRows);
  18117. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18118. }
  18119. HideRows += 2;
  18120. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("保险"));
  18121. if (leftBindData != null)
  18122. {
  18123. designer.SetDataSource("BXDRCB", leftBindData.cb);
  18124. designer.SetDataSource("BXRS", leftBindData.rs);
  18125. designer.SetDataSource("BXXS", leftBindData.xs);
  18126. designer.SetDataSource("BXZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18127. designer.SetDataSource("BXDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18128. designer.SetDataSource("BXZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18129. designer.SetDataSource("BXDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18130. designer.SetDataSource("BXZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18131. }
  18132. else
  18133. {
  18134. hideRowsList.Add(Row + startIndex + HideRows);
  18135. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18136. }
  18137. HideRows += 2;
  18138. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  18139. if (leftBindData != null)
  18140. {
  18141. designer.SetDataSource("HSDRCB", leftBindData.cb);
  18142. designer.SetDataSource("HSRS", leftBindData.rs);
  18143. designer.SetDataSource("HSXS", leftBindData.xs);
  18144. designer.SetDataSource("HSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18145. designer.SetDataSource("HSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18146. designer.SetDataSource("HSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18147. designer.SetDataSource("HSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18148. designer.SetDataSource("HSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18149. }
  18150. else
  18151. {
  18152. hideRowsList.Add(Row + startIndex + HideRows);
  18153. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18154. }
  18155. HideRows += 2;
  18156. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  18157. if (leftBindData != null)
  18158. {
  18159. designer.SetDataSource("JPJJCCB", leftBindData.cb);
  18160. designer.SetDataSource("JPJJCPnum", leftBindData.rs);
  18161. designer.SetDataSource("JPJJCXS", leftBindData.xs);
  18162. designer.SetDataSource("JPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18163. designer.SetDataSource("JPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18164. designer.SetDataSource("JPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18165. designer.SetDataSource("JPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18166. designer.SetDataSource("JPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18167. }
  18168. else
  18169. {
  18170. hideRowsList.Add(Row + startIndex + HideRows);
  18171. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18172. }
  18173. HideRows += 2;
  18174. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  18175. if (leftBindData != null)
  18176. {
  18177. designer.SetDataSource("JPGWCCB", leftBindData.cb);
  18178. designer.SetDataSource("JPGWCPNum", leftBindData.rs);
  18179. designer.SetDataSource("JPGWCXS", leftBindData.xs);
  18180. designer.SetDataSource("JPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18181. designer.SetDataSource("JPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18182. designer.SetDataSource("JPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18183. designer.SetDataSource("JPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18184. designer.SetDataSource("JPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18185. }
  18186. else
  18187. {
  18188. hideRowsList.Add(Row + startIndex + HideRows);
  18189. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18190. }
  18191. HideRows += 2;
  18192. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  18193. if (leftBindData != null)
  18194. {
  18195. designer.SetDataSource("JPTDCCB", leftBindData.cb);
  18196. designer.SetDataSource("JPTDCPNum", leftBindData.rs);
  18197. designer.SetDataSource("JPTDCXS", leftBindData.xs);
  18198. designer.SetDataSource("JPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18199. designer.SetDataSource("JPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18200. designer.SetDataSource("JPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18201. designer.SetDataSource("JPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18202. designer.SetDataSource("JPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18203. }
  18204. else
  18205. {
  18206. hideRowsList.Add(Row + startIndex + HideRows);
  18207. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18208. }
  18209. HideRows += 2;
  18210. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  18211. if (leftBindData != null)
  18212. {
  18213. ////TBR
  18214. designer.SetDataSource("HotelTBRDRCB", leftBindData.cb);
  18215. designer.SetDataSource("HotelTBRRS", leftBindData.rs);
  18216. designer.SetDataSource("HotelTBRXS", leftBindData.xs);
  18217. designer.SetDataSource("HotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18218. designer.SetDataSource("HotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18219. designer.SetDataSource("HotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18220. designer.SetDataSource("HotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18221. designer.SetDataSource("HotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18222. }
  18223. else
  18224. {
  18225. hideRowsList.Add(Row + startIndex + HideRows);
  18226. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18227. }
  18228. HideRows += 2;
  18229. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  18230. if (leftBindData != null)
  18231. {
  18232. ////SGR
  18233. designer.SetDataSource("HotelSGRDRCB", leftBindData.cb);
  18234. designer.SetDataSource("HotelSGRRS", leftBindData.rs);
  18235. designer.SetDataSource("HotelSGRXS", leftBindData.xs);
  18236. designer.SetDataSource("HotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18237. designer.SetDataSource("HotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18238. designer.SetDataSource("HotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18239. designer.SetDataSource("HotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18240. designer.SetDataSource("HotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18241. }
  18242. else
  18243. {
  18244. hideRowsList.Add(Row + startIndex + HideRows);
  18245. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18246. }
  18247. HideRows += 2;
  18248. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  18249. if (leftBindData != null)
  18250. {
  18251. ////JS/ES
  18252. designer.SetDataSource("HotelJSESDRCB", leftBindData.cb);
  18253. designer.SetDataSource("HotelJSESRS", leftBindData.rs);
  18254. designer.SetDataSource("HotelJSESXS", leftBindData.xs);
  18255. designer.SetDataSource("HotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18256. designer.SetDataSource("HotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18257. designer.SetDataSource("HotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18258. designer.SetDataSource("HotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18259. designer.SetDataSource("HotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18260. }
  18261. else
  18262. {
  18263. hideRowsList.Add(Row + startIndex + HideRows);
  18264. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18265. }
  18266. HideRows += 2;
  18267. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  18268. if (leftBindData != null)
  18269. {
  18270. ////SUITE
  18271. designer.SetDataSource("HotelSUITEDRCB", leftBindData.cb);
  18272. designer.SetDataSource("HotelSUITERS", leftBindData.rs);
  18273. designer.SetDataSource("HotelSUITEXS", leftBindData.xs);
  18274. designer.SetDataSource("HotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18275. designer.SetDataSource("HotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18276. designer.SetDataSource("HotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18277. designer.SetDataSource("HotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18278. designer.SetDataSource("HotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18279. }
  18280. else
  18281. {
  18282. hideRowsList.Add(Row + startIndex + HideRows);
  18283. // ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18284. }
  18285. HideRows += 2;
  18286. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  18287. if (leftBindData != null)
  18288. {
  18289. designer.SetDataSource("DJDRCB", leftBindData.cb);
  18290. designer.SetDataSource("DJRS", leftBindData.rs);
  18291. designer.SetDataSource("DJXS", leftBindData.xs);
  18292. designer.SetDataSource("DJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18293. designer.SetDataSource("DJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18294. designer.SetDataSource("DJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18295. designer.SetDataSource("DJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18296. designer.SetDataSource("DJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18297. }
  18298. else
  18299. {
  18300. hideRowsList.Add(Row + startIndex + HideRows);
  18301. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18302. }
  18303. HideRows += 2;
  18304. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  18305. if (leftBindData != null)
  18306. {
  18307. designer.SetDataSource("HCPCB", leftBindData.cb);
  18308. designer.SetDataSource("HCPRS", leftBindData.rs);
  18309. designer.SetDataSource("HCPXS", leftBindData.xs);
  18310. designer.SetDataSource("HCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18311. designer.SetDataSource("HCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18312. designer.SetDataSource("HCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18313. designer.SetDataSource("HCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18314. designer.SetDataSource("HCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18315. }
  18316. else
  18317. {
  18318. hideRowsList.Add(Row + startIndex + HideRows);
  18319. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18320. }
  18321. HideRows += 2;
  18322. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  18323. if (leftBindData != null)
  18324. {
  18325. designer.SetDataSource("CPCB", leftBindData.cb);
  18326. designer.SetDataSource("CPRS", leftBindData.rs);
  18327. designer.SetDataSource("CPXS", leftBindData.xs);
  18328. designer.SetDataSource("CPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18329. designer.SetDataSource("CPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18330. designer.SetDataSource("CPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18331. designer.SetDataSource("CPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18332. designer.SetDataSource("CPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18333. }
  18334. else
  18335. {
  18336. hideRowsList.Add(Row + startIndex + HideRows);
  18337. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18338. }
  18339. HideRows += 2;
  18340. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  18341. if (leftBindData != null)
  18342. {
  18343. designer.SetDataSource("GWDRCD", leftBindData.cb);
  18344. designer.SetDataSource("GWRS", leftBindData.rs);
  18345. designer.SetDataSource("GWXS", leftBindData.xs);
  18346. designer.SetDataSource("GWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18347. designer.SetDataSource("GWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18348. designer.SetDataSource("GWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18349. designer.SetDataSource("GWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18350. designer.SetDataSource("GWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18351. }
  18352. else
  18353. {
  18354. hideRowsList.Add(Row + startIndex + HideRows);
  18355. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18356. }
  18357. HideRows += 2;
  18358. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  18359. if (leftBindData != null)
  18360. {
  18361. designer.SetDataSource("LYJDRCB", leftBindData.cb);
  18362. designer.SetDataSource("LYJRS", leftBindData.rs);
  18363. designer.SetDataSource("LYJXS", leftBindData.xs);
  18364. designer.SetDataSource("LYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18365. designer.SetDataSource("LYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18366. designer.SetDataSource("LYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18367. designer.SetDataSource("LYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18368. designer.SetDataSource("LYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18369. }
  18370. else
  18371. {
  18372. hideRowsList.Add(Row + startIndex + HideRows);
  18373. //ws.Cells.HideRows((Row + startIndex + HideRows), 2);
  18374. }
  18375. #endregion
  18376. #region A段Right信息
  18377. var right = dto.rightInfo.Find(x => x.Type == "A");
  18378. if (right == null)
  18379. {
  18380. return Ok(jw);
  18381. }
  18382. HideRows += 4;
  18383. var rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  18384. if (rightBindData != null)
  18385. {
  18386. //经济舱 + 双人间 TBR
  18387. designer.SetDataSource("lblJJCTBRDRCB", rightBindData.cb);
  18388. designer.SetDataSource("txtJJCTBRRS", rightBindData.rs);
  18389. designer.SetDataSource("lblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18390. designer.SetDataSource("lblJJCTBRDRBJ", rightBindData.bj);
  18391. designer.SetDataSource("lblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18392. designer.SetDataSource("lblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18393. designer.SetDataSource("lblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18394. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18395. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18396. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18397. }
  18398. else
  18399. {
  18400. hideRowsList.Add(Row + startIndex + HideRows);
  18401. }
  18402. HideRows += 2;
  18403. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  18404. if (rightBindData != null)
  18405. {
  18406. //经济舱 + 单人间 SGR
  18407. designer.SetDataSource("lblJJCSGRDRCB", rightBindData.cb);
  18408. designer.SetDataSource("txtJJCSGRRS", rightBindData.rs);
  18409. designer.SetDataSource("lblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18410. designer.SetDataSource("lblJJCSGRDRBJ", rightBindData.bj);
  18411. designer.SetDataSource("lblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18412. designer.SetDataSource("lblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18413. designer.SetDataSource("lblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18414. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18415. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18416. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18417. }
  18418. else
  18419. {
  18420. hideRowsList.Add(Row + startIndex + HideRows);
  18421. }
  18422. HideRows += 2;
  18423. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  18424. if (rightBindData != null)
  18425. {
  18426. //公务舱 + 单人间 SGR
  18427. designer.SetDataSource("lblGWCSGRCB", rightBindData.cb);
  18428. designer.SetDataSource("lblGWCSGRRS", rightBindData.rs);
  18429. designer.SetDataSource("lblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18430. designer.SetDataSource("lblGWCSGRDRBJ", rightBindData.bj);
  18431. designer.SetDataSource("lblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18432. designer.SetDataSource("lblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18433. designer.SetDataSource("lblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18434. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18435. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18436. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18437. }
  18438. else
  18439. {
  18440. hideRowsList.Add(Row + startIndex + HideRows);
  18441. }
  18442. HideRows += 2;
  18443. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  18444. if (rightBindData != null)
  18445. {
  18446. //公务舱 + 小套房 JSES
  18447. designer.SetDataSource("lblGWCJSESDRCB", rightBindData.cb);
  18448. designer.SetDataSource("txtGWCJSESRS", rightBindData.rs);
  18449. designer.SetDataSource("lblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18450. designer.SetDataSource("lblGWCJSESDRBJ", rightBindData.bj);
  18451. designer.SetDataSource("lblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18452. designer.SetDataSource("lblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18453. designer.SetDataSource("lblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18454. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18455. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18456. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18457. }
  18458. else
  18459. {
  18460. hideRowsList.Add(Row + startIndex + HideRows);
  18461. }
  18462. HideRows += 2;
  18463. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  18464. if (rightBindData != null)
  18465. {
  18466. //公务舱 + 小套房 JSES
  18467. designer.SetDataSource("lblGWCSUITEDRCB", rightBindData.cb);
  18468. designer.SetDataSource("txtGWCSUITERS", rightBindData.rs);
  18469. designer.SetDataSource("lblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18470. designer.SetDataSource("lblGWCSUITEDRBJ", rightBindData.bj);
  18471. designer.SetDataSource("lblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18472. designer.SetDataSource("lblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18473. designer.SetDataSource("lblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18474. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18475. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18476. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18477. }
  18478. else
  18479. {
  18480. hideRowsList.Add(Row + startIndex + HideRows);
  18481. }
  18482. HideRows += 2;
  18483. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  18484. if (rightBindData != null)
  18485. {
  18486. //经济舱 + 大套房
  18487. designer.SetDataSource("lblJJCSUITEDRCB", rightBindData.cb);
  18488. designer.SetDataSource("txtJJCSUITERS", rightBindData.rs);
  18489. designer.SetDataSource("lblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18490. designer.SetDataSource("lblJJCSUITEDRBJ", rightBindData.bj);
  18491. designer.SetDataSource("lblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18492. designer.SetDataSource("lblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18493. designer.SetDataSource("lblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18494. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18495. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18496. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18497. }
  18498. else
  18499. {
  18500. hideRowsList.Add(Row + startIndex + HideRows);
  18501. }
  18502. HideRows += 2;
  18503. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  18504. if (rightBindData != null)
  18505. {
  18506. //头等舱 + 小套房 JSES
  18507. designer.SetDataSource("lblTDCJSESDRCB", rightBindData.cb);
  18508. designer.SetDataSource("txtTDCJSESRS", rightBindData.rs);
  18509. designer.SetDataSource("lblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18510. designer.SetDataSource("lblTDCJSESDRBJ", rightBindData.bj);
  18511. designer.SetDataSource("lblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18512. designer.SetDataSource("lblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18513. designer.SetDataSource("lblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18514. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18515. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18516. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18517. }
  18518. else
  18519. {
  18520. hideRowsList.Add(Row + startIndex + HideRows);
  18521. }
  18522. HideRows += 2;
  18523. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  18524. if (rightBindData != null)
  18525. {
  18526. //头等舱 + 大套房
  18527. designer.SetDataSource("lblTDCSUITEDRCB", rightBindData.cb);
  18528. designer.SetDataSource("txtTDCSUITERS", rightBindData.rs);
  18529. designer.SetDataSource("lblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18530. designer.SetDataSource("lblTDCSUITEDRBJ", rightBindData.bj);
  18531. designer.SetDataSource("lblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18532. designer.SetDataSource("lblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18533. designer.SetDataSource("lblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18534. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18535. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18536. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18537. }
  18538. else
  18539. {
  18540. hideRowsList.Add(Row + startIndex + HideRows);
  18541. }
  18542. #endregion
  18543. #region B段标题清空
  18544. designer.SetDataSource("CostBDRCB", "");
  18545. designer.SetDataSource("CostBRS", "");
  18546. designer.SetDataSource("CostBXS", "");
  18547. designer.SetDataSource("CostBZCB", "");
  18548. designer.SetDataSource("CostBDRBJ", "");
  18549. designer.SetDataSource("CostBZBJ", "");
  18550. designer.SetDataSource("CostBDRLR", "");
  18551. designer.SetDataSource("CostBZLR", "");
  18552. designer.SetDataSource("CostBDRCBOM", "");
  18553. designer.SetDataSource("CostBRSOM", "");
  18554. designer.SetDataSource("CostBZCBOM", "");
  18555. designer.SetDataSource("CostBDRBJOM", "");
  18556. designer.SetDataSource("CostBZBJOM", "");
  18557. designer.SetDataSource("CostBDRLROM", "");
  18558. designer.SetDataSource("CostBZLROM", "");
  18559. #endregion
  18560. designer.SetDataSource("HotelTBRName", "酒店TBR单间成本(CNY)");
  18561. designer.SetDataSource("HotelSGRName", "酒店SGR单间成本(CNY)");
  18562. designer.SetDataSource("HotelJSESName", "酒店JSES单间成本(CNY)");
  18563. designer.SetDataSource("HotelSUITEName", "酒店SUITE单间成本(CNY)");
  18564. designer.SetDataSource("DJName", "地接(CNY)");
  18565. designer.SetDataSource("HCPName", "地接-火车票(CNY)");
  18566. designer.SetDataSource("CPName", "地接-船票(CNY)");
  18567. designer.SetDataSource("GWName", "公务(CNY)");
  18568. designer.SetDataSource("YQHName", "邀请函(CNY)");
  18569. designer.SetDataSource("LYJName", "零用金(CNY)");
  18570. designer.SetDataSource("HSName", "核酸检测(CNY)");
  18571. designer.SetDataSource("AirGWCName", "机票-公务舱(CNY)");
  18572. designer.SetDataSource("AirJJCName", "机票-经济舱(CNY)");
  18573. designer.SetDataSource("AirTDCName", "机票-头等舱(CNY)");
  18574. designer.SetDataSource("BXName", "保险(CNY)");
  18575. designer.SetDataSource("VisaName", "签证(CNY)");
  18576. #region B段基本数据
  18577. if (dto.costType == "B")
  18578. {
  18579. left = dto.leftInfo.Find(x => x.Type == "B");
  18580. if (left == null)
  18581. {
  18582. return Ok(jw);
  18583. }
  18584. #region B段left数据
  18585. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("核酸"));
  18586. if (leftBindData != null)
  18587. {
  18588. designer.SetDataSource("BHSDRCB", leftBindData.cb);
  18589. designer.SetDataSource("BHSRS", leftBindData.rs);
  18590. designer.SetDataSource("BHSXS", leftBindData.xs);
  18591. designer.SetDataSource("BHSZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18592. designer.SetDataSource("BHSDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18593. designer.SetDataSource("BHSZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18594. designer.SetDataSource("BHSDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18595. designer.SetDataSource("BHSZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18596. }
  18597. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("经济舱"));
  18598. if (leftBindData != null)
  18599. {
  18600. designer.SetDataSource("BJPJJCCB", leftBindData.cb);
  18601. designer.SetDataSource("BJPJJCPnum", leftBindData.rs);
  18602. designer.SetDataSource("BJPJJCXS", leftBindData.xs);
  18603. designer.SetDataSource("BJPJJCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18604. designer.SetDataSource("BJPJJCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18605. designer.SetDataSource("BJPJJCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18606. designer.SetDataSource("BJPJJCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18607. designer.SetDataSource("BJPJJCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18608. }
  18609. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务舱"));
  18610. if (leftBindData != null)
  18611. {
  18612. designer.SetDataSource("BJPGWCCB", leftBindData.cb);
  18613. designer.SetDataSource("BJPGWCPNum", leftBindData.rs);
  18614. designer.SetDataSource("BJPGWCXS", leftBindData.xs);
  18615. designer.SetDataSource("BJPGWCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18616. designer.SetDataSource("BJPGWCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18617. designer.SetDataSource("BJPGWCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18618. designer.SetDataSource("BJPGWCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18619. designer.SetDataSource("BJPGWCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18620. }
  18621. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("头等舱"));
  18622. if (leftBindData != null)
  18623. {
  18624. designer.SetDataSource("BJPTDCCB", leftBindData.cb);
  18625. designer.SetDataSource("BJPTDCPNum", leftBindData.rs);
  18626. designer.SetDataSource("BJPTDCXS", leftBindData.xs);
  18627. designer.SetDataSource("BJPTDCZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18628. designer.SetDataSource("BJPTDCDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18629. designer.SetDataSource("BJPTDCZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18630. designer.SetDataSource("BJPTDCDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18631. designer.SetDataSource("BJPTDCZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18632. }
  18633. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("火车票"));
  18634. if (leftBindData != null)
  18635. {
  18636. designer.SetDataSource("BHCPCB", leftBindData.cb);
  18637. designer.SetDataSource("BHCPRS", leftBindData.rs);
  18638. designer.SetDataSource("BHCPXS", leftBindData.xs);
  18639. designer.SetDataSource("BHCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18640. designer.SetDataSource("BHCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18641. designer.SetDataSource("BHCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18642. designer.SetDataSource("BHCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18643. designer.SetDataSource("BHCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18644. }
  18645. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("船票"));
  18646. if (leftBindData != null)
  18647. {
  18648. designer.SetDataSource("BCPCB", leftBindData.cb);
  18649. designer.SetDataSource("BCPRS", leftBindData.rs);
  18650. designer.SetDataSource("BCPXS", leftBindData.xs);
  18651. designer.SetDataSource("BCPZCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18652. designer.SetDataSource("BCPDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18653. designer.SetDataSource("BCPZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18654. designer.SetDataSource("BCPDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18655. designer.SetDataSource("BCPZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18656. }
  18657. //TBR
  18658. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("TBR"));
  18659. if (leftBindData != null)
  18660. {
  18661. designer.SetDataSource("BHotelTBRDRCB", leftBindData.cb);
  18662. designer.SetDataSource("BHotelTBRRS", leftBindData.rs);
  18663. designer.SetDataSource("BHotelTBRXS", leftBindData.xs);
  18664. designer.SetDataSource("BHotelTBRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18665. designer.SetDataSource("BHotelTBRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18666. designer.SetDataSource("BHotelTBRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18667. designer.SetDataSource("BHotelTBRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18668. designer.SetDataSource("BHotelTBRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18669. }
  18670. //SGR
  18671. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SGR"));
  18672. if (leftBindData != null)
  18673. {
  18674. designer.SetDataSource("BHotelSGRDRCB", leftBindData.cb);
  18675. designer.SetDataSource("BHotelSGRRS", leftBindData.rs);
  18676. designer.SetDataSource("BHotelSGRXS", leftBindData.xs);
  18677. designer.SetDataSource("BHotelSGRCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18678. designer.SetDataSource("BHotelSGRDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18679. designer.SetDataSource("BHotelSGRZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18680. designer.SetDataSource("BHotelSGRDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18681. designer.SetDataSource("BHotelSGRZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18682. }
  18683. //JS/ES
  18684. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("JSES"));
  18685. if (leftBindData != null)
  18686. {
  18687. designer.SetDataSource("BHotelJSESDRCB", leftBindData.cb);
  18688. designer.SetDataSource("BHotelJSESRS", leftBindData.rs);
  18689. designer.SetDataSource("BHotelJSESXS", leftBindData.xs);
  18690. designer.SetDataSource("BHotelJSESCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18691. designer.SetDataSource("BHotelJSESDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18692. designer.SetDataSource("BHotelJSESZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18693. designer.SetDataSource("BHotelJSESDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18694. designer.SetDataSource("BHotelJSESZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18695. }
  18696. //SUITE
  18697. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("SUITE"));
  18698. if (leftBindData != null)
  18699. {
  18700. designer.SetDataSource("BHotelSUITEDRCB", leftBindData.cb);
  18701. designer.SetDataSource("BHotelSUITERS", leftBindData.rs);
  18702. designer.SetDataSource("BHotelSUITEXS", leftBindData.xs);
  18703. designer.SetDataSource("BHotelSUITECB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18704. designer.SetDataSource("BHotelSUITEDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18705. designer.SetDataSource("BHotelSUITEZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18706. designer.SetDataSource("BHotelSUITEDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18707. designer.SetDataSource("BHotelSUITEZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18708. }
  18709. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("地接"));
  18710. if (leftBindData != null)
  18711. {
  18712. designer.SetDataSource("BDJDRCB", leftBindData.cb);
  18713. designer.SetDataSource("BDJRS", leftBindData.rs);
  18714. designer.SetDataSource("BDJXS", leftBindData.xs);
  18715. designer.SetDataSource("BDJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18716. designer.SetDataSource("BDJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18717. designer.SetDataSource("BDJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18718. designer.SetDataSource("BDJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18719. designer.SetDataSource("BDJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18720. }
  18721. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("公务单人"));
  18722. if (leftBindData != null)
  18723. {
  18724. designer.SetDataSource("BGWDRCD", leftBindData.cb);
  18725. designer.SetDataSource("BGWRS", leftBindData.rs);
  18726. designer.SetDataSource("BGWXS", leftBindData.xs);
  18727. designer.SetDataSource("BGWCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18728. designer.SetDataSource("BGWDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18729. designer.SetDataSource("BGWZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18730. designer.SetDataSource("BGWDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18731. designer.SetDataSource("BGWZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18732. }
  18733. #region 优化方案
  18734. //Dictionary<string, object> excelBind = new Dictionary<string, object>();
  18735. //excelBind.Add("零用金", new {
  18736. //cb="",
  18737. //rs="",
  18738. //xs ="",
  18739. //zcb = "",
  18740. //});
  18741. #endregion
  18742. leftBindData = left.leftinfoNumber.Find(x => x.title.Contains("零用金"));
  18743. if (leftBindData != null)
  18744. {
  18745. designer.SetDataSource("BLYJDRCB", leftBindData.cb);
  18746. designer.SetDataSource("BLYJRS", leftBindData.rs);
  18747. designer.SetDataSource("BLYJXS", leftBindData.xs);
  18748. designer.SetDataSource("BLYJCB", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.rs));
  18749. designer.SetDataSource("BLYJDRBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs));
  18750. designer.SetDataSource("BLYJZBJ", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) * decimal.Parse(leftBindData.rs));
  18751. designer.SetDataSource("BLYJDRLR", decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs) - decimal.Parse(leftBindData.cb));
  18752. designer.SetDataSource("BLYJZLR", ((decimal.Parse(leftBindData.cb) * decimal.Parse(leftBindData.xs)) - decimal.Parse(leftBindData.cb)) * decimal.Parse(leftBindData.rs));
  18753. }
  18754. #endregion
  18755. #region B段Right信息
  18756. right = dto.rightInfo.Find(x => x.Type == "B");
  18757. if (right == null)
  18758. {
  18759. return Ok(jw);
  18760. }
  18761. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 TBR"));
  18762. if (rightBindData != null)
  18763. {
  18764. //经济舱 + 双人间 TBR
  18765. designer.SetDataSource("BlblJJCTBRDRCB", rightBindData.cb);
  18766. designer.SetDataSource("BtxtJJCTBRRS", rightBindData.rs);
  18767. designer.SetDataSource("BlblJJCTBRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18768. designer.SetDataSource("BlblJJCTBRDRBJ", rightBindData.bj);
  18769. designer.SetDataSource("BlblJJCTBRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18770. designer.SetDataSource("BlblJJCTBRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18771. designer.SetDataSource("BlblJJCTBRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18772. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18773. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18774. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18775. }
  18776. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SGR"));
  18777. if (rightBindData != null)
  18778. {
  18779. //经济舱 + 单人间 SGR
  18780. designer.SetDataSource("BlblJJCSGRDRCB", rightBindData.cb);
  18781. designer.SetDataSource("BtxtJJCSGRRS", rightBindData.rs);
  18782. designer.SetDataSource("BlblJJCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18783. designer.SetDataSource("BlblJJCSGRDRBJ", rightBindData.bj);
  18784. designer.SetDataSource("BlblJJCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18785. designer.SetDataSource("BlblJJCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18786. designer.SetDataSource("BlblJJCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18787. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18788. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18789. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18790. }
  18791. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SGR"));
  18792. if (rightBindData != null)
  18793. {
  18794. //公务舱 + 单人间 SGR
  18795. designer.SetDataSource("BlblGWCSGRCB", rightBindData.cb);
  18796. designer.SetDataSource("BlblGWCSGRRS", rightBindData.rs);
  18797. designer.SetDataSource("BlblGWCSGRZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18798. designer.SetDataSource("BlblGWCSGRDRBJ", rightBindData.bj);
  18799. designer.SetDataSource("BlblGWCSGRZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18800. designer.SetDataSource("BlblGWCSGRDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18801. designer.SetDataSource("BlblGWCSGRZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18802. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18803. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18804. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18805. }
  18806. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 JS/ES"));
  18807. if (rightBindData != null)
  18808. {
  18809. //公务舱 + 小套房 JSES
  18810. designer.SetDataSource("BlblGWCJSESDRCB", rightBindData.cb);
  18811. designer.SetDataSource("BtxtGWCJSESRS", rightBindData.rs);
  18812. designer.SetDataSource("BlblGWCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18813. designer.SetDataSource("BlblGWCJSESDRBJ", rightBindData.bj);
  18814. designer.SetDataSource("BlblGWCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18815. designer.SetDataSource("BlblGWCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18816. designer.SetDataSource("BlblGWCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18817. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18818. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18819. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18820. }
  18821. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("公务舱 SUITE"));
  18822. if (rightBindData != null)
  18823. {
  18824. //公务舱 + 小套房 JSES
  18825. designer.SetDataSource("BlblGWCSUITEDRCB", rightBindData.cb);
  18826. designer.SetDataSource("BtxtGWCSUITERS", rightBindData.rs);
  18827. designer.SetDataSource("BlblGWCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18828. designer.SetDataSource("BlblGWCSUITEDRBJ", rightBindData.bj);
  18829. designer.SetDataSource("BlblGWCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18830. designer.SetDataSource("BlblGWCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18831. designer.SetDataSource("BlblGWCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18832. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18833. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18834. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18835. }
  18836. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("经济舱 SUITE"));
  18837. if (rightBindData != null)
  18838. {
  18839. //经济舱 + 大套房
  18840. designer.SetDataSource("BlblJJCSUITEDRCB", rightBindData.cb);
  18841. designer.SetDataSource("BtxtJJCSUITERS", rightBindData.rs);
  18842. designer.SetDataSource("BlblJJCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18843. designer.SetDataSource("BlblJJCSUITEDRBJ", rightBindData.bj);
  18844. designer.SetDataSource("BlblJJCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18845. designer.SetDataSource("BlblJJCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18846. designer.SetDataSource("BlblJJCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18847. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18848. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18849. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18850. }
  18851. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 JS/ES"));
  18852. if (rightBindData != null)
  18853. {
  18854. //头等舱 + 小套房 JSES
  18855. designer.SetDataSource("BlblTDCJSESDRCB", rightBindData.cb);
  18856. designer.SetDataSource("BtxtTDCJSESRS", rightBindData.rs);
  18857. designer.SetDataSource("BlblTDCJSESZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18858. designer.SetDataSource("BlblTDCJSESDRBJ", rightBindData.bj);
  18859. designer.SetDataSource("BlblTDCJSESZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18860. designer.SetDataSource("BlblTDCJSESDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18861. designer.SetDataSource("BlblTDCJSESZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18862. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18863. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18864. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18865. }
  18866. rightBindData = right.rightInfoNumber.Find(x => x.title.Contains("头等舱 SUITE"));
  18867. if (rightBindData != null)
  18868. {
  18869. //头等舱 + 大套房
  18870. designer.SetDataSource("BlblTDCSUITEDRCB", rightBindData.cb);
  18871. designer.SetDataSource("BtxtTDCSUITERS", rightBindData.rs);
  18872. designer.SetDataSource("BlblTDCSUITEZCB", decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs));
  18873. designer.SetDataSource("BlblTDCSUITEDRBJ", rightBindData.bj);
  18874. designer.SetDataSource("BlblTDCSUITEZBJ", decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs));
  18875. designer.SetDataSource("BlblTDCSUITEDRLR", decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb));
  18876. designer.SetDataSource("BlblTDCSUITEZLR", (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs));
  18877. TzZCB2 += decimal.Parse(rightBindData.cb) * decimal.Parse(rightBindData.rs);
  18878. TzZLR2 += (decimal.Parse(rightBindData.bj) - decimal.Parse(rightBindData.cb)) * decimal.Parse(rightBindData.rs);
  18879. TzZBJ2 += decimal.Parse(rightBindData.bj) * decimal.Parse(rightBindData.rs);
  18880. }
  18881. #endregion
  18882. #region 标题
  18883. designer.SetDataSource("CostBDRCB", "单人成本");
  18884. designer.SetDataSource("CostBRS", "人数");
  18885. designer.SetDataSource("CostBXS", "系数");
  18886. designer.SetDataSource("CostBZCB", "总成本");
  18887. designer.SetDataSource("CostBDRBJ", "单人报价");
  18888. designer.SetDataSource("CostBZBJ", "总报价");
  18889. designer.SetDataSource("CostBDRLR", "单人利润");
  18890. designer.SetDataSource("CostBZLR", "总利润");
  18891. designer.SetDataSource("CostBDRCBOM", "单人成本");
  18892. designer.SetDataSource("CostBRSOM", "人数");
  18893. designer.SetDataSource("CostBZCBOM", "总成本");
  18894. designer.SetDataSource("CostBDRBJOM", "单人报价");
  18895. designer.SetDataSource("CostBZBJOM", "总报价");
  18896. designer.SetDataSource("CostBDRLROM", "单人利润");
  18897. designer.SetDataSource("CostBZLROM", "总利润");
  18898. #endregion
  18899. }
  18900. #endregion
  18901. designer.SetDataSource("TzZCB2", TzZCB2);
  18902. designer.SetDataSource("TzZBJ2", TzZBJ2);
  18903. designer.SetDataSource("TzZLR2", TzZLR2);
  18904. string[] dataSourceKeys = new string[]
  18905. {
  18906. "VF",
  18907. "TGS",
  18908. "TGOF",
  18909. "TGM",
  18910. "TGA",
  18911. "TGTF",
  18912. "TGEF",
  18913. "CFM",
  18914. "CFOF",
  18915. "B",
  18916. "L",
  18917. "D",
  18918. "TBR",
  18919. "SGR",
  18920. "JSES",
  18921. "Suite",
  18922. "TV",
  18923. "1L",
  18924. "IF",
  18925. "EF",
  18926. "BRF",
  18927. "TE",
  18928. "TGT",
  18929. "DRVT",
  18930. "PC",
  18931. "TLF",
  18932. "ECT"
  18933. };
  18934. foreach (var item in dataSourceKeys)
  18935. {
  18936. Func<TitleModel, bool> expr = x => x.label.Replace(" ", "").Replace("/", "") == item
  18937. || x.label.Replace(" ", "").Replace("/", "").ToUpper() == item.ToUpper();
  18938. var find = dto.titleModel.FirstOrDefault(expr);
  18939. if (find != null)
  18940. {
  18941. designer.SetDataSource(item, find.text);
  18942. }
  18943. else
  18944. {
  18945. designer.SetDataSource(item, 0);
  18946. }
  18947. }
  18948. designer.SetDataSource(dt);
  18949. //根据数据源处理生成报表内容
  18950. designer.Process();
  18951. designer.Workbook.Worksheets[0].Name = "费用明细";
  18952. designer.Workbook.Worksheets[1].Name = "费用总核算";
  18953. Worksheet sheet = designer.Workbook.Worksheets[0];
  18954. #region 隐藏舱位
  18955. var settingAir = new[]
  18956. {
  18957. new { key = "经济舱", index = 7 },
  18958. new { key = "公务舱", index = 19 },
  18959. new { key = "头等舱", index = 11 }
  18960. };
  18961. var airType = _sqlSugar.Queryable<Grp_TourClientList>()
  18962. .LeftJoin<Sys_SetData>((c, s) => s.IsDel == 0 && c.ShippingSpaceTypeId == s.Id)
  18963. .Where((c, s) => c.IsDel == 0 && c.DiId == di.Id)
  18964. .Select((c, s) => s.Name)
  18965. .ToList()
  18966. .GroupBy(x => x)
  18967. .Select(x => x.Key);
  18968. foreach (var item in settingAir)
  18969. {
  18970. if (!airType.Contains(item.key))
  18971. {
  18972. hideRowsList.Add(item.index);
  18973. }
  18974. }
  18975. #endregion
  18976. foreach (var Rowindex in hideRowsList)
  18977. {
  18978. ws.Cells.HideRows(Rowindex, 2);
  18979. }
  18980. ws = designer.Workbook.Worksheets[0];
  18981. foreach (var Column in hideColumnList)
  18982. {
  18983. ws.Cells.HideColumns(Column, 1);
  18984. }
  18985. byte[] bytes = null;
  18986. string strFileName = di.TeamName + "-团组-成本.xls";
  18987. using (MemoryStream stream = new MemoryStream())
  18988. {
  18989. designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  18990. bytes = stream.ToArray();
  18991. }
  18992. return Ok(JsonView(true, "", new
  18993. {
  18994. Data = bytes,
  18995. strFileName,
  18996. }));
  18997. }
  18998. /// <summary>
  18999. /// 导出客户报表
  19000. /// </summary>
  19001. /// <returns></returns>
  19002. [HttpPost]
  19003. public async Task<IActionResult> ExportClientWordFile(ExportClientWordFileDto dto)
  19004. {
  19005. var jw = JsonView(false);
  19006. if (dto.Diid == 0)
  19007. {
  19008. return Ok(JsonView(false, "请传递团组id"));
  19009. }
  19010. var deleInfo = await _groupRepository.PostGroupInfo(new GroupInfoDto { Id = dto.Diid, PortType = 1 });
  19011. if (deleInfo.Code != 0)
  19012. {
  19013. return Ok(JsonView(false, "团组信息查询失败!"));
  19014. }
  19015. var di = deleInfo.Data as DelegationInfoWebView;
  19016. if (di == null)
  19017. {
  19018. return Ok(JsonView(false, "团组信息查询失败!"));
  19019. }
  19020. //文件名
  19021. //string strFileName = di.TeamName + "-团组-客户报价.doc";
  19022. //获取模板
  19023. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/团组-客户报价.doc");
  19024. //载入模板
  19025. Document doc = new Document(tmppath);
  19026. Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
  19027. Dictionary<string, string> DickeyValue = new Dictionary<string, string>();
  19028. DickeyValue.Add("DickeyValue", di.TeamName); //团组名
  19029. var ParameterList = _GroupCostParameterRepository.GetGroupCostParameterListByDiid(dto.Diid);
  19030. var AParameter = ParameterList.Find(x => x.CostType == "A");
  19031. var BParameter = ParameterList.Find(x => x.CostType == "B");
  19032. if (AParameter == null)
  19033. {
  19034. return Ok(JsonView(false, "系数不存在!"));
  19035. }
  19036. string CarGuides, TzNumber, CarGuides1, Meal, SubsidizedMeals, NightRepair, AttractionsTickets, MiscellaneousFees, ATip, TzHotelDesc, Offcial, PettyCash, Visa, TrainTicket, TicketPrice
  19037. , TzAirDesc, TzZCost;
  19038. CarGuides = TzNumber = CarGuides1 = Meal = SubsidizedMeals = NightRepair = AttractionsTickets = MiscellaneousFees = ATip = TzHotelDesc = Offcial = PettyCash = Visa = TrainTicket = TicketPrice
  19039. = TzAirDesc = TzZCost = string.Empty;
  19040. TzNumber = AParameter.CostTypenumber.ToString();
  19041. CarGuides = "RMB " + (AParameter.DJCB * AParameter.DJXS).ToString("#0.00");
  19042. CarGuides1 = dto.CarGuides1;
  19043. Meal = dto.Meal;
  19044. SubsidizedMeals = dto.SubsidizedMeals;
  19045. NightRepair = dto.NightRepair;
  19046. AttractionsTickets = dto.AttractionsTickets;
  19047. MiscellaneousFees = dto.MiscellaneousFees;
  19048. ATip = dto.ATip;
  19049. TzHotelDesc = "";
  19050. Offcial = "RMB " + (AParameter.GWCB * AParameter.GWXS).ToString("#0.00");
  19051. PettyCash = "RMB " + (AParameter.LYJCB * AParameter.LYJXS).ToString("#0.00");
  19052. Visa = "RMB " + (AParameter.VisaCB * AParameter.VisaXS + AParameter.HSCB * AParameter.HSXS + AParameter.BXCB * AParameter.BXXS).ToString("#0.00");
  19053. TrainTicket = "RMB " + (AParameter.HCPCB * AParameter.HCPXS).ToString("#0.00");
  19054. TicketPrice = "RMB " + (AParameter.CPCB * AParameter.CPXS).ToString("#0.00");
  19055. TzAirDesc = "";
  19056. TzZCost = dto.TzZCost;
  19057. var TzHotelDescArr = new string[] { "SGR", "JSES", "SUITE", "TBR" };
  19058. var TzAirDescArr = new string[] { "经济舱", "公务舱" };
  19059. var index = 1;
  19060. var AinfoArr = dto.leftInfo.Find(x => x.Type == "A");
  19061. foreach (var item in TzHotelDescArr)
  19062. {
  19063. if (AinfoArr != null)
  19064. {
  19065. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19066. if (Ainfo != null)
  19067. {
  19068. if (int.Parse(Ainfo.rs) <= 0)
  19069. {
  19070. continue;
  19071. }
  19072. var hotelText = string.Empty;
  19073. switch (item)
  19074. {
  19075. case "SGR":
  19076. hotelText = "单人间";
  19077. break;
  19078. case "JSES":
  19079. hotelText = "小套房";
  19080. break;
  19081. case "SUITE":
  19082. hotelText = "套房";
  19083. break;
  19084. case "TBR":
  19085. hotelText = "双人间";
  19086. break;
  19087. }
  19088. if (item != "TBR")
  19089. {
  19090. 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";
  19091. }
  19092. else
  19093. {
  19094. 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";
  19095. }
  19096. index++;
  19097. }
  19098. }
  19099. }
  19100. index = 1;
  19101. foreach (var item in TzAirDescArr)
  19102. {
  19103. if (AinfoArr != null)
  19104. {
  19105. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19106. if (Ainfo != null)
  19107. {
  19108. if (int.Parse(Ainfo.rs) <= 0)
  19109. {
  19110. continue;
  19111. }
  19112. 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";
  19113. index++;
  19114. }
  19115. }
  19116. }
  19117. if (dto.costType == "B")
  19118. {
  19119. if (BParameter == null)
  19120. {
  19121. return Ok(JsonView(false, "B段系数不存在!"));
  19122. }
  19123. CarGuides = CarGuides.Insert(0, "A段 ") + " B段 RMB" + (BParameter.DJCB * BParameter.DJXS).ToString("#0.00");
  19124. Offcial = Offcial.Insert(0, "A段 ") + " B段 RMB " + (BParameter.GWCB * BParameter.GWXS).ToString("#0.00");
  19125. PettyCash = PettyCash.Insert(0, "A段 ") + " B段 RMB " + (BParameter.LYJCB * BParameter.LYJXS).ToString("#0.00");
  19126. Visa = Visa.Insert(0, "A段 ") + " B段 RMB " + (BParameter.VisaCB * BParameter.VisaXS + BParameter.HSCB * BParameter.HSXS + BParameter.BXCB * BParameter.BXXS).ToString("#0.00");
  19127. TrainTicket = TrainTicket.Insert(0, "A段 ") + " B段 RMB " + (BParameter.HCPCB * BParameter.HCPXS).ToString("#0.00");
  19128. TicketPrice = TicketPrice.Insert(0, "A段 ") + " B段 RMB " + (BParameter.CPCB * BParameter.CPXS).ToString("#0.00");
  19129. AinfoArr = dto.leftInfo.Find(x => x.Type == "B");
  19130. foreach (var item in TzHotelDescArr)
  19131. {
  19132. if (AinfoArr != null)
  19133. {
  19134. TzHotelDesc += "B段信息 \r\n";
  19135. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19136. if (Ainfo != null)
  19137. {
  19138. if (int.Parse(Ainfo.rs) <= 0)
  19139. {
  19140. continue;
  19141. }
  19142. var hotelText = string.Empty;
  19143. switch (item)
  19144. {
  19145. case "SGR":
  19146. hotelText = "单人间";
  19147. break;
  19148. case "JSES":
  19149. hotelText = "小套房";
  19150. break;
  19151. case "SUITE":
  19152. hotelText = "套房";
  19153. break;
  19154. case "TBR":
  19155. hotelText = "双人间";
  19156. break;
  19157. }
  19158. if (item != "TBR")
  19159. {
  19160. 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";
  19161. }
  19162. else
  19163. {
  19164. 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";
  19165. }
  19166. index++;
  19167. }
  19168. TzHotelDesc = TzHotelDesc.Insert(0, "A段信息 \r\n");
  19169. }
  19170. }
  19171. index = 1;
  19172. foreach (var item in TzAirDescArr)
  19173. {
  19174. if (AinfoArr != null)
  19175. {
  19176. var Ainfo = AinfoArr.leftinfoNumber.Find(x => x.title.Contains(item));
  19177. if (Ainfo != null)
  19178. {
  19179. if (int.Parse(Ainfo.rs) <= 0)
  19180. {
  19181. continue;
  19182. }
  19183. 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";
  19184. index++;
  19185. }
  19186. }
  19187. }
  19188. }
  19189. Visa = Visa.Insert(0, "签证及保险(含核酸检测): ");
  19190. DickeyValue.Add("TzNumber", TzNumber); //团组人数
  19191. DickeyValue.Add("CarGuides", CarGuides); //地接单人报价
  19192. DickeyValue.Add("CarGuides1", CarGuides1); // 地接 - 车导费
  19193. DickeyValue.Add("Meal", Meal); // 地接 - 餐费
  19194. DickeyValue.Add("SubsidizedMeals", SubsidizedMeals);// 地接 - 餐补
  19195. DickeyValue.Add("NightRepair", NightRepair); // 地接 - 宿补
  19196. DickeyValue.Add("AttractionsTickets", AttractionsTickets); // 地接 - 景点
  19197. DickeyValue.Add("MiscellaneousFees", MiscellaneousFees); // 地接 - 杂费
  19198. DickeyValue.Add("ATip", ATip); // 地接 - 小费
  19199. DickeyValue.Add("TzHotelDesc", TzHotelDesc); //酒店
  19200. DickeyValue.Add("Offcial", Offcial); // 公务单人报价
  19201. DickeyValue.Add("PettyCash", PettyCash); // 零用金单人报价
  19202. DickeyValue.Add("Visa", Visa); // 签证单人报价
  19203. DickeyValue.Add("TrainTicket", TrainTicket); //火车票
  19204. DickeyValue.Add("TicketPrice", TicketPrice); //船票
  19205. DickeyValue.Add("TzAirDesc", TzAirDesc); //机票
  19206. DickeyValue.Add("TzZCost", TzZCost);
  19207. foreach (var key in DickeyValue.Keys)
  19208. {
  19209. if (doc.Range.Bookmarks[key] != null)
  19210. {
  19211. Bookmark mark = doc.Range.Bookmarks[key];
  19212. mark.Text = DickeyValue[key];
  19213. }
  19214. }
  19215. byte[] bytes = null;
  19216. string strFileName = di.TeamName + "-客户报价.doc";
  19217. using (MemoryStream stream = new MemoryStream())
  19218. {
  19219. doc.Save(stream, Aspose.Words.SaveFormat.Doc);
  19220. bytes = stream.ToArray();
  19221. }
  19222. return Ok(JsonView(true, "", new
  19223. {
  19224. Data = bytes,
  19225. strFileName,
  19226. }));
  19227. }
  19228. /// <summary>
  19229. /// 团组成本 各模块(酒店,地接,机票)成本提示
  19230. /// </summary>
  19231. /// <param name="dto"></param>
  19232. /// <returns></returns>
  19233. [HttpPost]
  19234. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  19235. public async Task<IActionResult> PostGroupCostModulePrompt(GroupCostModulePromptDto dto)
  19236. {
  19237. try
  19238. {
  19239. #region 参数验证
  19240. if (dto.DiId < 0)
  19241. {
  19242. return Ok(JsonView(false, "请传入有效的DiId参数!"));
  19243. }
  19244. List<int> cTableIds = new List<int>() {
  19245. 76 ,//酒店预订
  19246. 77 ,//行程
  19247. 79 ,//车/导游地接
  19248. 80 ,//签证
  19249. 81 ,//邀请/公务活
  19250. 82 ,//团组客户保险
  19251. 85 ,//机票预订
  19252. 98 ,//其他款项
  19253. 285 ,//收款退还
  19254. 751 ,//酒店早餐
  19255. 1015 // 超支费用
  19256. };
  19257. if (dto.CTable < 0 && !cTableIds.Contains(dto.CTable))
  19258. {
  19259. return Ok(JsonView(false, "请传入有效的CTable参数!"));
  19260. }
  19261. #endregion
  19262. //Grp_GroupCostParameter 预算表 Grp_GroupCost 详细费用列表
  19263. var _GroupCostParameters = _usersRep._sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
  19264. if (_GroupCostParameters.Count <= 0)
  19265. {
  19266. return Ok(JsonView(false, "暂无该团组成本信息!", new List<dynamic>()));
  19267. }
  19268. if (_GroupCostParameters[0].IsShare == 0)
  19269. {
  19270. return Ok(JsonView(false, "该团组成本未完成!", new List<dynamic>()));
  19271. }
  19272. var _GroupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  19273. //处理date为空问题
  19274. if (_GroupCosts.Count > 0)
  19275. {
  19276. for (int i = 0; i < _GroupCosts.Count; i++)
  19277. {
  19278. if (string.IsNullOrEmpty(_GroupCosts[i].Date))
  19279. {
  19280. if (i > 0)
  19281. {
  19282. _GroupCosts[i].Date = _GroupCosts[i - 1].Date;
  19283. }
  19284. }
  19285. }
  19286. }
  19287. GroupCostModulePromptView _view = new GroupCostModulePromptView();
  19288. List<GroupCostModulePromptInfo> _ModulePromptInfos = new List<GroupCostModulePromptInfo>(); //机票存储多段
  19289. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0 && it.STid == 66).ToList();
  19290. string currCode = "";
  19291. #region currCode 验证
  19292. bool isInt = int.TryParse(_GroupCostParameters[0].Currency, out int intCurrency);
  19293. if (isInt)
  19294. {
  19295. var currData = currDatas.Find(it => it.Id == intCurrency);
  19296. if (currData != null)
  19297. {
  19298. currCode = currData.Name;
  19299. }
  19300. }
  19301. else
  19302. {
  19303. currCode = _GroupCostParameters[0].Currency.Trim();
  19304. }
  19305. #endregion
  19306. //op,酒店单段模式存储
  19307. GroupCostModulePromptInfo _ModulePromptInfo = new GroupCostModulePromptInfo()
  19308. {
  19309. CurrencyCode = currCode,
  19310. Rate = _GroupCostParameters[0].Rate,
  19311. CostType = _GroupCostParameters[0].CostType,
  19312. CostTypeStartTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeStartTime).ToString("yyyy-MM-dd"),
  19313. CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[0].CostTypeendTime).ToString("yyyy-MM-dd"),
  19314. CostTypeNumber = _GroupCostParameters[0].CostTypenumber
  19315. };
  19316. List<dynamic> _ModuleSubPromptInfo = new List<dynamic>(); // 存储CTbale != 85 的动态数据
  19317. if (_GroupCostParameters.Count == 2)
  19318. {
  19319. _ModulePromptInfo.CostTypeEndTime = Convert.ToDateTime(_GroupCostParameters[1].CostTypeendTime).ToString("yyyy-MM-dd");
  19320. }
  19321. foreach (var item in _GroupCostParameters)
  19322. {
  19323. decimal _rate = 1;
  19324. decimal _rate1 = item.Rate;
  19325. decimal _scale = 1;
  19326. //decimal _scale = 0.95M; 雷怡 2024-06-11 10:06:08 屏蔽
  19327. #region 处理地接价格比例 总经理 国交部经理 主管 不下调 其他人 下调 5%
  19328. //var userInfo = _usersRep._sqlSugar.Queryable<Sys_Users>().Where(it => it.IsDel == 0 && it.Id == dto.UserId).First();
  19329. //if (userInfo != null)
  19330. //{
  19331. // if (userInfo.DepId == 1 || userInfo.DepId == 7)
  19332. // {
  19333. // if (userInfo.JobPostId == 1 || userInfo.JobPostId == 22 || userInfo.JobPostId == 32)
  19334. // {
  19335. // _scale = 1.00M;
  19336. // }
  19337. // }
  19338. //}
  19339. #endregion
  19340. GroupCostModulePromptInfo modulePromptInfo = new GroupCostModulePromptInfo()
  19341. {
  19342. CurrencyCode = currCode,
  19343. Rate = _rate1,
  19344. CostType = item.CostType,
  19345. CostTypeStartTime = Convert.ToDateTime(item.CostTypeStartTime).ToString("yyyy-MM-dd"),
  19346. CostTypeEndTime = Convert.ToDateTime(item.CostTypeendTime).ToString("yyyy-MM-dd"),
  19347. CostTypeNumber = item.CostTypenumber
  19348. };
  19349. if (_GroupCostParameters.Count > 1)
  19350. {
  19351. modulePromptInfo.CostTypeNumber = item.CostTypenumber;
  19352. }
  19353. else
  19354. {
  19355. modulePromptInfo.CostTypeNumber = item.LYJRS;
  19356. }
  19357. if (dto.CTable == 79)//
  19358. {
  19359. modulePromptInfo.IndividualCost = item.DJCB / modulePromptInfo.CostTypeNumber;
  19360. modulePromptInfo.TotalCost = item.DJCB;
  19361. }
  19362. List<string> costTypes = new List<string>() { "A", "B" };
  19363. List<Grp_GroupCost> _GroupCostsTypeData = new List<Grp_GroupCost>();
  19364. var _GroupCostsDuplicates = _GroupCostParameters.GroupBy(x => x.CostType).Select(y => y.FirstOrDefault());
  19365. if (_GroupCostsDuplicates.Count() == 1)
  19366. {
  19367. _GroupCostsTypeData = _GroupCosts;
  19368. }
  19369. else
  19370. {
  19371. _GroupCostsTypeData = _GroupCosts.Where(it => Convert.ToDateTime(it.Date) >= Convert.ToDateTime(item.CostTypeStartTime) &&
  19372. Convert.ToDateTime(it.Date) <= Convert.ToDateTime(item.CostTypeendTime)).ToList();
  19373. }
  19374. /*
  19375. * 76 酒店预订
  19376. * 77 行程
  19377. * 79 车/导游地接
  19378. * 80 签证
  19379. * 81 邀请/公务活动
  19380. * 82 团组客户保险
  19381. * 85 机票预订
  19382. * 98 其他款项
  19383. * 285 收款退还
  19384. * 751 酒店早餐
  19385. * 1015 超支费用
  19386. */
  19387. switch (dto.CTable)
  19388. {
  19389. case 76: // 酒店预订
  19390. _ModuleSubPromptInfo.AddRange(
  19391. _GroupCostsTypeData.Select(it => new
  19392. {
  19393. it.DAY,
  19394. it.Date,
  19395. it.ACCON,
  19396. it.ITIN,
  19397. it.SGR,
  19398. it.TBR,
  19399. it.JS_ES,
  19400. it.Suite
  19401. })
  19402. );
  19403. break;
  19404. case 79: // 车/导游地接
  19405. _ModuleSubPromptInfo.AddRange(
  19406. _GroupCostsTypeData.Select(it => new
  19407. {
  19408. Date = it.Date, //日期
  19409. CarFee = it.CarCost * _rate * _scale, //车费用
  19410. CarType = it.CarType, //车型
  19411. DriverFee = it.CFS * _rate * _scale, //司机工资
  19412. DriverTipsFee = it.DRVTips * _rate * _scale, //司机小费
  19413. DriverMealSubsidy = it.CFM * _rate * _scale, //司机餐补
  19414. DriverOvertimeFee = it.CFOF * _rate * _scale, //司机超时费用
  19415. GuideFee = it.TGS * _rate * _scale, //导游费用
  19416. GuideOvertimeFee = it.TGOF * _rate * _scale, //导游超时费用
  19417. GuideMealSubsidy = it.TGM * _rate * _scale, //导游餐补
  19418. GuideRoomSubsidy = it.TGA * _rate * _scale, //导游房补
  19419. GuideCarFare = it.TGTF * _rate * _scale, //导游交通费
  19420. GuideSpotFee = it.TGEF * _rate * _scale, //导游景点费
  19421. GuideTipsFee = it.TGTips * _rate * _scale, //导游小费
  19422. Breakfast = it.B * _rate * _scale, //早餐费
  19423. Lunch = it.L * _rate * _scale, //午餐费
  19424. Dinner = it.D * _rate * _scale, //晚餐费
  19425. OfficialActivitiesFee = it.TV * _rate * _scale,//会务活动费 --新加
  19426. OfficialTransFee = it.IF * _rate * _scale, //公务翻译费 --新加
  19427. InvitationFee = it.iL * _rate * _scale, //邀请函费用 --新加
  19428. TicketFee = it.EF * _rate * _scale, //门票费
  19429. TicketRemark = it.EFR, //门票费描述
  19430. DrinksSnacksFruitFee = it.B_R_F * _rate * _scale, //饮料零食水果
  19431. TravelSupplies = it.TE * _rate * _scale, //出行物资
  19432. SpentCash = it.PC * _rate * _scale, //零用金
  19433. LeadersFee = it.TLF * _rate * _scale, //领队费
  19434. ActivitiesFee = it.ECT * _rate * _scale, //会务费 --新加
  19435. })
  19436. );
  19437. break;
  19438. case 85: // 机票
  19439. List<dynamic> datas = new List<dynamic>();
  19440. datas.Add(
  19441. new
  19442. {
  19443. AirType = "经济舱",
  19444. AirNum = item.JJCRS,
  19445. AirDRCB = item.JJCCB,
  19446. AirZCB = (item.JJCRS * item.JJCCB)
  19447. }
  19448. );
  19449. datas.Add(
  19450. new
  19451. {
  19452. AirType = "公务舱",
  19453. AirNum = item.GWCRS,
  19454. AirDRCB = item.GWCCB,
  19455. AirZCB = (item.GWCRS * item.GWCCB)
  19456. }
  19457. );
  19458. var groupCosts = _usersRep._sqlSugar.Queryable<Grp_GroupCost>().Where(it => it.IsDel == 0 && it.Diid == dto.DiId).ToList();
  19459. var initDatas = groupCosts.Select(it => new { date = it.Date, week = it.Date.GetWeek() == "" ? "-" : it.Date.GetWeek(), itinerary = it.ITIN }).ToList();
  19460. modulePromptInfo.Data = new
  19461. {
  19462. airFeeData = datas,
  19463. airInitData = initDatas
  19464. };
  19465. _ModulePromptInfos.Add(modulePromptInfo);
  19466. break;
  19467. default:
  19468. break;
  19469. }
  19470. }
  19471. if (dto.CTable != 85)
  19472. {
  19473. _ModulePromptInfo.Data = _ModuleSubPromptInfo;
  19474. _ModulePromptInfos.Add(_ModulePromptInfo);
  19475. }
  19476. _view.ModulePromptInfos = _ModulePromptInfos;
  19477. return Ok(JsonView(true, "操作成功!", _view));
  19478. }
  19479. catch (Exception ex)
  19480. {
  19481. return Ok(JsonView(false, ex.Message));
  19482. }
  19483. }
  19484. /// <summary>
  19485. /// 根据黑屏代码重新生成行程
  19486. /// </summary>
  19487. /// <param name="dto"></param>
  19488. /// <returns></returns>
  19489. [HttpPost]
  19490. public IActionResult CraeteGroupCostTravel(GroupCostInItDto dto)
  19491. {
  19492. var jw = JsonView(false, "Error");
  19493. var Create = _sqlSugar.Queryable<Air_TicketBlackCode>()
  19494. .Where(x => x.IsDel == 0 && x.DiId == dto.Diid)
  19495. .Select(x => new
  19496. {
  19497. x.Id,
  19498. x.Title
  19499. })
  19500. .ToList();
  19501. if (Create.Any())
  19502. {
  19503. jw.Msg = "获取成功!";
  19504. jw.Code = 200;
  19505. jw.Data = new
  19506. {
  19507. BlackCodeListSelect = Create,
  19508. blackCodeIsTrue = true
  19509. };
  19510. }
  19511. else
  19512. {
  19513. jw.Code = 400;
  19514. jw.Data = new
  19515. {
  19516. BlackCodeListSelect = Create,
  19517. blackCodeIsTrue = false,
  19518. };
  19519. }
  19520. return Ok(jw);
  19521. }
  19522. /// <summary>
  19523. /// 根据黑屏代码Id重新生成行程
  19524. /// </summary>
  19525. /// <param name="dto"></param>
  19526. /// <returns></returns>
  19527. [HttpPost]
  19528. public IActionResult CraeteGroupCostTravelById(CraeteGroupCostTravelByIdDto dto)
  19529. {
  19530. var jw = JsonView(false, "Error");
  19531. var result = _GroupCostRepository.CreateGroupCostByBlackCode(dto.DiId, dto.BlackCodeId);
  19532. if (result.Code == 0)
  19533. {
  19534. jw.Msg = "获取成功!";
  19535. jw.Code = 200;
  19536. jw.Data = new
  19537. {
  19538. groupCost = result.Data,
  19539. blackCodeIsTrue = true
  19540. };
  19541. }
  19542. else
  19543. {
  19544. jw.Code = 400;
  19545. jw.Data = new
  19546. {
  19547. groupCost = result.Data,
  19548. blackCodeIsTrue = false,
  19549. };
  19550. }
  19551. return Ok(jw);
  19552. }
  19553. /// <summary>
  19554. /// 成本获取OP历史车费用
  19555. /// </summary>
  19556. /// <param name="dto"></param>
  19557. /// <returns></returns>
  19558. [HttpPost]
  19559. public async Task<IActionResult> GetHistoryCarData(HistoryCarDataDto dto)
  19560. {
  19561. var jw = JsonView(false);
  19562. try
  19563. {
  19564. List<HistoryCarDataView> dbResult = new List<HistoryCarDataView>();
  19565. //获取现有所有车的数据
  19566. if (!dto.Param.IsNullOrWhiteSpace())
  19567. {
  19568. string sql = $@"
  19569. SELECT gdi.TeamName , gctggr.Area, gctggr.PriceName , gctggrc.Id ,gctggrc.Price , gctggrc.DatePrice , gctggrc.PriceContent , gctggrc.Currency , gctggr.ServiceStartTime , gctggr.ServiceEndTime
  19570. FROM Grp_CarTouristGuideGroundReservationsContent gctggrc inner join Grp_CarTouristGuideGroundReservations gctggr on
  19571. gctggrc.CTGGRId = gctggr.Id inner JOIN Grp_DelegationInfo gdi on gctggr.DiId = gdi.Id LEFT JOIN Sys_SetData ssd on ssd.Id = gctggr.PriceType
  19572. 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
  19573. AND gctggr.ServiceEndTime is not NULL
  19574. ORDER by gctggrc.id DESC
  19575. ";
  19576. dbResult = await _sqlSugar.SqlQueryable<HistoryCarDataView>(sql).ToListAsync();
  19577. var numeberResult = await Task.Run(() =>
  19578. {
  19579. var numberArr = dbResult.Where(x => int.TryParse(x.Area, out int number)).ToList();
  19580. _ = dbResult.RemoveAll(x => int.TryParse(x.Area, out int number));
  19581. return numberArr;
  19582. });
  19583. var cityArr = await _sqlSugar.Queryable<Grp_NationalTravelFee>().ToListAsync();
  19584. foreach (var item in numeberResult)
  19585. {
  19586. var find = cityArr.Find(x => x.Id == int.Parse(item.Area)) ?? new Grp_NationalTravelFee
  19587. {
  19588. Country = "数据异常!",
  19589. City = string.Empty,
  19590. };
  19591. item.Area = find.Country + " " + find.City;
  19592. }
  19593. dbResult.AddRange(numeberResult);
  19594. if (dto.Param.Contains("、"))
  19595. {
  19596. var sp = dto.Param.Split("、");
  19597. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  19598. .Where(x =>
  19599. {
  19600. return System.Array.Exists(sp, e =>
  19601. {
  19602. bool where = false;
  19603. if (x.Area != null)
  19604. {
  19605. where = x.Area.Contains(e);
  19606. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  19607. {
  19608. return false;
  19609. }
  19610. }
  19611. if (x.PriceName != null && !where)
  19612. {
  19613. where = x.PriceName.Contains(e);
  19614. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  19615. {
  19616. return false;
  19617. }
  19618. }
  19619. return where;
  19620. });
  19621. }).ToList();
  19622. }
  19623. else
  19624. {
  19625. dbResult = dbResult.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount)
  19626. .Where(x =>
  19627. {
  19628. bool where = false;
  19629. if (x.Area != null)
  19630. {
  19631. where = x.Area.Contains(dto.Param);
  19632. if (x.Area.Contains("尾款") || x.PriceName.Contains("尾款"))
  19633. {
  19634. return false;
  19635. }
  19636. }
  19637. if (x.PriceName != null && !where)
  19638. {
  19639. where = x.PriceName.Contains(dto.Param);
  19640. if (x.PriceName.Contains("尾款") || x.PriceName.Contains("尾款"))
  19641. {
  19642. return false;
  19643. }
  19644. }
  19645. return where;
  19646. }
  19647. )
  19648. .ToList();
  19649. }
  19650. }
  19651. var view = dbResult.Select(x =>
  19652. {
  19653. decimal dp = 0.00M;
  19654. var startB = DateTime.TryParse(x.Start.ToString(), out DateTime startD);
  19655. var endB = DateTime.TryParse(x.End.ToString(), out DateTime endD);
  19656. if (string.IsNullOrWhiteSpace(x.DatePrice))
  19657. {
  19658. if (startB && endB)
  19659. {
  19660. var timesp = endD.Subtract(startD);
  19661. if ((timesp.Days + 1) != 0)
  19662. {
  19663. dp = x.Price / (timesp.Days + 1);
  19664. }
  19665. }
  19666. }
  19667. else
  19668. {
  19669. dp = x.Price;
  19670. }
  19671. return new
  19672. {
  19673. start = startB ? startD.ToString("yyyy-MM-dd") : "",
  19674. end = endB ? endD.ToString("yyyy-MM-dd") : "",
  19675. x.Area,
  19676. x.id,
  19677. price = x.Price.ToString("F2"),
  19678. x.PriceName,
  19679. x.PriceContent,
  19680. x.TeamName,
  19681. x.DatePrice,
  19682. dayPrice = dp.ToString("F2"),
  19683. };
  19684. }).OrderByDescending(x => x.id).ToList();
  19685. jw = JsonView(true, "获取成功!", view);
  19686. }
  19687. catch (Exception e)
  19688. {
  19689. jw = JsonView(false, e.Message);
  19690. }
  19691. return Ok(jw);
  19692. }
  19693. [HttpPost]
  19694. public async Task<IActionResult> SearchGroupByKeyword(SearchGroupByKeywordDto dto)
  19695. {
  19696. var jw = JsonView(true);
  19697. List<DelegationInfoAndIsTrueView> matches = new List<DelegationInfoAndIsTrueView>();
  19698. #region SQL语句
  19699. //if (string.IsNullOrWhiteSpace(dto.Keyword))
  19700. //{
  19701. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  19702. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  19703. // WHEN COUNT(*) >= 0 THEN 'True'
  19704. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  19705. // Where TeamName != '' And IsDel = 0 Order By a.VisitStartDate Desc
  19706. // ")
  19707. // .ToList();
  19708. //}
  19709. //else
  19710. //{
  19711. // string likeKey = string.Empty;
  19712. // foreach (var item in dto.Keyword)
  19713. // {
  19714. // likeKey += "%" + item;
  19715. // }
  19716. // likeKey += "%";
  19717. // matches = _sqlSugar.SqlQueryable<DelegationInfoAndIsTrueView>($@"
  19718. // Select a.Id,TeamName GroupName,b.isTrue From Grp_DelegationInfo a left join (select top 100 percent Diid, CASE
  19719. // WHEN COUNT(*) >= 0 THEN 'True'
  19720. // ELSE 'False' END as isTrue from Grp_GroupCost where Isdel = 0 and date != '' group by Diid) b on a.Id = b.Diid
  19721. // Where TeamName != '' And IsDel = 0 And TeamName LIKE '{likeKey}' Order By a.VisitStartDate Desc
  19722. // ")
  19723. // .ToList();
  19724. //}
  19725. #endregion
  19726. var table = _sqlSugar.Ado.UseStoredProcedure().GetDataTable("SearchGroupByKeyword", new
  19727. {
  19728. @KeyWord = dto.Keyword
  19729. });
  19730. if (table != null && table.Rows.Count > 0)
  19731. {
  19732. foreach (DataRow row in table.Rows)
  19733. {
  19734. matches.Add(new DelegationInfoAndIsTrueView
  19735. {
  19736. Id = row.Field<int>("Id"),
  19737. GroupName = row.Field<string>("GroupName"),
  19738. isTrue = row.Field<string>("isTrue")
  19739. });
  19740. }
  19741. }
  19742. if (matches.Any())
  19743. {
  19744. jw.Data = matches;
  19745. }
  19746. else
  19747. {
  19748. jw.Code = 201;
  19749. jw.Msg = "empty list";
  19750. jw.Data = new List<string>(1);
  19751. }
  19752. return Ok(jw);
  19753. }
  19754. /// <summary>
  19755. /// 报价Word下载
  19756. /// </summary>
  19757. /// <param name="dto"></param>
  19758. /// <returns></returns>
  19759. [HttpPost]
  19760. public async Task<IActionResult> GroupQuotationsFileDown(GroupQuotationsFileDownDto dto)
  19761. {
  19762. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  19763. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  19764. if (di == null)
  19765. {
  19766. return Ok(JsonView(false, "团组不存在!"));
  19767. }
  19768. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  19769. if (mainPrice == null || mainPrice.IsShare == 0)
  19770. {
  19771. return Ok(JsonView(false, "团组成本不存在!"));
  19772. }
  19773. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  19774. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  19775. if (costTypeHotelNumbers == null)
  19776. {
  19777. return Ok(JsonView(false, "团组成本不存在!"));
  19778. }
  19779. //文件名
  19780. string strFileName = di.TeamName + "-收款账单.doc";
  19781. //获取模板
  19782. string tmppath = (AppSettingsHelper.Get("WordBasePath") + "Template/收款账单(四川)模板.doc");
  19783. //载入模板
  19784. Document doc = new Document(tmppath);
  19785. decimal allPrice = 0.00M;
  19786. string itemStr = string.Empty;
  19787. Dictionary<string, string> airSouer = new Dictionary<string, string>();
  19788. airSouer.Add("经济舱TBR", "经济舱及酒店双人间");
  19789. airSouer.Add("经济舱SGR", "经济舱及酒店单人间");
  19790. airSouer.Add("公务舱SGR", "公务舱及酒店单人间");
  19791. airSouer.Add("公务舱JSES", "公务舱及酒店小套房");
  19792. airSouer.Add("公务舱SUITE", "公务舱及酒店套房");
  19793. airSouer.Add("经济舱SUITE", "经济舱及酒店套房");
  19794. airSouer.Add("头等舱JSES", "头等舱及酒店小套房");
  19795. airSouer.Add("头等舱SUITE", "头等舱及酒店套房");
  19796. airSouer.Add("经济舱JSES", "经济舱及酒店小套房");
  19797. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  19798. {
  19799. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  19800. ("BXRS", "BXCB", "BXXS", "bx"),
  19801. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  19802. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  19803. ("GWCRS", "GWCCB", "GWCXS", "gwc"),
  19804. ("TDCRS", "TDCCB", "TDCXS", "tdc"),
  19805. ("CPRS", "CPCB", "CPXS", "cp"),
  19806. ("HSRS", "HSCB", "HSXS", "hsjc"),
  19807. ("TBRNumber", "TBRCB", "TBRXS", "tbr"),
  19808. ("SGRNumber", "SGRCB", "SGRXS", "sgr"),
  19809. ("JSESNumber", "JSESCB", "JSESXS", "jses"),
  19810. ("SUITENumber", "SUITECB", "SUITEXS", "suite"),
  19811. ("DJRS", "DJCB", "DJXS", "dj"),
  19812. ("GWRS", "GWCB", "GWXS", "gw"),
  19813. ("LYJRS", "LYJCB", "LYJXS", "lyj"),
  19814. };
  19815. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  19816. var rightSum = 0.00M;
  19817. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  19818. {
  19819. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  19820. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  19821. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  19822. if (prefix == "tbr")
  19823. {
  19824. rsValue *= 2;
  19825. cbValue /= 2;
  19826. }
  19827. if (OtherCostPropertyBJ.Contains(prefix))
  19828. {
  19829. rightSum += cbValue * xsValue;
  19830. }
  19831. }
  19832. var hotelRooms = new Dictionary<string, int>
  19833. {
  19834. { "SGR", costTypeHotelNumbers.SGR },
  19835. { "TBR", costTypeHotelNumbers.TBR },
  19836. { "JSES", costTypeHotelNumbers.JSES },
  19837. { "SUITE", costTypeHotelNumbers.SUITE }
  19838. };
  19839. var flights = new Dictionary<string, int>
  19840. {
  19841. { "经济舱", mainPrice.JJCRS },
  19842. { "公务舱", mainPrice.GWCRS },
  19843. { "头等舱", mainPrice.TDCRS }
  19844. };
  19845. var flightRoomMatchingRules = new Dictionary<string, string[]>
  19846. {
  19847. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  19848. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  19849. { "头等舱", new[] { "SUITE", "JSES" } }
  19850. };
  19851. var result = new Dictionary<string, int>();
  19852. List<AirHotelPrice> airHotelPriceList = new List<AirHotelPrice>();
  19853. foreach (var flight in flights.Keys)
  19854. {
  19855. // 获取当前舱位的匹配规则
  19856. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  19857. {
  19858. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  19859. }
  19860. }
  19861. #region right计算
  19862. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  19863. {
  19864. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19865. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  19866. airHotelPriceList.Add(new
  19867. AirHotelPrice
  19868. {
  19869. Name = "经济舱TBR",
  19870. Price = rightSum + air + hotel,
  19871. Count = result["经济舱TBR"] * 2
  19872. });
  19873. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  19874. }
  19875. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  19876. {
  19877. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19878. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  19879. airHotelPriceList.Add(new
  19880. AirHotelPrice
  19881. {
  19882. Name = "经济舱SGR",
  19883. Price = rightSum + air + hotel,
  19884. Count = result["经济舱SGR"]
  19885. });
  19886. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  19887. }
  19888. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  19889. {
  19890. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  19891. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  19892. airHotelPriceList.Add(new
  19893. AirHotelPrice
  19894. {
  19895. Name = "公务舱SGR",
  19896. Price = rightSum + air + hotel,
  19897. Count = result["公务舱SGR"]
  19898. });
  19899. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  19900. }
  19901. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  19902. {
  19903. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  19904. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  19905. airHotelPriceList.Add(new
  19906. AirHotelPrice
  19907. {
  19908. Name = "公务舱JSES",
  19909. Price = rightSum + air + hotel,
  19910. Count = result["公务舱JSES"]
  19911. });
  19912. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  19913. }
  19914. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  19915. {
  19916. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  19917. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  19918. airHotelPriceList.Add(new
  19919. AirHotelPrice
  19920. {
  19921. Name = "公务舱SUITE",
  19922. Price = rightSum + air + hotel,
  19923. Count = result["公务舱SUITE"]
  19924. });
  19925. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  19926. }
  19927. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  19928. {
  19929. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19930. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  19931. airHotelPriceList.Add(new
  19932. AirHotelPrice
  19933. {
  19934. Name = "经济舱SUITE",
  19935. Price = rightSum + air + hotel,
  19936. Count = result["经济舱SUITE"]
  19937. });
  19938. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  19939. }
  19940. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  19941. {
  19942. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  19943. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  19944. airHotelPriceList.Add(new
  19945. AirHotelPrice
  19946. {
  19947. Name = "头等舱JSES",
  19948. Price = rightSum + air + hotel,
  19949. Count = result["头等舱JSES"]
  19950. });
  19951. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  19952. }
  19953. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  19954. {
  19955. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  19956. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  19957. airHotelPriceList.Add(new
  19958. AirHotelPrice
  19959. {
  19960. Name = "头等舱SUITE",
  19961. Price = rightSum + air + hotel,
  19962. Count = result["头等舱SUITE"]
  19963. });
  19964. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  19965. }
  19966. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  19967. {
  19968. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  19969. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  19970. airHotelPriceList.Add(new
  19971. AirHotelPrice
  19972. {
  19973. Name = "经济舱JSES",
  19974. Price = rightSum + air + hotel,
  19975. Count = result["经济舱JSES"]
  19976. });
  19977. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  19978. }
  19979. #endregion
  19980. foreach (var item in airSouer.Keys)
  19981. {
  19982. var find = airHotelPriceList.FirstOrDefault(x => x.Name == item);
  19983. if (find != null && find.Count > 0)
  19984. {
  19985. if (item.Contains("TBR"))
  19986. {
  19987. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + (find.Count / 2) + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  19988. }
  19989. else
  19990. {
  19991. itemStr += "团费(" + airSouer[item] + ") RMB " + find.Price.ToString("F2") + "/人*" + find.Count + "(" + find.Count + "间) ............合计 RMB " + (find.Count * find.Price).ToString("#0.00") + "\n";
  19992. }
  19993. }
  19994. }
  19995. #region 替换Word模板书签内容
  19996. Dictionary<string, string> marks = new Dictionary<string, string>();
  19997. marks.Add("To", di.ClientUnit);//付款方
  19998. marks.Add("ToTel", di.TellPhone);//付款方电话
  19999. marks.Add("Date", DateTime.Now.ToString("yyyy-MM-dd"));//导出时间
  20000. marks.Add("Team", di.VisitCountry.Replace(" ", "、"));//团队名称
  20001. marks.Add("TontractTime", (di.VisitDate).ToString("yyyy年MM月dd日"));//付款日期
  20002. marks.Add("PayDay", (di.PayDay).ToString());//付款预期
  20003. marks.Add("PaymentMoney", (di.PaymentMoney).ToString("#0.00"));//付款金额
  20004. marks.Add("WeChat", di.WeChatNo ?? "");//微信号
  20005. marks.Add("PayItemContent", itemStr);//详细信息
  20006. marks.Add("Total", allPrice.ToString("F2"));//合计
  20007. #endregion
  20008. foreach (var item in marks.Keys)
  20009. {
  20010. if (doc.Range.Bookmarks[item] != null)
  20011. {
  20012. Bookmark mark = doc.Range.Bookmarks[item];
  20013. mark.Text = marks[item];
  20014. }
  20015. }
  20016. string savePaht = $"{AppSettingsHelper.Get("WordBasePath")}GroupCostQuotations/{di.TeamName}_报批费用.doc";
  20017. doc.Save(savePaht);
  20018. var jw = new JsonView();
  20019. jw.Msg = "生成成功!";
  20020. jw.Code = 200;
  20021. jw.Data = new { Url = AppSettingsHelper.Get("WordBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("WordBasePath"), AppSettingsHelper.Get("WordFtpPath")) };
  20022. return Ok(jw);
  20023. }
  20024. /// <summary>
  20025. /// 详细报价费用Excel下载
  20026. /// </summary>
  20027. /// <param name="dto"></param>
  20028. /// <returns></returns>
  20029. [HttpPost]
  20030. public async Task<IActionResult> GroupQuotationsDetailFileDown(GroupQuotationsFileDownDto dto)
  20031. {
  20032. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  20033. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  20034. if (di == null)
  20035. {
  20036. return Ok(JsonView(false, "团组不存在!"));
  20037. }
  20038. var mainPrice = _GroupCostParameterRepository.GetGroupCostParameterMainByDiid(dto.Diid);
  20039. if (mainPrice == null || mainPrice.IsShare == 0)
  20040. {
  20041. return Ok(JsonView(false, "团组成本不存在!"));
  20042. }
  20043. var costTypeHotelNumbers = await _sqlSugar.Queryable<Grp_CostTypeHotelNumber>()
  20044. .FirstAsync(x => x.Type == "Default" && x.Diid == dto.Diid && x.IsDel == 0);
  20045. if (costTypeHotelNumbers == null)
  20046. {
  20047. return Ok(JsonView(false, "团组成本不存在!"));
  20048. }
  20049. WorkbookDesigner designer = new WorkbookDesigner();
  20050. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + ("Template/报价详细表.xls"));
  20051. List<int> hideRowsList = new List<int>();
  20052. int conterStartIndex = 3;
  20053. int rowIndex = conterStartIndex;
  20054. designer.SetDataSource("GroupName", di.TeamName);
  20055. var priceDataList = new List<(string rsName, string cbName, string xsName, string prefix)>
  20056. {
  20057. ("VisaRS", "VisaCB", "VisaXS", "qz"),
  20058. ("BXRS", "BXCB", "BXXS", "bx"),
  20059. ("HCPRS", "HCPCB", "HCPXS", "hcp"),
  20060. ("JJCRS", "JJCCB", "JJCXS", "jjc"),
  20061. ("GWCRS", "GWCCB", "GWCXS", "gwc") ,
  20062. ("TDCRS", "TDCCB", "TDCXS", "tdc") ,
  20063. ("CPRS", "CPCB", "CPXS", "cp") ,
  20064. ("HSRS", "HSCB", "HSXS", "hsjc") ,
  20065. ("TBRNumber", "TBRCB", "TBRXS", "tbr") ,
  20066. ("SGRNumber", "SGRCB", "SGRXS", "sgr") ,
  20067. ("JSESNumber", "JSESCB", "JSESXS", "jses") ,
  20068. ("SUITENumber", "SUITECB", "SUITEXS", "suite") ,
  20069. ("DJRS", "DJCB", "DJXS", "dj") ,
  20070. ("GWRS", "GWCB", "GWXS", "gw") ,
  20071. ("LYJRS", "LYJCB", "LYJXS", "lyj") ,
  20072. };
  20073. var OtherCostPropertyBJ = new string[] { "qz", "hcp", "cp", "bx", "hsjc", "dj", "gw", "lyj" };
  20074. var rightSum = 0.00M;
  20075. foreach (var (rsName, cbName, xsName, prefix) in priceDataList)
  20076. {
  20077. var rsValue = (int)mainPrice.GetType().GetProperty(rsName).GetValue(mainPrice);
  20078. var cbValue = (decimal)mainPrice.GetType().GetProperty(cbName).GetValue(mainPrice);
  20079. var xsValue = (decimal)mainPrice.GetType().GetProperty(xsName).GetValue(mainPrice);
  20080. if (prefix == "tbr")
  20081. {
  20082. rsValue *= 2;
  20083. cbValue /= 2;
  20084. }
  20085. if (OtherCostPropertyBJ.Contains(prefix))
  20086. {
  20087. rightSum += cbValue * xsValue;
  20088. }
  20089. if (rsValue == 0)
  20090. {
  20091. hideRowsList.Add(rowIndex);
  20092. }
  20093. else
  20094. {
  20095. designer.SetDataSource($"{prefix}rs", rsValue);
  20096. designer.SetDataSource($"{prefix}bj", cbValue * xsValue);
  20097. designer.SetDataSource($"{prefix}zbj", cbValue * xsValue * rsValue);
  20098. }
  20099. rowIndex += 2;
  20100. }
  20101. var hotelRooms = new Dictionary<string, int>
  20102. {
  20103. { "SGR", costTypeHotelNumbers.SGR },
  20104. { "TBR", costTypeHotelNumbers.TBR },
  20105. { "JSES", costTypeHotelNumbers.JSES },
  20106. { "SUITE", costTypeHotelNumbers.SUITE }
  20107. };
  20108. var flights = new Dictionary<string, int>
  20109. {
  20110. { "经济舱", mainPrice.JJCRS },
  20111. { "公务舱", mainPrice.GWCRS },
  20112. { "头等舱", mainPrice.TDCRS }
  20113. };
  20114. var flightRoomMatchingRules = new Dictionary<string, string[]>
  20115. {
  20116. { "经济舱", new[] { "TBR", "SGR", "JSES", "SUITE" } },
  20117. { "公务舱", new[] { "SUITE", "JSES", "SGR" } },
  20118. { "头等舱", new[] { "SUITE", "JSES" } }
  20119. };
  20120. var result = new Dictionary<string, int>();
  20121. foreach (var flight in flights.Keys)
  20122. {
  20123. // 获取当前舱位的匹配规则
  20124. if (flightRoomMatchingRules.TryGetValue(flight, out string[] roomTypes))
  20125. {
  20126. MatchRooms(ref hotelRooms, ref flights, roomTypes, flight, ref result);
  20127. }
  20128. }
  20129. var allPrice = 0.00M;
  20130. #region right计算
  20131. int airRowIndex = 35;
  20132. if (result.Keys.Contains("经济舱TBR") && result["经济舱TBR"] > 0)
  20133. {
  20134. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20135. var hotel = (mainPrice.TBRCB * mainPrice.TBRXS) / 2;
  20136. designer.SetDataSource("jjctbrrs", result["经济舱TBR"] * 2);
  20137. designer.SetDataSource("jjctbrbj", rightSum + air + hotel);
  20138. designer.SetDataSource("jjctbrzbj", (rightSum + air + hotel) * result["经济舱TBR"] * 2);
  20139. allPrice += (rightSum + air + hotel) * result["经济舱TBR"] * 2;
  20140. }
  20141. else
  20142. {
  20143. hideRowsList.Add(airRowIndex);
  20144. }
  20145. airRowIndex += 2;
  20146. if (result.Keys.Contains("经济舱SGR") && result["经济舱SGR"] > 0)
  20147. {
  20148. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20149. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  20150. designer.SetDataSource("jjcsgrrs", result["经济舱SGR"]);
  20151. designer.SetDataSource("jjcsgrbj", rightSum + air + hotel);
  20152. designer.SetDataSource("jjcsgrzbj", (rightSum + air + hotel) * result["经济舱SGR"]);
  20153. allPrice += (rightSum + air + hotel) * result["经济舱SGR"];
  20154. }
  20155. else
  20156. {
  20157. hideRowsList.Add(airRowIndex);
  20158. }
  20159. airRowIndex += 2;
  20160. if (result.Keys.Contains("公务舱SGR") && result["公务舱SGR"] > 0)
  20161. {
  20162. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  20163. var hotel = mainPrice.SGRCB * mainPrice.SGRXS;
  20164. designer.SetDataSource("gwcsgrrs", result["公务舱SGR"]);
  20165. designer.SetDataSource("gwcsgrbj", rightSum + air + hotel);
  20166. designer.SetDataSource("gwcsgrzbj", (rightSum + air + hotel) * result["公务舱SGR"]);
  20167. allPrice += (rightSum + air + hotel) * result["公务舱SGR"];
  20168. }
  20169. else
  20170. {
  20171. hideRowsList.Add(airRowIndex);
  20172. }
  20173. airRowIndex += 2;
  20174. if (result.Keys.Contains("公务舱JSES") && result["公务舱JSES"] > 0)
  20175. {
  20176. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  20177. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  20178. designer.SetDataSource("gwcjsesrs", result["公务舱JSES"]);
  20179. designer.SetDataSource("gwcjsesbj", rightSum + air + hotel);
  20180. designer.SetDataSource("gwcjseszbj", (rightSum + air + hotel) * result["公务舱JSES"]);
  20181. allPrice += (rightSum + air + hotel) * result["公务舱JSES"];
  20182. }
  20183. else
  20184. {
  20185. hideRowsList.Add(airRowIndex);
  20186. }
  20187. airRowIndex += 2;
  20188. if (result.Keys.Contains("公务舱SUITE") && result["公务舱SUITE"] > 0)
  20189. {
  20190. var air = mainPrice.GWCCB * mainPrice.GWCXS;
  20191. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  20192. designer.SetDataSource("gwcsuiters", result["公务舱SUITE"]);
  20193. designer.SetDataSource("gwcsuitebj", rightSum + air + hotel);
  20194. designer.SetDataSource("gwcsuitezbj", (rightSum + air + hotel) * result["公务舱SUITE"]);
  20195. allPrice += (rightSum + air + hotel) * result["公务舱SUITE"];
  20196. }
  20197. else
  20198. {
  20199. hideRowsList.Add(airRowIndex);
  20200. }
  20201. airRowIndex += 2;
  20202. if (result.Keys.Contains("经济舱SUITE") && result["经济舱SUITE"] > 0)
  20203. {
  20204. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20205. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  20206. designer.SetDataSource("jjcsuiters", result["经济舱SUITE"]);
  20207. designer.SetDataSource("jjcsuitebj", rightSum + air + hotel);
  20208. designer.SetDataSource("jjcsuitezbj", (rightSum + air + hotel) * result["经济舱SUITE"]);
  20209. allPrice += (rightSum + air + hotel) * result["经济舱SUITE"];
  20210. }
  20211. else
  20212. {
  20213. hideRowsList.Add(airRowIndex);
  20214. }
  20215. airRowIndex += 2;
  20216. if (result.Keys.Contains("头等舱JSES") && result["头等舱JSES"] > 0)
  20217. {
  20218. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  20219. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  20220. designer.SetDataSource("tdcjsesrs", result["头等舱JSES"]);
  20221. designer.SetDataSource("tdcjsesbj", rightSum + air + hotel);
  20222. designer.SetDataSource("tdcjseszbj", (rightSum + air + hotel) * result["头等舱JSES"]);
  20223. allPrice += (rightSum + air + hotel) * result["头等舱JSES"];
  20224. }
  20225. else
  20226. {
  20227. hideRowsList.Add(airRowIndex);
  20228. }
  20229. airRowIndex += 2;
  20230. if (result.Keys.Contains("头等舱SUITE") && result["头等舱SUITE"] > 0)
  20231. {
  20232. var air = mainPrice.TDCCB * mainPrice.TDCXS;
  20233. var hotel = mainPrice.SUITECB * mainPrice.SUITEXS;
  20234. designer.SetDataSource("tdcsuiters", result["头等舱SUITE"]);
  20235. designer.SetDataSource("tdcsuitebj", rightSum + air + hotel);
  20236. designer.SetDataSource("tdcsuitezbj", (rightSum + air + hotel) * result["头等舱SUITE"]);
  20237. allPrice += (rightSum + air + hotel) * result["头等舱SUITE"];
  20238. }
  20239. else
  20240. {
  20241. hideRowsList.Add(airRowIndex);
  20242. }
  20243. airRowIndex += 2;
  20244. if (result.Keys.Contains("经济舱JSES") && result["经济舱JSES"] > 0)
  20245. {
  20246. var air = mainPrice.JJCCB * mainPrice.JJCXS;
  20247. var hotel = mainPrice.JSESCB * mainPrice.JSESXS;
  20248. designer.SetDataSource("jjcjsesrs", result["经济舱JSES"]);
  20249. designer.SetDataSource("jjcjsesbj", rightSum + air + hotel);
  20250. designer.SetDataSource("jjcjseszbj", (rightSum + air + hotel) * result["经济舱JSES"]);
  20251. allPrice += (rightSum + air + hotel) * result["经济舱JSES"];
  20252. }
  20253. else
  20254. {
  20255. hideRowsList.Add(airRowIndex);
  20256. }
  20257. #endregion
  20258. designer.SetDataSource("AllPrice", "总金额:" + allPrice.ToString("#0.00"));
  20259. string savePaht = AppSettingsHelper.Get("ExcelBasePath") + "GroupCostQuotations/" + di.TeamName + "_详细报批费用.xls";
  20260. var ws = designer.Workbook.Worksheets[0];
  20261. foreach (var Rowindex in hideRowsList)
  20262. {
  20263. ws.Cells.HideRows(Rowindex, 2);
  20264. }
  20265. designer.Process();
  20266. designer.Workbook.Save(savePaht);
  20267. return Ok(JsonView(true, "生成成功!", new
  20268. {
  20269. Url = AppSettingsHelper.Get("ExcelBaseUrl") + savePaht.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelFtpPath"))
  20270. }));
  20271. }
  20272. private void MatchRooms(ref Dictionary<string, int> hotelRooms, ref Dictionary<string, int> flights, string[] roomTypes, string flightType, ref Dictionary<string, int> result)
  20273. {
  20274. foreach (var roomType in roomTypes)
  20275. {
  20276. while (hotelRooms[roomType] > 0 && flights[flightType] > 0)
  20277. {
  20278. hotelRooms[roomType]--;
  20279. flights[flightType]--;
  20280. if (roomType == "TBR")
  20281. {
  20282. flights[flightType]--; // 双人间在减少1
  20283. }
  20284. string key = flightType + roomType;
  20285. if (result.Keys.Contains(key))
  20286. {
  20287. result[key]++;
  20288. }
  20289. else
  20290. {
  20291. result.Add(key, 1);
  20292. }
  20293. }
  20294. }
  20295. }
  20296. private class AirHotelPrice
  20297. {
  20298. public string Name { get; set; }
  20299. public decimal Price { get; set; }
  20300. public int Count { get; set; }
  20301. }
  20302. /// <summary>
  20303. /// 团组系数设置
  20304. /// </summary>
  20305. /// <param name="dto"></param>
  20306. /// <returns></returns>
  20307. [HttpPost]
  20308. public async Task<IActionResult> QueryGroupCostCoefficient(QueryGroupCostCoefficientDto dto)
  20309. {
  20310. var di = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  20311. .FirstAsync(x => x.Id == dto.Diid && x.IsDel == 0);
  20312. if (di == null)
  20313. {
  20314. return Ok(JsonView(false, "团组不存在!"));
  20315. }
  20316. //var firstExpression = Expressionable.Create<Grp_GroupCostParameter>()
  20317. // .And(x => x.CostType == "A" && x.DiId == di.Id && x.IsDel == 0);
  20318. //var groupCostMainPrice = await _sqlSugar.Queryable<Grp_GroupCostParameter>().
  20319. // FirstAsync(firstExpression.ToExpression());
  20320. #region JSON
  20321. string hcpJson = @"
  20322. [
  20323. {
  20324. ""min"": 1,
  20325. ""max"": 500,
  20326. ""value"": 1.50
  20327. },
  20328. {
  20329. ""min"": 501,
  20330. ""max"": 1000,
  20331. ""value"": 1.40
  20332. },
  20333. {
  20334. ""min"": 1001,
  20335. ""max"": 2000,
  20336. ""value"": 1.35
  20337. }
  20338. ]";
  20339. #endregion
  20340. var hcpPriceRange = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PriceRange>>(hcpJson);
  20341. List<(Predicate<decimal>, decimal)> hcpSwitchDictionary = hcpPriceRange
  20342. .Select(pr => (new Predicate<decimal>(x => x >= pr.Min && x <= pr.Max), pr.Value))
  20343. .ToList();
  20344. List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)> jjcSwitchDictionary =
  20345. new List<(Predicate<decimal>, List<(Predicate<decimal>, decimal)>)>();
  20346. //jjcSwitchDictionary.Add((new Predicate<decimal>(x => x >= 1 && x <= 3),
  20347. // new List<(Predicate<decimal>, decimal)>()
  20348. // {
  20349. // (new Predicate<decimal>(y => y >= 1000 && y <= 3000), 2.6M),
  20350. // (new Predicate<decimal>(y => y > 3000), 2.5M)
  20351. // }
  20352. // ));
  20353. #region 签证系数
  20354. var visaXS = 0.00M;
  20355. switch (dto.VisaCB)
  20356. {
  20357. case decimal n when (n > 1 && n < 500):
  20358. switch (dto.VisaRS)
  20359. {
  20360. case 2 or 3:
  20361. visaXS = 1.35M;
  20362. break;
  20363. case 4 or 5:
  20364. visaXS = 1.30M;
  20365. break;
  20366. case 6 or 7:
  20367. visaXS = 1.25M;
  20368. break;
  20369. case 8 or 9 or 10:
  20370. visaXS = 1.20M;
  20371. break;
  20372. case > 10:
  20373. visaXS = 1.15M;
  20374. break;
  20375. default:
  20376. visaXS = 0.00M;
  20377. break;
  20378. }
  20379. break;
  20380. case decimal n when (n >= 500 && n < 1000):
  20381. switch (dto.VisaRS)
  20382. {
  20383. case 2 or 3 or 4:
  20384. visaXS = 1.30M;
  20385. break;
  20386. case 5 or 6 or 7 or 8:
  20387. visaXS = 1.25M;
  20388. break;
  20389. case 9 or 10:
  20390. visaXS = 1.20M;
  20391. break;
  20392. case > 10:
  20393. visaXS = 1.15M;
  20394. break;
  20395. default:
  20396. visaXS = 0.00M;
  20397. break;
  20398. }
  20399. break;
  20400. default:
  20401. switch (dto.VisaRS)
  20402. {
  20403. case 2 or 3 or 4:
  20404. visaXS = 1.30M;
  20405. break;
  20406. case 5 or 6 or 7 or 8:
  20407. visaXS = 1.25M;
  20408. break;
  20409. case 9 or 10:
  20410. visaXS = 1.20M;
  20411. break;
  20412. case > 10:
  20413. visaXS = 1.15M;
  20414. break;
  20415. default:
  20416. visaXS = 0.00M;
  20417. break;
  20418. }
  20419. break;
  20420. }
  20421. #endregion
  20422. #region 火车系数
  20423. var hcpXS = 0.00M;
  20424. foreach (var (condition, result) in hcpSwitchDictionary)
  20425. {
  20426. if (condition(dto.HCPCB))
  20427. {
  20428. hcpXS = result;
  20429. break;
  20430. }
  20431. }
  20432. #endregion
  20433. #region 机票系数
  20434. #region 经济舱系数
  20435. var jjcXS = 0.00M;
  20436. switch (dto.JJCCB)
  20437. {
  20438. case decimal x when (x >= 1000 && x <= 3000):
  20439. jjcXS = 2.6M;
  20440. break;
  20441. case decimal x when (x >= 3001 && x <= 8000):
  20442. jjcXS = 2.3M;
  20443. break;
  20444. case decimal x when (x >= 8001 && x <= 15000):
  20445. jjcXS = 2.1M;
  20446. break;
  20447. case decimal x when (x >= 15001 && x <= 30000):
  20448. jjcXS = 1.95M;
  20449. break;
  20450. case > 30000:
  20451. jjcXS = 1.8M;
  20452. break;
  20453. default:
  20454. break;
  20455. }
  20456. #endregion
  20457. #region 公务舱系数
  20458. var gwcXS = 0.00M;
  20459. switch (dto.GWCCB)
  20460. {
  20461. case decimal x when (x >= 1000 && x <= 3000):
  20462. gwcXS = 2.5M;
  20463. break;
  20464. case decimal x when (x >= 3001 && x <= 8000):
  20465. gwcXS = 2.2M;
  20466. break;
  20467. case decimal x when (x >= 8001 && x <= 15000):
  20468. gwcXS = 2.0M;
  20469. break;
  20470. case decimal x when (x >= 15001 && x <= 30000):
  20471. gwcXS = 1.85M;
  20472. break;
  20473. case > 30000:
  20474. gwcXS = 1.7M;
  20475. break;
  20476. default:
  20477. break;
  20478. }
  20479. #endregion
  20480. #region 头等舱系数
  20481. var tdcXS = 0.00M;
  20482. switch (dto.TDCCB)
  20483. {
  20484. case > 70000:
  20485. tdcXS = 1.5M;
  20486. break;
  20487. default:
  20488. tdcXS = 1.9M;
  20489. break;
  20490. }
  20491. #endregion
  20492. #endregion
  20493. #region 酒店系数
  20494. Dictionary<decimal, List<string>> dic = new Dictionary<decimal, List<string>>()
  20495. {
  20496. {1.6M, new List<string>(){"新西兰","澳大利亚" }},
  20497. {1.5M, new List<string>(){"越南社会主义共和国",
  20498. "老挝",
  20499. "柬埔寨",
  20500. "泰国",
  20501. "缅甸",
  20502. "马来西亚",
  20503. //"新加坡",
  20504. "文莱达鲁萨兰",
  20505. "印度尼西亚",
  20506. "东帝汶"}},
  20507. {1.2M, new List<string>(){ "日本","新加坡","法国","意大利","荷兰"}},
  20508. };
  20509. #region SGR
  20510. var sgrXS = 1.25M;
  20511. #endregion
  20512. #region TBR
  20513. var tbrXS = 1.25M;
  20514. #endregion
  20515. #region JSES
  20516. var jsesXS = 1.25M;
  20517. #endregion
  20518. #region SUITE
  20519. var suiteXS = 1.25M;
  20520. #endregion
  20521. var countryArr = di.VisitCountry.Split("|");
  20522. foreach (var item in dic)
  20523. {
  20524. var extsisCount = item.Value.Where(x => countryArr.Contains(x))
  20525. .Count();
  20526. if (extsisCount > 0)
  20527. {
  20528. jsesXS = item.Key;
  20529. sgrXS = item.Key;
  20530. tbrXS = item.Key;
  20531. suiteXS = item.Key;
  20532. }
  20533. }
  20534. #endregion
  20535. #region 地接系数
  20536. var djXS = 0.00M;
  20537. switch (dto.DJRS)
  20538. {
  20539. case 2 or 3:
  20540. djXS = 2.65M;
  20541. break;
  20542. case 4:
  20543. djXS = 2.6M;
  20544. break;
  20545. case 5 or 6:
  20546. djXS = 2.5M;
  20547. break;
  20548. case 7 or 8:
  20549. djXS = 2.4M;
  20550. break;
  20551. case 9 or 10:
  20552. djXS = 2.3M;
  20553. break;
  20554. case 11:
  20555. djXS = 2.2M;
  20556. break;
  20557. case 12:
  20558. djXS = 2.1M;
  20559. break;
  20560. case 13 or 14:
  20561. djXS = 2M;
  20562. break;
  20563. case 15:
  20564. djXS = 1.9M;
  20565. break;
  20566. case 16 or 17 or 18:
  20567. djXS = 1.8M;
  20568. break;
  20569. case 19 or 20:
  20570. djXS = 1.7M;
  20571. break;
  20572. }
  20573. #endregion
  20574. #region 零用金系数
  20575. var lyjXS = 0.00M;
  20576. switch (dto.LYJRS)
  20577. {
  20578. case 2:
  20579. lyjXS = 1.25M;
  20580. break;
  20581. case 3 or 4 or 5:
  20582. lyjXS = 1.2M;
  20583. break;
  20584. case int number when (number > 5 && number < 10):
  20585. lyjXS = 1.15M;
  20586. break;
  20587. case > 10:
  20588. lyjXS = 1.1M;
  20589. break;
  20590. default:
  20591. break;
  20592. }
  20593. #endregion
  20594. return Ok(JsonView(true, "查询成功", new ArrayList()
  20595. {
  20596. new { label = "火车票系数", value = hcpXS, key = "hcpXS" },
  20597. new { label = "经济舱系数", value = jjcXS, key = "jjcXS" },
  20598. new { label = "公务舱系数", value = gwcXS, key = "gwcXS" },
  20599. new { label = "头等舱系数", value = tdcXS, key = "tdcXS" },
  20600. new { label = "SGR系数", value = sgrXS, key = "sgrXS" },
  20601. new { label = "TBR系数", value = tbrXS, key = "tbrXS" },
  20602. new { label = "JSES系数", value = jsesXS, key = "jsesXS" },
  20603. new { label = "SUITE系数", value = suiteXS, key = "suiteXS" },
  20604. new { label = "地接系数", value = djXS, key = "djXS" },
  20605. new { label = "零用金系数", value = lyjXS, key = "lyjXS" },
  20606. new { label = "公务系数", value = 2M, key = "gwXS" }
  20607. }));
  20608. }
  20609. #endregion
  20610. #region 酒店预订 New 2023-12-28 17:45
  20611. /// <summary>
  20612. /// 酒店预订
  20613. /// 酒店费用列表 根据团组Id查询
  20614. /// </summary>
  20615. /// <param name="_dto"></param>
  20616. /// <returns></returns>
  20617. [HttpPost]
  20618. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20619. public async Task<IActionResult> PostHotelReservationsItemsByDiId(HotelReservationItemDto _dto)
  20620. {
  20621. #region 参数验证
  20622. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20623. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20624. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20625. #region 团组操作权限验证 76 酒店预定模块
  20626. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20627. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20628. #endregion
  20629. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20630. #region 页面操作权限验证
  20631. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20632. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20633. #endregion
  20634. #endregion
  20635. return Ok(await _hotelPriceRep.ItemsByDiId(_dto.PortType, _dto.DiId));
  20636. }
  20637. /// <summary>
  20638. /// 酒店预订
  20639. /// 基础数据
  20640. /// </summary>
  20641. /// <param name="_dto"></param>
  20642. /// <returns></returns>
  20643. [HttpPost]
  20644. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20645. public async Task<IActionResult> PostHotelReservationsBasicsDataInit(HotelReservationBasicsDataInitDto _dto)
  20646. {
  20647. #region 参数验证
  20648. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20649. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20650. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20651. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20652. #region 页面操作权限验证
  20653. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20654. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20655. #endregion
  20656. #region 团组操作权限验证 76 酒店预定模块
  20657. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20658. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20659. #endregion
  20660. #endregion
  20661. return Ok(await _hotelPriceRep.BasicsDataInit(_dto.PortType, _dto.DiId));
  20662. }
  20663. /// <summary>
  20664. /// 酒店预订
  20665. /// 创建 入住卷号码
  20666. /// </summary>
  20667. /// <param name="_dto"></param>
  20668. /// <returns></returns>
  20669. [HttpPost]
  20670. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20671. public async Task<IActionResult> PostHotelReservationsCreateCheckVolumeNo(HotelReservationBasicsDataInitDto _dto)
  20672. {
  20673. #region 参数验证
  20674. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20675. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20676. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20677. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20678. #region 页面操作权限验证
  20679. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20680. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20681. #endregion
  20682. #region 团组操作权限验证 76 酒店预定模块
  20683. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20684. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20685. #endregion
  20686. #endregion
  20687. Result data = await _hotelPriceRep.CreateCheckVolumeNo(_dto.DiId);
  20688. if (data.Code != 0)
  20689. {
  20690. return Ok(JsonView(false, data.Msg));
  20691. }
  20692. return Ok(JsonView(true, data.Msg, data.Data));
  20693. }
  20694. /// <summary>
  20695. /// 酒店预订
  20696. /// 详情
  20697. /// </summary>
  20698. /// <param name="_dto"></param>
  20699. /// <returns></returns>
  20700. [HttpPost]
  20701. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20702. public async Task<IActionResult> PostHotelReservationsDetails(HotelReservationsDetailsDto _dto)
  20703. {
  20704. #region 参数验证
  20705. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入正确的UserId参数"));
  20706. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20707. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入正确的DiId参数"));
  20708. #region 团组操作权限验证 76 酒店预定模块
  20709. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20710. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20711. #endregion
  20712. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20713. #region 页面操作权限验证
  20714. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20715. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  20716. #endregion
  20717. #endregion
  20718. return Ok(await _hotelPriceRep.Details(_dto.PortType, _dto.Id));
  20719. }
  20720. /// <summary>
  20721. /// 酒店预订
  20722. /// Add Or Edit
  20723. /// </summary>
  20724. /// <param name="_dto"></param>
  20725. /// <returns></returns>
  20726. [HttpPost]
  20727. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20728. public async Task<IActionResult> PostHotelReservationsAddOrEdit(HotelReservationsAddOrEditDto _dto)
  20729. {
  20730. #region 参数验证
  20731. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20732. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20733. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20734. #region 团组操作权限验证 76 酒店预定模块
  20735. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20736. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20737. #endregion
  20738. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20739. #region 页面操作权限验证
  20740. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20741. if (_dto.Id == 0) // Add
  20742. {
  20743. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  20744. }
  20745. else if (_dto.Id > 1) // Edit
  20746. {
  20747. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  20748. }
  20749. else return Ok(JsonView(false, "请输入正确的数据Id!"));
  20750. #endregion
  20751. #endregion
  20752. JsonView _view = await _hotelPriceRep.AddOrEdit(_dto);
  20753. if (_view.Code != 200)
  20754. {
  20755. return Ok(_view);
  20756. }
  20757. #region 成本无酒店价格数据进入超支
  20758. _sqlSugar.BeginTran();
  20759. var start_Bool = DateTime.TryParse(_dto.CheckInDate, out DateTime start_Time);
  20760. var end_Bool = DateTime.TryParse(_dto.CheckOutDate, out DateTime end_Time);
  20761. var groupCost = _sqlSugar.Queryable<Grp_GroupCost>().Where(x => x.Diid == _dto.DiId && x.IsDel == 0).ToList();
  20762. for (int i = 0; i < groupCost.Count; i++)
  20763. {
  20764. if (groupCost[i].Date.IsNullOrWhiteSpace() && i != 0)
  20765. {
  20766. groupCost[i].Date = groupCost[i - 1].Date;
  20767. }
  20768. }
  20769. var groupCost_Grp = groupCost.GroupBy(x => x.Date).ToList();
  20770. List<Fin_GroupExtraCostDto_OP> extraCostList = new
  20771. List<Fin_GroupExtraCostDto_OP>();
  20772. if (start_Bool && end_Bool)
  20773. {
  20774. while (start_Time < end_Time)
  20775. {
  20776. foreach (var item in groupCost_Grp)
  20777. {
  20778. if (DateTime.TryParse(item.Key, out DateTime cost_Time))
  20779. {
  20780. if (DateTime.Compare(start_Time, cost_Time) == 0 && item.Sum(x => x.SGR + x.Suite + x.TBR + x.JS_ES) == 0)
  20781. {
  20782. extraCostList.Add(new
  20783. Fin_GroupExtraCostDto_OP
  20784. {
  20785. Area = _dto.AreaId,
  20786. coefficient = 1.5M,
  20787. createUser = _dto.UserId,
  20788. currency = _dto.CardPriceCurrency,
  20789. diId = _dto.DiId,
  20790. ManagerConfirm = 0,
  20791. SupervisorConfirm = 0,
  20792. SYsupervisorConfirm = 0,
  20793. editType = 1,
  20794. PortType = 1,
  20795. price = _dto.CardPrice,
  20796. PriceCount = 1,
  20797. priceType = 1027,
  20798. priceDetailType = 1044,
  20799. PriceDt = start_Time.ToString("yyyy-MM-dd"),
  20800. priceName = $"酒店超支费用-酒店导入-({start_Time.ToString("yyyy/MM/dd")})",
  20801. });
  20802. }
  20803. }
  20804. }
  20805. start_Time = start_Time.AddDays(1);
  20806. }
  20807. }
  20808. if (extraCostList.Any())
  20809. {
  20810. await _carTouristGuideGroundRep.GroupExtraCost_OperatorList(extraCostList);
  20811. }
  20812. _sqlSugar.CommitTran();
  20813. #endregion
  20814. #region 应用推送
  20815. try
  20816. {
  20817. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  20818. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  20819. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  20820. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  20821. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  20822. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  20823. var diId = _dto.DiId;
  20824. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20825. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20826. #region 操作记录
  20827. var opInfo = new Crm_TableOperationRecord()
  20828. {
  20829. TableName = "Grp_HotelReservations",
  20830. PortType = _dto.PortType,
  20831. DataId = hotelId,
  20832. CreateUserId = _dto.UserId
  20833. };
  20834. //var opStatus = OperationEnum.NoOperation;
  20835. if (_dto.Id < 1) //添加操作
  20836. {
  20837. opInfo.OperationItem = OperationEnum.Add;
  20838. }
  20839. else if (_dto.Id > 0)
  20840. {
  20841. opInfo.OperationItem = OperationEnum.Edit;
  20842. }
  20843. string opRemark = string.Empty;
  20844. if (ccpInfo != null)
  20845. {
  20846. // USD 1211.86、 CNY 8761.75、汇率:7.2300
  20847. var currency = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0 && x.Id == ccpInfo.PaymentCurrency).First()?.Name;
  20848. var cnyPrice = ccpInfo.PayMoney * ccpInfo.DayRate;
  20849. opRemark = $"{currency} {ccpInfo.PayMoney.ToString("#0.00")}、CNY {cnyPrice.ToString("#0.00")}、汇率:{ccpInfo.DayRate.ToString("#0.0000")}";
  20850. }
  20851. opInfo.Remark = opRemark;
  20852. await _tableorRep.AddAsync(opInfo);
  20853. #endregion
  20854. _logger.LogInformation($"【iOS推送通知Exception】Begin");
  20855. //2024-10-21 新增LZ UID
  20856. var userIds = new List<int>() { 21 };
  20857. string title = $"费用审核";
  20858. string content = "";
  20859. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20860. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20861. try
  20862. {
  20863. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "76" };
  20864. await APNsTools.iOS_PushNotifications1("051", title, "", content, true, "ExpenseAuditWebView", h5);
  20865. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】Start");
  20866. //var iosRes = await APNsTools.iOS_PushNotifications("051", title, "", content);
  20867. //Logs($"【iOS推送通知PostHotelReservationsAddOrEdit】End Response:[{JsonConvert.SerializeObject(iosRes)}]");
  20868. }
  20869. catch (Exception ex)
  20870. {
  20871. Logs($"【iOS推送通知-PostHotelReservationsAddOrEdit-Exception】[{ex.Message}]");
  20872. }
  20873. }
  20874. catch (Exception ex)
  20875. {
  20876. Logs($"【iOS推送通知Exception】【{ex.Message}】");
  20877. }
  20878. try
  20879. {
  20880. //int ccpId = (int)_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null);
  20881. //int sign = (int)_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null);
  20882. //int hotelId = (int)_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null);
  20883. int ccpId = Convert.ToInt32(_view.Data.GetType().GetProperty("ccpId").GetValue(_view.Data, null) ?? 0);
  20884. int sign = Convert.ToInt32(_view.Data.GetType().GetProperty("sign").GetValue(_view.Data, null) ?? 0);
  20885. int hotelId = Convert.ToInt32(_view.Data.GetType().GetProperty("hotelId").GetValue(_view.Data, null) ?? 0);
  20886. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  20887. //自动审核
  20888. var autoAdit = await _feeAuditRep.FeeAutomaticAudit(1, _dto.DiId, hotelId);
  20889. //if (autoAdit.Code != 200) _view.Msg += $"\r\n{autoAdit.Msg}";
  20890. _logger.LogInformation($"【酒店自动审核】【{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}】执行调用 调用结果:{JsonConvert.SerializeObject(autoAdit)}");
  20891. //2024-10-21 新增LZ UID
  20892. var userIds = new List<int>() { 21 };
  20893. string title = $"系统通知";
  20894. var diId = _dto.DiId;
  20895. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  20896. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  20897. string content = "";
  20898. if (_dto.Id == 0) content = $"[新增-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20899. else if (_dto.Id > 0) content = $"[更新-酒店费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  20900. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  20901. }
  20902. catch (Exception ex)
  20903. {
  20904. }
  20905. #endregion
  20906. return Ok(_view);
  20907. }
  20908. /// <summary>
  20909. /// 酒店自动审核测试
  20910. /// Add Or Edit
  20911. /// </summary>
  20912. /// <param name="diid"></param>
  20913. /// <param name="dataId"></param>
  20914. /// <returns></returns>
  20915. [HttpPost]
  20916. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20917. public async Task<IActionResult> PostHotelAutoAuditTest(int diid, int dataId)
  20918. {
  20919. #region 应用推送
  20920. try
  20921. {
  20922. //自动审核
  20923. await _feeAuditRep.FeeAutomaticAudit(1, diid, dataId);
  20924. }
  20925. catch (Exception ex)
  20926. {
  20927. return Ok(JsonView(false, ex.Message));
  20928. }
  20929. #endregion
  20930. return Ok(JsonView(false, "操作成功"));
  20931. }
  20932. /// <summary>
  20933. /// 酒店预订
  20934. /// Del
  20935. /// </summary>
  20936. /// <param name="_dto"></param>
  20937. /// <returns></returns>
  20938. [HttpPost]
  20939. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20940. public async Task<IActionResult> PostHotelReservationsDel(HotelReservationsDelDto _dto)
  20941. {
  20942. #region 参数验证
  20943. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20944. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20945. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20946. #region 团组操作权限验证 76 酒店预定模块
  20947. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20948. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20949. #endregion
  20950. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20951. #region 页面操作权限验证
  20952. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20953. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  20954. #endregion
  20955. #endregion
  20956. var data = await _hotelPriceRep.Del(_dto.Id, _dto.UserId);
  20957. #region 操作记录
  20958. await _tableorRep.AddAsync(new Crm_TableOperationRecord()
  20959. {
  20960. TableName = "Grp_HotelReservations",
  20961. PortType = _dto.PortType,
  20962. OperationItem = OperationEnum.Del,
  20963. DataId = _dto.Id,
  20964. CreateUserId = _dto.UserId
  20965. });
  20966. #endregion
  20967. return Ok(data);
  20968. }
  20969. /// <summary>
  20970. /// 酒店预订
  20971. /// 生成VOUCHER
  20972. /// 2024.05.06 之前版本
  20973. /// </summary>
  20974. /// <param name="_dto"></param>
  20975. /// <returns></returns>
  20976. [HttpPost]
  20977. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  20978. public async Task<IActionResult> PostHotelReservationsCreateVoucherOld(HotelReservationsCreateVoucherDto _dto)
  20979. {
  20980. try
  20981. {
  20982. #region 参数验证
  20983. if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  20984. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  20985. if (_dto.DiId < 1) return Ok(JsonView(false, "团组Id为空"));
  20986. if (_dto.Id < 1) return Ok(JsonView(false, "Id为空"));
  20987. #region 团组操作权限验证 76 酒店预定模块
  20988. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  20989. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  20990. #endregion
  20991. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  20992. #region 页面操作权限验证
  20993. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  20994. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  20995. #endregion
  20996. #endregion
  20997. Grp_HotelReservations hr = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.Id == _dto.Id).FirstAsync();
  20998. //判断数据是否完整
  20999. if (hr != null)
  21000. {
  21001. if (!string.IsNullOrEmpty(hr.DetermineNo))
  21002. {
  21003. string strFileName = "HotelStatement/";
  21004. Grp_DelegationInfo dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  21005. if (dele != null)
  21006. strFileName += dele.TourCode;
  21007. //载入模板
  21008. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/酒店预订模板.doc";
  21009. Document doc = new Document(sss);
  21010. DocumentBuilder builder = new DocumentBuilder(doc);
  21011. #region 替换Word模板书签内容
  21012. //这里可以创建个DataTable循环添加书签的值,这里提示一下就不多做修改了
  21013. //入住卷预定号码
  21014. if (doc.Range.Bookmarks["VNO"] != null)
  21015. {
  21016. Bookmark mark = doc.Range.Bookmarks["VNO"];
  21017. mark.Text = hr.CheckNumber;
  21018. }
  21019. //酒店时间
  21020. if (doc.Range.Bookmarks["Date"] != null)
  21021. {
  21022. Bookmark mark = doc.Range.Bookmarks["Date"];
  21023. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  21024. }
  21025. //团号
  21026. if (doc.Range.Bookmarks["TNo"] != null)
  21027. {
  21028. Bookmark mark = doc.Range.Bookmarks["TNo"];
  21029. mark.Text = dele.TourCode;
  21030. }
  21031. //预定号码
  21032. if (doc.Range.Bookmarks["BookingId"] != null)
  21033. {
  21034. Bookmark mark = doc.Range.Bookmarks["BookingId"];
  21035. mark.Text = hr.ReservationsNo;
  21036. }
  21037. if (doc.Range.Bookmarks["HotelConfirmNo"] != null)
  21038. {
  21039. Bookmark mark = doc.Range.Bookmarks["HotelConfirmNo"];
  21040. mark.Text = hr.DetermineNo;
  21041. }
  21042. //酒店城市
  21043. if (doc.Range.Bookmarks["City"] != null)
  21044. {
  21045. Bookmark mark = doc.Range.Bookmarks["City"];
  21046. mark.Text = hr.City;
  21047. }
  21048. //酒店名称
  21049. if (doc.Range.Bookmarks["HName"] != null)
  21050. {
  21051. Bookmark mark = doc.Range.Bookmarks["HName"];
  21052. mark.Text = hr.HotelName;
  21053. }
  21054. //酒店地址
  21055. if (doc.Range.Bookmarks["Address"] != null)
  21056. {
  21057. Bookmark mark = doc.Range.Bookmarks["Address"];
  21058. mark.Text = hr.HotelAddress;
  21059. }
  21060. //酒店电话
  21061. if (doc.Range.Bookmarks["Tel"] != null)
  21062. {
  21063. Bookmark mark = doc.Range.Bookmarks["Tel"];
  21064. mark.Text = hr.HotelTel;
  21065. }
  21066. //酒店传真
  21067. if (doc.Range.Bookmarks["Fax"] != null)
  21068. {
  21069. Bookmark mark = doc.Range.Bookmarks["Fax"];
  21070. if (!string.IsNullOrWhiteSpace(hr.HotelFax))
  21071. {
  21072. mark.Text = hr.HotelFax;
  21073. }
  21074. }
  21075. //入住时间
  21076. if (doc.Range.Bookmarks["CIn"] != null)
  21077. {
  21078. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  21079. Bookmark mark = doc.Range.Bookmarks["CIn"];
  21080. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year;
  21081. }
  21082. //退房时间
  21083. if (doc.Range.Bookmarks["COut"] != null)
  21084. {
  21085. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  21086. Bookmark mark = doc.Range.Bookmarks["COut"];
  21087. mark.Text = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  21088. }
  21089. //客户名称
  21090. if (doc.Range.Bookmarks["GName"] != null)
  21091. {
  21092. string guestName = "";
  21093. string[] clients = Array.Empty<string>();
  21094. if (hr.GuestName.Contains(","))
  21095. {
  21096. clients = hr.GuestName.Split(",");
  21097. }
  21098. else
  21099. {
  21100. clients = new string[] { hr.GuestName };
  21101. }
  21102. List<int> clientIds_int = new List<int>();
  21103. if (clients.Length > 0)
  21104. {
  21105. foreach (var item in clients)
  21106. {
  21107. if (item.IsNumeric())
  21108. {
  21109. clientIds_int.Add(int.Parse(item));
  21110. }
  21111. }
  21112. }
  21113. if (clientIds_int.Count > 0)
  21114. {
  21115. var _clientDatas = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && clientIds_int.Contains(it.Id)).ToList();
  21116. foreach (var client in _clientDatas)
  21117. {
  21118. //男
  21119. if (client.Sex == 0) guestName += $"Mr.";
  21120. //女
  21121. else if (client.Sex == 1) guestName += $"Ms.";
  21122. if (!String.IsNullOrEmpty(client.FirstName + client.LastName))
  21123. {
  21124. guestName += $"{string.Join("", client.FirstName.GetTotalPingYin()).ToUpper()} {string.Join("", client.LastName.GetTotalPingYin()).ToUpper()},";
  21125. }
  21126. //guestName += $"{client.Pinyin},";
  21127. }
  21128. if (guestName.Length > 0)
  21129. {
  21130. guestName = guestName.Substring(0, guestName.Length - 1);
  21131. }
  21132. }
  21133. else
  21134. {
  21135. guestName = hr.GuestName;
  21136. }
  21137. Bookmark mark = doc.Range.Bookmarks["GName"];
  21138. mark.Text = guestName;
  21139. }
  21140. //房间介绍
  21141. if (doc.Range.Bookmarks["ROOM"] != null)
  21142. {
  21143. Bookmark mark = doc.Range.Bookmarks["ROOM"];
  21144. mark.Text = hr.RoomExplanation;
  21145. }
  21146. //报价描述
  21147. if (doc.Range.Bookmarks["NOTE"] != null)
  21148. {
  21149. Bookmark mark = doc.Range.Bookmarks["NOTE"];
  21150. Sys_SetData ss = _sqlSugar.Queryable<Sys_SetData>().First(a => a.Id == hr.ReservationsWebsite);
  21151. if (ss != null)
  21152. mark.Text = ss.Name;
  21153. }
  21154. //入住时间
  21155. if (doc.Range.Bookmarks["CheckIn"] != null)
  21156. {
  21157. DateTime dtCheckIn = Convert.ToDateTime(hr.CheckInDate);
  21158. Bookmark mark = doc.Range.Bookmarks["CheckIn"];
  21159. mark.Text = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  21160. }
  21161. //退房时间
  21162. if (doc.Range.Bookmarks["CheckOut"] != null)
  21163. {
  21164. DateTime dtCheckOut = Convert.ToDateTime(hr.CheckOutDate);
  21165. Bookmark mark = doc.Range.Bookmarks["CheckOut"];
  21166. mark.Text = " " + dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year;
  21167. }
  21168. //日期
  21169. if (doc.Range.Bookmarks["DT"] != null)
  21170. {
  21171. Bookmark mark = doc.Range.Bookmarks["DT"];
  21172. mark.Text = Convert.ToDateTime(hr.CreateTime).ToString("yyyy-MM-dd");
  21173. }
  21174. //名称
  21175. if (doc.Range.Bookmarks["VName"] != null)
  21176. {
  21177. Bookmark mark = doc.Range.Bookmarks["VName"];
  21178. mark.Text = hr.HotelName;
  21179. }
  21180. //号码
  21181. if (doc.Range.Bookmarks["VOUCHERNO"] != null)
  21182. {
  21183. Bookmark mark = doc.Range.Bookmarks["VOUCHERNO"];
  21184. mark.Text = hr.CheckNumber;
  21185. }
  21186. #endregion
  21187. strFileName += "VOUCHER.doc";
  21188. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  21189. doc.Save(fileDir);
  21190. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  21191. return Ok(JsonView(true, "操作成功!", Url));
  21192. }
  21193. else
  21194. {
  21195. return Ok(JsonView(false, "酒店确定号码未填写,无法生成Voucher!"));
  21196. }
  21197. }
  21198. else
  21199. {
  21200. return Ok(JsonView(false, "该条数据已删除或不存在!"));
  21201. }
  21202. }
  21203. catch (Exception ex)
  21204. {
  21205. return Ok(JsonView(false, ex.Message));
  21206. }
  21207. }
  21208. /// <summary>
  21209. /// 酒店预订
  21210. /// 生成VOUCHER
  21211. /// 2024.05.06 之后版本
  21212. /// </summary>
  21213. /// <param name="_dto"></param>
  21214. /// <returns></returns>
  21215. [HttpPost]
  21216. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21217. public async Task<IActionResult> PostHotelReservationsCreateVoucher(HotelReservationsCreateVoucherDto _dto)
  21218. {
  21219. #region 参数验证
  21220. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  21221. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  21222. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  21223. #region 团组操作权限验证 76 酒店预定模块
  21224. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  21225. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  21226. #endregion
  21227. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21228. #region 页面操作权限验证
  21229. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21230. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21231. #endregion
  21232. #endregion
  21233. List<Grp_HotelReservations> hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToListAsync();
  21234. //判断数据是否完整
  21235. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  21236. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  21237. string strFileName = "HotelStatement/";
  21238. string guestNames = ""; //格式Mr.xxx Ms.xxx
  21239. List<HotelVoucherInfoView> vouchers = new List<HotelVoucherInfoView>();
  21240. #region 数据处理
  21241. List<int> guestIds = new List<int>();
  21242. //int index = 0;
  21243. foreach (var item in hrDtas)
  21244. {
  21245. if (item.GuestName.Contains(","))
  21246. {
  21247. string[] guestIdArr = item.GuestName.Split(',');
  21248. foreach (var guestIdStr in guestIdArr)
  21249. {
  21250. bool guestBool = int.TryParse(guestIdStr, out int guestId);
  21251. if (guestBool)
  21252. {
  21253. guestIds.Add(guestId);
  21254. }
  21255. }
  21256. }
  21257. else guestNames += item.GuestName;
  21258. var voucherInfo = new HotelVoucherInfoView()
  21259. {
  21260. HotelName = item.HotelName,
  21261. CheckInDate = item.CheckInDate,
  21262. CheckOutDate = item.CheckOutDate,
  21263. ConfirmationNumber = item.DetermineNo.Trim(),
  21264. RoomType = item.RoomExplanation
  21265. };
  21266. vouchers.Add(voucherInfo);
  21267. }
  21268. if (guestIds.Count > 0)
  21269. {
  21270. guestIds = guestIds.Distinct().ToList();
  21271. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0 && guestIds.Contains(it.Id)).ToListAsync();
  21272. if (guestDatas.Count > 0)
  21273. {
  21274. guestNames = "";
  21275. foreach (var guest in guestDatas)
  21276. {
  21277. string guestName = "";
  21278. if (guest.Sex == 0) guestName += @"MR.";
  21279. else if (guest.Sex == 1) guestName += @"MS.";
  21280. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  21281. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  21282. guestNames += @$"{guestName.Trim()}、";
  21283. }
  21284. if (guestNames.Length > 0)
  21285. {
  21286. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  21287. }
  21288. }
  21289. }
  21290. #endregion
  21291. //载入模板
  21292. string sss = AppSettingsHelper.Get("WordBasePath") + "Template/Voucher-2024Versions.docx";
  21293. Document doc = new Document(sss);
  21294. DocumentBuilder builder = new DocumentBuilder(doc);
  21295. if (doc.Range.Bookmarks["GuestName"] != null)
  21296. {
  21297. Bookmark mark = doc.Range.Bookmarks["GuestName"];
  21298. mark.Text = guestNames;
  21299. }
  21300. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  21301. Aspose.Words.Tables.Table table = allTables[0] as Aspose.Words.Tables.Table;
  21302. vouchers = vouchers.OrderBy(it => it.CheckInDate).ToList();
  21303. for (int i = 1; i <= vouchers.Count; i++)
  21304. {
  21305. HotelVoucherInfoView hviv = vouchers[i - 1];
  21306. builder.MoveToCell(0, i, 0, 0);
  21307. builder.Write(hviv.HotelName);
  21308. builder.MoveToCell(0, i, 1, 0);
  21309. builder.Write(hviv.CheckInDate);
  21310. builder.MoveToCell(0, i, 2, 0);
  21311. builder.Write(hviv.CheckOutDate);
  21312. builder.MoveToCell(0, i, 3, 0);
  21313. builder.Write(hviv.RoomType);
  21314. builder.MoveToCell(0, i, 4, 0);
  21315. builder.Write(hviv.ConfirmationNumber);
  21316. }
  21317. //删除多余行
  21318. int currRowIndex = vouchers.Count + 1;
  21319. int delRows = 21 - currRowIndex;
  21320. if (delRows > 0)
  21321. {
  21322. for (int i = 0; i < delRows; i++)
  21323. {
  21324. table.Rows.RemoveAt(currRowIndex);
  21325. //cultivateRowIndex++;
  21326. }
  21327. }
  21328. strFileName += "VOUCHER.docx";
  21329. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  21330. doc.Save(fileDir);
  21331. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  21332. return Ok(JsonView(true, "操作成功!", Url));
  21333. }
  21334. /// <summary>
  21335. /// 酒店预订
  21336. /// 生成VOUCHER 批量生成
  21337. /// New
  21338. /// </summary>
  21339. /// <param name="_dto"></param>
  21340. /// <returns></returns>
  21341. [HttpPost]
  21342. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21343. public async Task<IActionResult> PostHotelReservationsCreateVoucherBatchNew(HotelReservationsCreateVoucherDto _dto)
  21344. {
  21345. #region 参数验证
  21346. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  21347. if (_dto.PageId < 1) _dto.PageId = 28;
  21348. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  21349. #region 团组操作权限验证 76 酒店预定模块
  21350. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  21351. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  21352. #endregion
  21353. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21354. #region 页面操作权限验证
  21355. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21356. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21357. #endregion
  21358. #endregion
  21359. var hrDtas = await _sqlSugar.Queryable<Grp_HotelReservations>()
  21360. .Where(it => it.IsDel == 0 && it.DiId == _dto.DiId)
  21361. .OrderBy(x => x.CheckInDate)
  21362. .ToListAsync();
  21363. //判断数据是否完整
  21364. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "请先录入酒店预订信息!", ""));
  21365. string strFileName = "HotelStatement/";
  21366. var dele = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == _dto.DiId).FirstAsync();
  21367. if (dele != null)
  21368. strFileName += $"{dele?.TeamName ?? ""}_{dele.TourCode}_";
  21369. var guestDatas = await _sqlSugar.Queryable<Crm_DeleClient>()
  21370. .Select(x => new Crm_DeleClient { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Pinyin = x.Pinyin })
  21371. .Where(it => it.IsDel == 0)
  21372. .ToListAsync();
  21373. foreach (var item in guestDatas) EncryptionProcessor.DecryptProperties(item);
  21374. for (int i = 0; i < hrDtas.Count; i++)
  21375. {
  21376. string guestNames = string.Empty;
  21377. List<int> guestIds = new List<int>();
  21378. var item = hrDtas[i];
  21379. //处理客户姓名
  21380. if (item.GuestName.Contains(","))
  21381. {
  21382. string[] guestIdArr = item.GuestName.Split(',');
  21383. foreach (var guestIdStr in guestIdArr)
  21384. if (int.TryParse(guestIdStr, out int guestId))
  21385. guestIds.Add(guestId);
  21386. }
  21387. else
  21388. {
  21389. bool guestIdBool = int.TryParse(item.GuestName, out int guestId);
  21390. if (guestIdBool)
  21391. {
  21392. guestIds.Add(guestId);
  21393. }
  21394. //NaN
  21395. if (item.GuestName.Contains("NaN"))
  21396. {
  21397. guestNames += item.GuestName.Replace("NaN", "").Replace(",", "");
  21398. }
  21399. }
  21400. if (guestIds.Count > 0)
  21401. {
  21402. guestIds = guestIds.Distinct().ToList();
  21403. var guestDatas1 = guestDatas.Where(it => guestIds.Contains(it.Id)).ToList();
  21404. if (guestDatas1.Count > 0)
  21405. {
  21406. guestNames = "";
  21407. foreach (var guest in guestDatas1)
  21408. {
  21409. string guestName = "";
  21410. if (guest.Sex == 0) guestName += @"MR.";
  21411. else if (guest.Sex == 1) guestName += @"MS.";
  21412. if (guest.Pinyin == null) guestName += $"{string.Join("", guest.LastName.GetTotalPingYin()).ToUpper()}/{string.Join("", guest.FirstName.GetTotalPingYin()).ToUpper()}";
  21413. else guestName += @$"{guest.Pinyin.Replace(" ", "")}";
  21414. guestNames += @$"{guestName.Trim()}、";
  21415. }
  21416. if (guestNames.Length > 0)
  21417. {
  21418. guestNames = guestNames.Substring(0, guestNames.Length - 1);
  21419. }
  21420. }
  21421. }
  21422. //if (!string.IsNullOrEmpty(guestNames))
  21423. //{
  21424. hrDtas[i].GuestName = guestNames;
  21425. //}
  21426. }
  21427. strFileName += $"VOUCHER_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.docx";
  21428. Document doc = new Document();
  21429. DocumentBuilder builder = new DocumentBuilder(doc);
  21430. try
  21431. {
  21432. builder.MoveToDocumentStart();
  21433. foreach (var item in hrDtas)
  21434. {
  21435. //标题
  21436. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  21437. builder.ParagraphFormat.LineSpacing = 1;
  21438. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21439. builder.ParagraphFormat.Style.Font.Size = 9;
  21440. builder.ParagraphFormat.Style.Font.Bold = true;
  21441. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21442. builder.Writeln(@$"ACCOMMODATION VOUCHER");
  21443. builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Title;
  21444. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  21445. builder.ParagraphFormat.LineSpacing = 1;
  21446. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21447. builder.ParagraphFormat.Style.Font.Size = 9;
  21448. builder.ParagraphFormat.Style.Font.Bold = true;
  21449. builder.Writeln(@$"VOUCHER No:{item.CheckNumber} DATE: {item.CreateTime.ToString("yyyy-MM-dd")}");
  21450. builder.StartTable();
  21451. // 设置边框颜色
  21452. builder.CellFormat.Borders.Top.Color = System.Drawing.Color.Black;
  21453. //设置边框样式
  21454. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Dot;
  21455. //表格
  21456. #region 第一行
  21457. builder.InsertCell();
  21458. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21459. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21460. //builder.CellFormat.AllowAutoFit = false;
  21461. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21462. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21463. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21464. builder.CellFormat.WrapText = true; //自动换行
  21465. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21466. builder.RowFormat.AllowBreakAcrossPages = false; //文字自适应大小
  21467. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21468. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21469. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21470. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21471. builder.Write("TOUR NO:");
  21472. builder.InsertCell();
  21473. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21474. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21475. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21476. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21477. builder.ParagraphFormat.Style.Font.Bold = false;
  21478. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21479. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21480. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21481. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21482. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21483. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21484. builder.Write($"{dele?.TourCode ?? "-"}");
  21485. builder.InsertCell();
  21486. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21487. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21488. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21489. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21490. builder.ParagraphFormat.Style.Font.Bold = false;
  21491. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21492. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21493. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21494. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21495. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21496. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21497. builder.Write($"CITY:");
  21498. builder.InsertCell();
  21499. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21500. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21501. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21502. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21503. builder.ParagraphFormat.Style.Font.Bold = false;
  21504. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21505. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21506. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21507. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21508. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21509. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21510. builder.Write($"{item.City}");
  21511. builder.EndRow();
  21512. #endregion
  21513. #region 第二行
  21514. builder.InsertCell();
  21515. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21516. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21517. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21518. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21519. builder.ParagraphFormat.Style.Font.Bold = false;
  21520. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21521. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21522. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21523. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21524. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21525. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21526. builder.Write("CONFIRMATION NO:");
  21527. builder.InsertCell();
  21528. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21529. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21530. builder.ParagraphFormat.Style.Font.Size = 8;
  21531. builder.ParagraphFormat.Style.Font.Bold = false;
  21532. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21533. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21534. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21535. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21536. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21537. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21538. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21539. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21540. builder.Write($"{item.DetermineNo}");
  21541. builder.InsertCell();
  21542. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21543. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21544. builder.InsertCell();
  21545. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21546. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21547. builder.EndRow();
  21548. #endregion
  21549. #region 第三行
  21550. builder.InsertCell();
  21551. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21552. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21553. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21554. builder.ParagraphFormat.Style.Font.Bold = false;
  21555. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21556. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21557. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21558. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21559. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21560. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21561. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21562. builder.Write($"HOTEL NAME:");
  21563. builder.InsertCell();
  21564. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21565. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21566. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21567. builder.ParagraphFormat.Style.Font.Bold = false;
  21568. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21569. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21570. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21571. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21572. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21573. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21574. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21575. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21576. builder.Write($"{item.HotelName}");
  21577. builder.InsertCell();
  21578. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21579. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21580. builder.InsertCell();
  21581. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21582. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21583. builder.EndRow();
  21584. #endregion
  21585. #region 第四行
  21586. builder.InsertCell();
  21587. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21588. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21589. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21590. builder.ParagraphFormat.Style.Font.Bold = false;
  21591. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21592. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21593. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21594. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21595. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21596. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21597. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21598. builder.Write($"HOTEL ADDRESS:");
  21599. builder.InsertCell();
  21600. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21601. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21602. builder.ParagraphFormat.Style.Font.Size = 8;
  21603. builder.ParagraphFormat.Style.Font.Bold = false;
  21604. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21605. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21606. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21607. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21608. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21609. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21610. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21611. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21612. builder.Write($"{item.HotelAddress}");
  21613. builder.InsertCell();
  21614. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21615. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21616. builder.InsertCell();
  21617. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21618. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21619. builder.EndRow();
  21620. #endregion
  21621. #region 第五行
  21622. builder.InsertCell();
  21623. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21624. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21625. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21626. builder.ParagraphFormat.Style.Font.Bold = false;
  21627. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21628. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21629. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21630. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21631. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21632. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21633. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21634. builder.Write("TEL:");
  21635. builder.InsertCell();
  21636. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21637. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21638. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21639. builder.ParagraphFormat.Style.Font.Bold = false;
  21640. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21641. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21642. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21643. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21644. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21645. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21646. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21647. builder.Write($"{item.HotelTel}");
  21648. builder.InsertCell();
  21649. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21650. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21651. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21652. builder.ParagraphFormat.Style.Font.Bold = false;
  21653. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21654. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21655. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21656. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21657. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21658. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21659. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21660. builder.Write($"FAX:");
  21661. builder.InsertCell();
  21662. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21663. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21664. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21665. builder.ParagraphFormat.Style.Font.Bold = false;
  21666. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21667. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21668. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21669. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21670. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21671. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21672. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21673. builder.Write($"{item.HotelFax}");
  21674. builder.EndRow();
  21675. #endregion
  21676. #region 第六行
  21677. builder.InsertCell();
  21678. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21679. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21680. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21681. builder.ParagraphFormat.Style.Font.Bold = false;
  21682. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21683. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21684. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21685. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21686. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21687. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21688. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21689. builder.Write("CHECK IN:");
  21690. builder.InsertCell();
  21691. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21692. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21693. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21694. builder.ParagraphFormat.Style.Font.Bold = false;
  21695. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21696. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21697. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21698. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21699. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21700. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21701. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21702. DateTime dtCheckIn = Convert.ToDateTime(item.CheckInDate);
  21703. string checkInStr = dtCheckIn.Day + " " + dtCheckIn.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckIn.Year + " ";
  21704. builder.Write($"{checkInStr}");
  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($"CHECK OUT:");
  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. DateTime dtCheckOut = Convert.ToDateTime(item.CheckOutDate);
  21731. string checkOutStr = dtCheckOut.Day + " " + dtCheckOut.ToString("MMMM", CultureInfo.GetCultureInfo("en-US")) + " " + dtCheckOut.Year + " ";
  21732. builder.Write($"{checkOutStr}");
  21733. builder.EndRow();
  21734. #endregion
  21735. #region 第七行
  21736. builder.InsertCell();
  21737. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21738. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21739. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21740. builder.ParagraphFormat.Style.Font.Bold = false;
  21741. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21742. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21743. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21744. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21745. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21746. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21747. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21748. builder.Write($"GUEST NAME:");
  21749. builder.InsertCell();
  21750. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21751. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21752. builder.ParagraphFormat.Style.Font.Size = 8;
  21753. builder.ParagraphFormat.Style.Font.Bold = false;
  21754. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21755. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21756. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21757. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21758. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21759. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21760. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21761. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21762. builder.Write($"{item.GuestName.Trim()}");
  21763. builder.InsertCell();
  21764. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21765. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21766. builder.InsertCell();
  21767. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21768. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21769. builder.EndRow();
  21770. #endregion
  21771. #region 第八行
  21772. builder.InsertCell();
  21773. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21774. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21775. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21776. builder.ParagraphFormat.Style.Font.Bold = false;
  21777. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21778. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21779. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21780. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21781. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21782. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21783. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21784. builder.Write($"ROOM TYPE:");
  21785. builder.InsertCell();
  21786. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21787. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21788. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21789. builder.ParagraphFormat.Style.Font.Bold = false;
  21790. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21791. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21792. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21793. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21794. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21795. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21796. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21797. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21798. builder.Write($"{item.RoomExplanation}");
  21799. builder.InsertCell();
  21800. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21801. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21802. builder.InsertCell();
  21803. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21804. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21805. builder.EndRow();
  21806. #endregion
  21807. #region 第九行
  21808. builder.InsertCell();
  21809. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21810. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21811. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21812. builder.ParagraphFormat.Style.Font.Bold = false;
  21813. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21814. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21815. builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;//对齐
  21816. builder.ParagraphFormat.SpaceBefore = 0; //设置段前间距 0
  21817. builder.ParagraphFormat.SpaceAfter = 0; //设置段后间距 0
  21818. builder.ParagraphFormat.LineSpacingRule = LineSpacingRule.Exactly; //设置行距 固定值
  21819. builder.ParagraphFormat.LineSpacing = 11; //设置固定的行距为11磅
  21820. builder.Write($"NOTE:");
  21821. builder.InsertCell();
  21822. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21823. builder.ParagraphFormat.Style.Font.Name = "微软雅黑";
  21824. builder.ParagraphFormat.Style.Font.Size = 7.5;
  21825. builder.ParagraphFormat.Style.Font.Bold = false;
  21826. builder.CellFormat.HorizontalMerge = CellMerge.None;
  21827. builder.CellFormat.FitText = true;//单元格内文字设为多行(默认为单行,会影响单元格宽)
  21828. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//对齐
  21829. builder.CellFormat.HorizontalMerge = CellMerge.First;
  21830. 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.");
  21831. builder.InsertCell();
  21832. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);//列宽 - 百分比
  21833. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21834. builder.InsertCell();
  21835. builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(30);//列宽 - 百分比
  21836. builder.CellFormat.HorizontalMerge = CellMerge.Previous;
  21837. builder.EndRow();
  21838. #endregion
  21839. builder.EndTable();
  21840. //换行
  21841. builder.Writeln("");
  21842. builder.Writeln("");
  21843. }
  21844. #region 获取文档中的所有表格 设置文字自适应
  21845. // 获取文档中的所有表格。
  21846. foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
  21847. {
  21848. // 遍历表格中的所有行。
  21849. foreach (Aspose.Words.Tables.Row row in table.Rows)
  21850. {
  21851. foreach (Cell cell in row.Cells)
  21852. {
  21853. Aspose.Words.Tables.CellFormat cellFormat = cell.CellFormat;
  21854. cellFormat.Width = 0;
  21855. }
  21856. }
  21857. }
  21858. #endregion
  21859. #region 设置页眉
  21860. builder.MoveToHeaderFooter(HeaderFooterType.HeaderPrimary);
  21861. string voucherHeaderPath = $"./Images/VoucherHeader.png";
  21862. if (System.IO.File.Exists(voucherHeaderPath))
  21863. {
  21864. byte[] imageBytes = System.IO.File.ReadAllBytes(voucherHeaderPath);
  21865. //Image image = Image.FromStream(imageBytes, ImageType.Png);
  21866. //builder.InsertImage(imageBytes, RelativeHorizontalPosition.Margin, 0, RelativeVerticalPosition.Margin, 0, 81, 36, WrapType.None);
  21867. Aspose.Words.Drawing.Shape shape = builder.InsertImage(imageBytes);
  21868. // 调整图片位置
  21869. shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page; // 将图片的水平位置设置为页面
  21870. shape.RelativeVerticalPosition = RelativeVerticalPosition.TopMargin; // 将图片的垂直位置设置为页眉上边距
  21871. shape.Top = 50; // 将图片距离页眉上边缘的距离
  21872. shape.Left = 0; // 将图片距离页面左边缘的距离
  21873. shape.Width = 81; // 设置图片宽度
  21874. shape.Height = 36; // 设置图片高度
  21875. }
  21876. //靠右
  21877. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  21878. //// 设置页脚上下边距
  21879. //builder.PageSetup.HeaderDistance = 42;
  21880. // 添加页眉线
  21881. Aspose.Words.Border borderHeader = null;
  21882. try
  21883. {
  21884. borderHeader = builder.ParagraphFormat.Borders.Bottom;
  21885. }
  21886. catch (Exception e)
  21887. {
  21888. // TODO Auto-generated catch block
  21889. //e.printStackTrace();
  21890. }
  21891. borderHeader.Shadow = true;
  21892. borderHeader.DistanceFromText = 2;
  21893. borderHeader.LineStyle = Aspose.Words.LineStyle.Single;
  21894. #endregion
  21895. }
  21896. catch (Exception ex)
  21897. {
  21898. }
  21899. var fileDir = AppSettingsHelper.Get("WordBasePath") + strFileName;
  21900. doc.Save(fileDir);
  21901. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/" + strFileName;
  21902. return Ok(JsonView(true, "操作成功!", Url));
  21903. }
  21904. /// <summary>
  21905. /// 酒店预订
  21906. /// 生成 预定成本 Excel
  21907. /// </summary>
  21908. /// <param name="_dto"></param>
  21909. /// <returns></returns>
  21910. [HttpPost]
  21911. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  21912. public async Task<IActionResult> PostHotelReservationsPredictedCostFileDownload(HotelReservations_PCFD_DTO _dto)
  21913. {
  21914. #region 参数验证
  21915. var vadalitor = new HotelReservations_PCFD_DTOFoalidator();
  21916. var vadalitorRes = await vadalitor.ValidateAsync(_dto);
  21917. if (!vadalitorRes.IsValid)
  21918. {
  21919. var errors = new StringBuilder();
  21920. foreach (var valid in vadalitorRes.Errors) errors.AppendLine(valid.ErrorMessage);
  21921. return Ok(JsonView(StatusCodes.Status400BadRequest, errors.ToString(), ""));
  21922. }
  21923. #region 团组操作权限验证 76 酒店预定模块
  21924. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  21925. if (groupAuthView.Code != 0) return Ok(JsonView(false, groupAuthView.Msg));
  21926. #endregion
  21927. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  21928. #region 页面操作权限验证
  21929. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  21930. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  21931. #endregion
  21932. #endregion
  21933. decimal _rate = 1.00M;
  21934. string _currency = string.Empty;
  21935. var currDatas = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.STid == 66).ToList();
  21936. var hrDtas = _sqlSugar.Queryable<Grp_HotelReservations>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  21937. if (hrDtas.Count < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "酒店预订费用未录入,不支持预定成本Excel导出", ""));
  21938. var hotelSubData = _sqlSugar.Queryable<Grp_HotelReservationsContent>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).ToList();
  21939. var ccpData = _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(it => it.IsDel == 0 && it.DIId == _dto.DiId && it.CTable == 76).ToList();
  21940. var _GroupCostParameter = _sqlSugar.Queryable<Grp_GroupCostParameter>().Where(it => it.IsDel == 0 && it.DiId == _dto.DiId).First();
  21941. //if (_GroupCostParameter == null) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用未录入,不支持预定成本Excel导出", ""));
  21942. if (_GroupCostParameter == null)
  21943. {
  21944. //return Ok(JsonView(StatusCodes.Status400BadRequest, "团组成本费用“币种为录入”未录入,不支持预定成本Excel导出", ""));
  21945. bool isIntType = int.TryParse(_currency, out int currId);
  21946. if (isIntType)
  21947. {
  21948. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  21949. }
  21950. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  21951. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  21952. if (currInfo == null)
  21953. {
  21954. //return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  21955. }
  21956. else _rate = currInfo.Rate;
  21957. if (!string.IsNullOrEmpty(_currency) && !_currency.ToUpper().Equals("CNY"))
  21958. {
  21959. _rate = _GroupCostParameter.Rate;
  21960. }
  21961. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  21962. //string strFileName = "HotelStatement/";
  21963. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  21964. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  21965. var rateDatas = new List<dynamic>();
  21966. #region 数据处理
  21967. foreach (var item in hrDtas)
  21968. {
  21969. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  21970. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  21971. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  21972. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  21973. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  21974. if (ccpInfo == null || roomInfo == null || breakfastInfo == null || governmentRentInfo == null || cityTaxInfo == null)
  21975. {
  21976. continue;
  21977. }
  21978. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  21979. if (string.IsNullOrEmpty(_currency)) _currency = $"CNY";
  21980. string singleRoomFeeStr = string.Empty,
  21981. doubleRoomFeeStr = string.Empty,
  21982. suiteRoomFeeStr = string.Empty,
  21983. otherRoomFeeStr = string.Empty,
  21984. payMoneyStr = string.Empty,
  21985. cardPriceStr = string.Empty;
  21986. if (roomCurr.Equals("CNY"))
  21987. {
  21988. rateDatas.Add(new { code = "CNY", rate = 1.0000 });
  21989. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  21990. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  21991. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  21992. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  21993. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? ""}";
  21994. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {currDatas.Find(it => it.Id == item.CardPriceCurrency)?.Name ?? ""}";
  21995. }
  21996. else
  21997. {
  21998. //singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  21999. //doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  22000. //suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  22001. //otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  22002. //payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  22003. //cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  22004. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  22005. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  22006. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  22007. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}\r\n{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}";
  22008. rateDatas.Add(new { code = roomCurr, rate = roomInfo.Rate });
  22009. var ccpPaymentCurrency = currDatas.Find(it => it.Id == ccpInfo?.PaymentCurrency)?.Name ?? "";
  22010. if (ccpPaymentCurrency.Equals("CNY"))
  22011. {
  22012. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} CNY";
  22013. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  22014. }
  22015. else
  22016. {
  22017. rateDatas.Add(new { code = ccpPaymentCurrency, rate = ccpInfo.DayRate });
  22018. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {ccpPaymentCurrency}\r\n{((ccpInfo.PayMoney * ccpInfo.DayRate) / _rate).ToString("#0.00")} CNY";
  22019. }
  22020. var hotelcardPriceCurrency = currDatas.Find(it => it.Id == item?.CardPriceCurrency)?.Name ?? "";
  22021. if (hotelcardPriceCurrency.Equals("CNY"))
  22022. {
  22023. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} CNY";
  22024. }
  22025. else
  22026. {
  22027. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {hotelcardPriceCurrency}\r\n{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} CNY";
  22028. }
  22029. }
  22030. string breakfastPriceStr = string.Empty,
  22031. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  22032. governmentRentStr = string.Empty,
  22033. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  22034. cityTaxStr = string.Empty,
  22035. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  22036. var breakfastCurrency1 = currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name;
  22037. if (!string.IsNullOrEmpty(breakfastCurrency1))
  22038. {
  22039. if (breakfastCurrency1.Equals("CNY"))
  22040. {
  22041. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  22042. }
  22043. else
  22044. {
  22045. rateDatas.Add(new { code = breakfastCurrency1, rate = breakfastInfo.Rate });
  22046. var breakfastPriceCny = breakfastInfo.Price * breakfastInfo.Rate;
  22047. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}\r\n{breakfastPriceCny.ToString("#0.00")} CNY";
  22048. }
  22049. }
  22050. else breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {breakfastCurrency1}";
  22051. var governmentRentCurrency1 = currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name;
  22052. if (!string.IsNullOrEmpty(governmentRentCurrency1))
  22053. {
  22054. if (governmentRentCurrency.Equals("CNY"))
  22055. {
  22056. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  22057. }
  22058. else
  22059. {
  22060. rateDatas.Add(new { code = governmentRentCurrency1, rate = governmentRentInfo.Rate });
  22061. var governmentRentCny = governmentRentInfo.Price * governmentRentInfo.Rate;
  22062. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}\r\n{governmentRentCny.ToString("#0.00")} CNY";
  22063. }
  22064. }
  22065. else governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {governmentRentCurrency1}";
  22066. var cityTaxStrCurrency1 = currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name;
  22067. if (!string.IsNullOrEmpty(cityTaxStrCurrency1))
  22068. {
  22069. if (cityTaxStrCurrency1.Equals("CNY"))
  22070. {
  22071. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  22072. }
  22073. else
  22074. {
  22075. rateDatas.Add(new { code = cityTaxStrCurrency1, rate = cityTaxInfo.Rate });
  22076. var cityTaxCny = cityTaxInfo.Price * cityTaxInfo.Rate;
  22077. cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}\r\n{cityTaxCny.ToString("#0.00")} CNY";
  22078. }
  22079. }
  22080. else cityTaxStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {cityTaxStrCurrency1}";
  22081. int payDId = roomInfo?.PayDId ?? 0;
  22082. pcfds.Add(new HotelReservations_PCFD_View()
  22083. {
  22084. City = item.City,
  22085. HotelName = item.HotelName,
  22086. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  22087. // SingleRoomCount = item.SingleRoomCount,
  22088. SingleRoomPrice = singleRoomFeeStr,
  22089. // DoubleRoomCount = item.DoubleRoomCount,
  22090. DoubleRoomPrice = doubleRoomFeeStr,
  22091. //SuiteRoomCount = item.SuiteRoomCount,
  22092. SuiteRoomPrice = suiteRoomFeeStr,
  22093. OtherRoomPrice = otherRoomFeeStr,
  22094. //OtherRoomCount = item.OtherRoomCount,
  22095. BreakfastPrice = breakfastPriceStr,
  22096. GovernmentRent = governmentRentStr,
  22097. CityTax = cityTaxStr,
  22098. RoomExplanation = item.RoomExplanation,
  22099. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  22100. PayTime = roomInfo?.ConsumptionDate,
  22101. BankNo = roomInfo?.BankNo,
  22102. PayMoney = payMoneyStr,
  22103. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  22104. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  22105. CardPrice = cardPriceStr,
  22106. Remark = ccpInfo.Remark
  22107. });
  22108. }
  22109. #endregion
  22110. //载入模板
  22111. WorkbookDesigner designer = new WorkbookDesigner();
  22112. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  22113. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  22114. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  22115. designer.SetDataSource("TourNo", groupInfo.TourCode);
  22116. var rateDatas1 = rateDatas.Distinct();
  22117. var rateStr = string.Empty;
  22118. foreach (var item in rateDatas1)
  22119. {
  22120. rateStr += $"{item.code} {item.rate.ToString("#0.0000")} \t\t";
  22121. }
  22122. designer.SetDataSource("TeamName", $"酒店模块汇率:{rateStr}");
  22123. designer.SetDataSource("Opertor", userInfo.CnName);
  22124. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  22125. dt.TableName = "ViewMyHotelReservations";
  22126. designer.SetDataSource(dt);
  22127. designer.Process();
  22128. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  22129. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  22130. designer.Workbook.Save(serverPath);
  22131. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  22132. #region 删除指定行
  22133. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  22134. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  22135. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  22136. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  22137. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  22138. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  22139. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  22140. cssIndex = dt.Columns["CityTax"].Ordinal,
  22141. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  22142. remarkIndex = dt.Columns["Remark"].Ordinal;
  22143. //删除指定列
  22144. foreach (DataRow item in dt.Rows)
  22145. {
  22146. string singleStr = item["SingleRoomPrice"].ToString();
  22147. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  22148. if (containsDigitButNotZero1) singleDel = false;
  22149. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  22150. string doubleStr = item["DoubleRoomPrice"].ToString();
  22151. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22152. if (containsDigitButNotZero2) doubleDel = false;
  22153. string suiteStr = item["SuiteRoomPrice"].ToString();
  22154. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22155. if (containsDigitButNotZero3) suiteDel = false;
  22156. string otherStr = item["OtherRoomPrice"].ToString();
  22157. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  22158. if (containsDigitButNotZero4) otherDel = false;
  22159. string zcStr = item["BreakfastPrice"].ToString();
  22160. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  22161. if (containsDigitButNotZero5) zcDel = false;
  22162. string dsStr = item["GovernmentRent"].ToString();
  22163. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  22164. if (containsDigitButNotZero6) dsDel = false;
  22165. string cssStr = item["CityTax"].ToString();
  22166. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  22167. if (containsDigitButNotZero7) cssDel = false;
  22168. string cpStr = item["ConsumptionPatterns"].ToString();
  22169. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  22170. string remarkStr = item["Remark"].ToString();
  22171. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  22172. }
  22173. DeleteColumn(serverPath, remarkIndex, remarkDel);
  22174. DeleteColumn(serverPath, cpIndex, cpDel);
  22175. DeleteColumn(serverPath, dsIndex, dsDel);
  22176. DeleteColumn(serverPath, cssIndex, cssDel);
  22177. DeleteColumn(serverPath, zcIndex, zcDel);
  22178. DeleteColumn(serverPath, otherIndex, otherDel);
  22179. DeleteColumn(serverPath, suiteIndex, suiteDel);
  22180. DeleteColumn(serverPath, doubleIndex, doubleDel);
  22181. DeleteColumn(serverPath, singleIndex, singleDel);
  22182. #endregion
  22183. //只保留第一个表格
  22184. DeleteSheet(serverPath);
  22185. return Ok(JsonView(true, "操作成功", url = rst));
  22186. }
  22187. else
  22188. {
  22189. _currency = _GroupCostParameter.Currency;
  22190. bool isIntType = int.TryParse(_currency, out int currId);
  22191. if (isIntType)
  22192. {
  22193. _currency = currDatas.Find(it => it.Id == currId)?.Name ?? "";
  22194. }
  22195. var teamRate = await _teamRateRep.PostGroupTeamRateItemByDiIdAndCTableId(1, _dto.DiId, 76);
  22196. var currInfo = teamRate.Find(it => it.CurrencyCode.Equals(_currency));
  22197. if (currInfo == null)
  22198. {
  22199. return Ok(JsonView(StatusCodes.Status400BadRequest, $"团组汇率-->酒店模块 {_currency} 币种未设置汇率,不支持预定成本Excel导出", ""));
  22200. }
  22201. if (!_currency.ToUpper().Equals("CNY"))
  22202. {
  22203. _rate = _GroupCostParameter.Rate;
  22204. }
  22205. _rate = currInfo.Rate;
  22206. hrDtas = hrDtas.OrderBy(it => it.CheckInDate).ToList();
  22207. //string strFileName = "HotelStatement/";
  22208. //string guestNames = ""; //格式Mr.xxx Ms.xxx
  22209. List<HotelReservations_PCFD_View> pcfds = new List<HotelReservations_PCFD_View>();
  22210. #region 数据处理
  22211. foreach (var item in hrDtas)
  22212. {
  22213. var ccpInfo = ccpData.Where(it => it.DIId == _dto.DiId && it.CId == item.Id).First();
  22214. var roomInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 1).FirstOrDefault(); //房费
  22215. var breakfastInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 2).FirstOrDefault(); //早餐
  22216. var governmentRentInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 3).FirstOrDefault(); //地税
  22217. var cityTaxInfo = hotelSubData.Where(it => it.HrId == item.Id && it.PriceType == 4).FirstOrDefault(); //城市税
  22218. string roomCurr = currDatas.Find(it => it.Id == roomInfo?.Currency)?.Name ?? "";
  22219. string singleRoomFeeStr = string.Empty,
  22220. doubleRoomFeeStr = string.Empty,
  22221. suiteRoomFeeStr = string.Empty,
  22222. otherRoomFeeStr = string.Empty,
  22223. payMoneyStr = string.Empty,
  22224. cardPriceStr = string.Empty;
  22225. if (roomCurr.Equals(_currency))
  22226. {
  22227. singleRoomFeeStr = $"{item.SingleRoomPrice.ToString("#0.00")} {_currency}";
  22228. doubleRoomFeeStr = $"{item.DoubleRoomPrice.ToString("#0.00")} {_currency}";
  22229. suiteRoomFeeStr = $"{item.SuiteRoomPrice.ToString("#0.00")} {_currency}";
  22230. otherRoomFeeStr = $"{item.OtherRoomPrice.ToString("#0.00")} {_currency}";
  22231. payMoneyStr = $"{ccpInfo.PayMoney.ToString("#0.00")} {_currency}";
  22232. cardPriceStr = $"{item.CardPrice.ToString("#0.00")} {_currency}";
  22233. }
  22234. else
  22235. {
  22236. singleRoomFeeStr = $"{((item.SingleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SingleRoomPrice.ToString("#0.00")} {roomCurr}";
  22237. doubleRoomFeeStr = $"{((item.DoubleRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.DoubleRoomPrice.ToString("#0.00")} {roomCurr}";
  22238. suiteRoomFeeStr = $"{((item.SuiteRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.SuiteRoomPrice.ToString("#0.00")} {roomCurr}";
  22239. otherRoomFeeStr = $"{((item.OtherRoomPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.OtherRoomPrice.ToString("#0.00")} {roomCurr}";
  22240. payMoneyStr = $"{((ccpInfo.PayMoney * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{ccpInfo.PayMoney.ToString("#0.00")} {roomCurr}";
  22241. cardPriceStr = $"{((item.CardPrice * roomInfo.Rate) / _rate).ToString("#0.00")} {_currency}\r\n{item.CardPrice.ToString("#0.00")} {roomCurr}";
  22242. }
  22243. string breakfastPriceStr = string.Empty,
  22244. breakfastCurrency = currDatas.Find(it => it.Id == item.BreakfastCurrency)?.Name ?? "",
  22245. governmentRentStr = string.Empty,
  22246. governmentRentCurrency = currDatas.Find(it => it.Id == item.GovernmentRentCurrency)?.Name ?? "",
  22247. cityTaxStrStr = string.Empty,
  22248. cityTaxStrCurrency = currDatas.Find(it => it.Id == item.CityTaxCurrency)?.Name ?? "";
  22249. breakfastPriceStr = $"{breakfastInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == breakfastInfo?.Currency)?.Name}";
  22250. governmentRentStr = $"{governmentRentInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == governmentRentInfo?.Currency)?.Name}";
  22251. cityTaxStrStr = $"{cityTaxInfo?.Price.ToString("#0.00")} {currDatas.Find(it => it.Id == cityTaxInfo?.Currency)?.Name}";
  22252. int payDId = roomInfo?.PayDId ?? 0;
  22253. pcfds.Add(new HotelReservations_PCFD_View()
  22254. {
  22255. City = item.City,
  22256. HotelName = item.HotelName,
  22257. Date = $"{item.CheckInDate} - {item.CheckOutDate}",
  22258. // SingleRoomCount = item.SingleRoomCount,
  22259. SingleRoomPrice = singleRoomFeeStr,
  22260. // DoubleRoomCount = item.DoubleRoomCount,
  22261. DoubleRoomPrice = doubleRoomFeeStr,
  22262. //SuiteRoomCount = item.SuiteRoomCount,
  22263. SuiteRoomPrice = suiteRoomFeeStr,
  22264. OtherRoomPrice = otherRoomFeeStr,
  22265. //OtherRoomCount = item.OtherRoomCount,
  22266. BreakfastPrice = breakfastPriceStr,
  22267. GovernmentRent = governmentRentStr,
  22268. CityTax = cityTaxStrStr,
  22269. RoomExplanation = item.RoomExplanation,
  22270. PayTypeName = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.Id == payDId).First()?.Name ?? "",
  22271. PayTime = roomInfo?.ConsumptionDate,
  22272. BankNo = roomInfo?.BankNo,
  22273. PayMoney = payMoneyStr,
  22274. //PayMoneys = ccpInfo.PayMoney.ToString("#0.00"),
  22275. ConsumptionPatterns = roomInfo?.ConsumptionPatterns,
  22276. CardPrice = cardPriceStr,
  22277. Remark = ccpInfo.Remark
  22278. });
  22279. }
  22280. #endregion
  22281. //载入模板
  22282. WorkbookDesigner designer = new WorkbookDesigner();
  22283. designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/酒店预订成本.xls");
  22284. var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == _dto.DiId).First();
  22285. var userInfo = _sqlSugar.Queryable<Sys_Users>().Where(it => it.Id == hrDtas[0].CreateUserId).First();
  22286. designer.SetDataSource("TourNo", groupInfo.TourCode);
  22287. designer.SetDataSource("TeamName", $"{groupInfo.TeamName} 团组成本币种:{_currency} 团组汇率-->酒店模块汇率:{_rate.ToString("#0.0000")}");
  22288. designer.SetDataSource("Opertor", userInfo.CnName);
  22289. DataTable dt = CommonFun.GetDataTableFromIList<HotelReservations_PCFD_View>(pcfds);
  22290. dt.TableName = "ViewMyHotelReservations";
  22291. designer.SetDataSource(dt);
  22292. designer.Process();
  22293. string fileName = $"HotelReservation/{groupInfo.TeamName.Replace("/", "").Replace(@"\", "").Trim()}_酒店预订成本_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xls";
  22294. string serverPath = AppSettingsHelper.Get("ExcelBasePath") + fileName;
  22295. designer.Workbook.Save(serverPath);
  22296. string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
  22297. #region 删除指定行
  22298. bool singleDel = true, doubleDel = true, suiteDel = true, otherDel = true, zcDel = true, dsDel = true, cssDel = true, cpDel = true, remarkDel = true;
  22299. int singleIndex = dt.Columns["SingleRoomPrice"].Ordinal,
  22300. doubleIndex = dt.Columns["DoubleRoomPrice"].Ordinal,
  22301. suiteIndex = dt.Columns["SuiteRoomPrice"].Ordinal,
  22302. otherIndex = dt.Columns["OtherRoomPrice"].Ordinal,
  22303. zcIndex = dt.Columns["BreakfastPrice"].Ordinal,
  22304. dsIndex = dt.Columns["GovernmentRent"].Ordinal,
  22305. cssIndex = dt.Columns["CityTax"].Ordinal,
  22306. cpIndex = dt.Columns["ConsumptionPatterns"].Ordinal,
  22307. remarkIndex = dt.Columns["Remark"].Ordinal;
  22308. //删除指定列
  22309. foreach (DataRow item in dt.Rows)
  22310. {
  22311. string singleStr = item["SingleRoomPrice"].ToString();
  22312. bool containsDigitButNotZero1 = !singleStr.StartsWith("0") && Regex.IsMatch(singleStr, @"[1-9]");
  22313. if (containsDigitButNotZero1) singleDel = false;
  22314. singleIndex = dt.Columns["SingleRoomPrice"].Ordinal;
  22315. string doubleStr = item["DoubleRoomPrice"].ToString();
  22316. bool containsDigitButNotZero2 = !doubleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22317. if (containsDigitButNotZero2) doubleDel = false;
  22318. string suiteStr = item["SuiteRoomPrice"].ToString();
  22319. bool containsDigitButNotZero3 = !singleStr.StartsWith("0") && Regex.IsMatch(doubleStr, @"[1-9]");
  22320. if (containsDigitButNotZero3) suiteDel = false;
  22321. string otherStr = item["OtherRoomPrice"].ToString();
  22322. bool containsDigitButNotZero4 = !otherStr.StartsWith("0") && Regex.IsMatch(otherStr, @"[1-9]");
  22323. if (containsDigitButNotZero4) otherDel = false;
  22324. string zcStr = item["BreakfastPrice"].ToString();
  22325. bool containsDigitButNotZero5 = !zcStr.StartsWith("0") && Regex.IsMatch(zcStr, @"[1-9]");
  22326. if (containsDigitButNotZero5) zcDel = false;
  22327. string dsStr = item["GovernmentRent"].ToString();
  22328. bool containsDigitButNotZero6 = !dsStr.StartsWith("0") && Regex.IsMatch(dsStr, @"[1-9]");
  22329. if (containsDigitButNotZero6) dsDel = false;
  22330. string cssStr = item["CityTax"].ToString();
  22331. bool containsDigitButNotZero7 = !cssStr.StartsWith("0") && Regex.IsMatch(cssStr, @"[1-9]");
  22332. if (containsDigitButNotZero7) cssDel = false;
  22333. string cpStr = item["ConsumptionPatterns"].ToString();
  22334. if (!string.IsNullOrEmpty(cpStr)) cpDel = false;
  22335. string remarkStr = item["Remark"].ToString();
  22336. if (!string.IsNullOrEmpty(remarkStr)) remarkDel = false;
  22337. }
  22338. DeleteColumn(serverPath, remarkIndex, remarkDel);
  22339. DeleteColumn(serverPath, cpIndex, cpDel);
  22340. DeleteColumn(serverPath, dsIndex, dsDel);
  22341. DeleteColumn(serverPath, cssIndex, cssDel);
  22342. DeleteColumn(serverPath, zcIndex, zcDel);
  22343. DeleteColumn(serverPath, otherIndex, otherDel);
  22344. DeleteColumn(serverPath, suiteIndex, suiteDel);
  22345. DeleteColumn(serverPath, doubleIndex, doubleDel);
  22346. DeleteColumn(serverPath, singleIndex, singleDel);
  22347. #endregion
  22348. //只保留第一个表格
  22349. DeleteSheet(serverPath);
  22350. return Ok(JsonView(true, "操作成功", url = rst));
  22351. }
  22352. //return Ok(JsonView(false));
  22353. }
  22354. /// <summary>
  22355. /// 删除指定列
  22356. /// </summary>
  22357. /// <param name="file"></param>
  22358. /// <param name="columnIndex"></param>
  22359. /// <param name="isDel"></param>
  22360. private void DeleteColumn(string file, int columnIndex, bool isDel)
  22361. {
  22362. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  22363. //wb.Save(file);
  22364. Aspose.Cells.Worksheet sheet1 = wb.Worksheets[0];
  22365. if (sheet1 != null)
  22366. {
  22367. if (isDel)
  22368. {
  22369. Cells cells = sheet1.Cells;
  22370. cells.DeleteColumn(columnIndex);
  22371. }
  22372. }
  22373. wb.Save(file);
  22374. }
  22375. /// <summary>
  22376. /// 删除sheet
  22377. /// </summary>
  22378. /// <param name="file"></param>
  22379. private void DeleteSheet(string file)
  22380. {
  22381. Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(file);
  22382. //wb.Save(file);
  22383. List<string> sheets = new List<string>();
  22384. foreach (var item in wb.Worksheets)
  22385. {
  22386. sheets.Add(item.Name);
  22387. }
  22388. if (sheets.Count > 0)
  22389. {
  22390. sheets.RemoveAt(0);//不删除第一个sheet
  22391. foreach (var item in sheets)
  22392. {
  22393. wb.Worksheets.RemoveAt(item);
  22394. }
  22395. }
  22396. wb.Save(file);
  22397. }
  22398. /// <summary>
  22399. /// 酒店预订
  22400. /// 确认单
  22401. /// </summary>
  22402. /// <param name="_dto"></param>
  22403. /// <returns></returns>
  22404. [HttpPost]
  22405. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22406. public async Task<IActionResult> PostHotelReservationsConfirmationSlip(HotelReservationsConfirmationSlipDto _dto)
  22407. {
  22408. try
  22409. {
  22410. #region 参数验证
  22411. if (_dto.UserId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "员工Id为空", ""));
  22412. if (_dto.PageId < 1) _dto.PageId = 28; //酒店预定Id
  22413. if (_dto.DiId < 1) return Ok(JsonView(StatusCodes.Status400BadRequest, "团组Id为空", ""));
  22414. #region 团组操作权限验证 76 酒店预定模块
  22415. var groupAuthView = await GeneralMethod.PostGroupOperationAuth(_dto.DiId, _dto.UserId, 76);
  22416. if (groupAuthView.Code != 0) return Ok(JsonView(StatusCodes.Status400BadRequest, groupAuthView.Msg, ""));
  22417. #endregion
  22418. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22419. #region 页面操作权限验证
  22420. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22421. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  22422. #endregion
  22423. #endregion
  22424. //团组信息
  22425. Grp_DelegationInfo di = _sqlSugar.Queryable<Grp_DelegationInfo>().First(a => a.Id == _dto.DiId);
  22426. //酒店数据
  22427. List<Grp_HotelReservations> listhoteldata = await _sqlSugar.Queryable<Grp_HotelReservations>().Where(a => a.DiId == _dto.DiId && a.IsDel == 0).ToListAsync();
  22428. if (listhoteldata.Count < 0)
  22429. {
  22430. return Ok(JsonView(StatusCodes.Status400BadRequest, "当前团组暂无酒店预订信息!", ""));
  22431. }
  22432. //利datatable存储
  22433. DataTable dt = new DataTable();
  22434. dt.Columns.Add("CheckInDate", typeof(string));
  22435. dt.Columns.Add("City", typeof(string));
  22436. dt.Columns.Add("Hotel", typeof(string));
  22437. dt.Columns.Add("Room", typeof(string));
  22438. for (int i = 0; i < listhoteldata.Count; i++)
  22439. {
  22440. DateTime dayStart = Convert.ToDateTime(listhoteldata[i].CheckInDate);
  22441. DateTime dayEnd = Convert.ToDateTime(listhoteldata[i].CheckOutDate);
  22442. while (dayStart < dayEnd)
  22443. {
  22444. string temp = "";
  22445. DataRow row = dt.NewRow();
  22446. row["CheckInDate"] = dayStart.ToString("yyyy-MM-dd");
  22447. row["City"] = listhoteldata[i].City;
  22448. row["Hotel"] = listhoteldata[i].HotelName;
  22449. if (listhoteldata[i].SingleRoomCount > 0)
  22450. {
  22451. temp = listhoteldata[i].SingleRoomCount + "个单间" + "\r\n";
  22452. }
  22453. if (listhoteldata[i].DoubleRoomCount > 0)
  22454. {
  22455. temp = temp + listhoteldata[i].DoubleRoomCount + "个标间" + "\r\n";
  22456. }
  22457. if (listhoteldata[i].SuiteRoomCount > 0)
  22458. {
  22459. temp = temp + listhoteldata[i].SuiteRoomCount + "个套房" + "\r\n";
  22460. }
  22461. if (listhoteldata[i].OtherRoomCount > 0)
  22462. {
  22463. temp = temp + listhoteldata[i].OtherRoomCount + "个其他房型" + "\r\n";
  22464. }
  22465. row["Room"] = temp;
  22466. dt.Rows.Add(row);
  22467. dayStart = dayStart.AddDays(1);
  22468. }
  22469. }
  22470. Dictionary<string, string> dic = new Dictionary<string, string>();
  22471. dic.Add("Dele", di.TeamName);
  22472. dic.Add("City", di.VisitCountry);
  22473. //模板路径
  22474. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/酒店用房确认单-模板.doc";
  22475. //载入模板
  22476. Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
  22477. DocumentBuilder builder = new DocumentBuilder(doc);
  22478. foreach (var key in dic.Keys)
  22479. {
  22480. builder.MoveToBookmark(key);
  22481. builder.Write(dic[key]);
  22482. }
  22483. //获取word里所有表格
  22484. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  22485. //获取所填表格的序数
  22486. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  22487. var rowStart = tableOne.Rows[0]; //获取第1行
  22488. //循环赋值
  22489. for (int i = 0; i < dt.Rows.Count; i++)
  22490. {
  22491. builder.MoveToCell(0, i + 1, 0, 0);
  22492. builder.Write(dt.Rows[i]["CheckInDate"].ToString());
  22493. builder.MoveToCell(0, i + 1, 1, 0);
  22494. builder.Write(dt.Rows[i]["City"].ToString());
  22495. builder.MoveToCell(0, i + 1, 2, 0);
  22496. builder.Write(dt.Rows[i]["Hotel"].ToString());
  22497. builder.MoveToCell(0, i + 1, 3, 0);
  22498. builder.Write(dt.Rows[i]["Room"].ToString());
  22499. }
  22500. //删除多余行
  22501. while (tableOne.Rows.Count > dt.Rows.Count + 1)
  22502. {
  22503. tableOne.Rows.RemoveAt(dt.Rows.Count + 1);
  22504. }
  22505. string strFileName = di.TeamName + "酒店确认单.doc";
  22506. doc.Save(AppSettingsHelper.Get("WordBasePath") + "HotelStatement/" + strFileName);
  22507. string url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/HotelStatement/" + strFileName;
  22508. return Ok(JsonView(true, "成功", url));
  22509. }
  22510. catch (Exception ex)
  22511. {
  22512. return Ok(JsonView(StatusCodes.Status400BadRequest, ex.Message, ""));
  22513. }
  22514. }
  22515. #endregion
  22516. #region 团组状态
  22517. /// <summary>
  22518. /// 团组状态列表 Page
  22519. /// </summary>
  22520. /// <param name="dto">团组列表请求dto</param>
  22521. /// <returns></returns>
  22522. [HttpPost]
  22523. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22524. public async Task<IActionResult> PostGroupStatusPageList(GroupStatusListDto dto)
  22525. {
  22526. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  22527. if (dto.PortType == 1 || dto.PortType == 2) // web/Android
  22528. {
  22529. string sqlWhere = string.Empty;
  22530. if (dto.IsSure == 0) //未完成
  22531. {
  22532. sqlWhere += string.Format(@" And IsSure = 0");
  22533. }
  22534. else if (dto.IsSure == 1) //已完成
  22535. {
  22536. sqlWhere += string.Format(@" And IsSure = 1");
  22537. }
  22538. if (!string.IsNullOrEmpty(dto.SearchCriteria))
  22539. {
  22540. string tj = dto.SearchCriteria;
  22541. 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}%')",
  22542. tj, tj, tj, tj, tj);
  22543. }
  22544. string sql = string.Format(@"Select Row_Number,Id,SalesQuoteNo,TourCode,TeamTypeId, TeamType,
  22545. TeamLevId,TeamLev,TeamName,ClientName,ClientUnit,
  22546. VisitDate,VisitDays,VisitPNumber,JietuanOperator,IsSure,CreateTime
  22547. From (
  22548. Select row_number() over(order by gdi.VisitStartDate Desc) as Row_Number,
  22549. gdi.Id,SalesQuoteNo,TourCode,ssd.Id TeamTypeId, ssd.Name TeamType,
  22550. ssd1.Id TeamLevId,ssd1.Name TeamLev,TeamName,ClientName,ClientUnit,
  22551. VisitDate,VisitDays,VisitPNumber,su.CnName JietuanOperator,IsSure,gdi.CreateTime
  22552. From Grp_DelegationInfo gdi
  22553. Inner Join Sys_SetData ssd On gdi.TeamDid = ssd.Id
  22554. Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
  22555. Left Join Sys_Users su On gdi.JietuanOperator = su.Id
  22556. Where gdi.IsDel = 0 {0}
  22557. ) temp ", sqlWhere);
  22558. RefAsync<int> total = 0;//REF和OUT不支持异步,想要真的异步这是最优解
  22559. var _DelegationList = await _sqlSugar.SqlQueryable<GroupStatusView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);//ToPageAsync
  22560. return Ok(JsonView(true, "查询成功!", _DelegationList, total));
  22561. }
  22562. else
  22563. {
  22564. return Ok(JsonView(false, "查询失败"));
  22565. }
  22566. }
  22567. /// <summary>
  22568. /// 团组状态
  22569. /// 设置操作完成
  22570. /// </summary>
  22571. /// <param name="dto">团组列表请求dto</param>
  22572. /// <returns></returns>
  22573. [HttpPost]
  22574. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22575. public async Task<IActionResult> PostGroupStatusSetOperationComplete(GroupStatusSetOperationCompleteDto dto)
  22576. {
  22577. if (dto == null) return Ok(JsonView(false, "请输入搜索条件!"));
  22578. Grp_DelegationInfo _DelegationInfo = new Grp_DelegationInfo()
  22579. {
  22580. Id = dto.Id,
  22581. IsSure = 1
  22582. };
  22583. var result = await _sqlSugar.Updateable(_DelegationInfo)
  22584. .UpdateColumns(it => new { it.IsSure })
  22585. .WhereColumns(it => new { it.Id })
  22586. .ExecuteCommandAsync();
  22587. if (result > 0)
  22588. {
  22589. return Ok(JsonView(true, "操作完成!"));
  22590. }
  22591. return Ok(JsonView(false, "操作失败!"));
  22592. }
  22593. #endregion
  22594. #region 保险费用录入
  22595. /// <summary>
  22596. /// 根据团组Id查询保险费用列表
  22597. /// </summary>
  22598. /// <param name="dto"></param>
  22599. /// <returns></returns>
  22600. [HttpPost]
  22601. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22602. public async Task<IActionResult> CustomersByDiId(CustomersByDiIdDto dto)
  22603. {
  22604. Result groupData = await _customersRep.CustomersByDiId(dto);
  22605. if (groupData.Code != 0)
  22606. {
  22607. return Ok(JsonView(false, groupData.Msg));
  22608. }
  22609. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22610. }
  22611. /// <summary>
  22612. /// 根据保险费用Id查询保险费用详细
  22613. /// </summary>
  22614. /// <param name="dto"></param>
  22615. /// <returns></returns>
  22616. [HttpPost]
  22617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22618. public async Task<IActionResult> CustomersById(CustomersByIdDto dto)
  22619. {
  22620. try
  22621. {
  22622. Result groupData = await _customersRep.CustomersById(dto);
  22623. if (groupData.Code != 0)
  22624. {
  22625. return Ok(JsonView(false, groupData.Msg));
  22626. }
  22627. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22628. }
  22629. catch (Exception ex)
  22630. {
  22631. return Ok(JsonView(false, ex.Message));
  22632. }
  22633. }
  22634. /// <summary>
  22635. /// 保险费用录入页面初始化绑定
  22636. /// </summary>
  22637. /// <param name="dto"></param>
  22638. /// <returns></returns>
  22639. [HttpPost]
  22640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22641. public async Task<IActionResult> CustomersInitialize(CustomersInitializeDto dto)
  22642. {
  22643. try
  22644. {
  22645. Result groupData = await _customersRep.CustomersInitialize(dto);
  22646. if (groupData.Code != 0)
  22647. {
  22648. return Ok(JsonView(false, groupData.Msg));
  22649. }
  22650. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22651. }
  22652. catch (Exception ex)
  22653. {
  22654. return Ok(JsonView(false, ex.Message));
  22655. }
  22656. }
  22657. /// <summary>
  22658. /// 保险费用操作(Status:1.新增,2.修改)
  22659. /// </summary>
  22660. /// <param name="dto"></param>
  22661. /// <returns></returns>
  22662. [HttpPost]
  22663. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22664. public async Task<IActionResult> OpCustomers(OpCustomersDto dto)
  22665. {
  22666. Result groupData = await _customersRep.OpCustomers(dto);
  22667. if (groupData.Code != 0)
  22668. {
  22669. return Ok(JsonView(false, groupData.Msg));
  22670. }
  22671. #region 应用推送
  22672. try
  22673. {
  22674. int ccpId = groupData.Data.GetType().GetProperty("ccpId").GetValue(groupData.Data, null);
  22675. int sign = groupData.Data.GetType().GetProperty("sign").GetValue(groupData.Data, null);
  22676. int dataId = groupData.Data.GetType().GetProperty("dataId").GetValue(groupData.Data, null);
  22677. await AppNoticeLibrary.SendChatMsg_GroupStatus_ApplyFee(ccpId, sign, QiyeWeChatEnum.GuoJiaoLeaderChat);
  22678. //自动审核
  22679. await _feeAuditRep.FeeAutomaticAudit(4, dto.DiId, dataId);
  22680. //2024-10-21 新增LZ UID
  22681. var userIds = new List<int>() { 21 };
  22682. string title = $"系统通知";
  22683. var diId = dto.DiId;
  22684. var groupInfo = await _groupRepository.Query(x => x.Id == diId).FirstAsync();
  22685. var ccpInfo = await _sqlSugar.Queryable<Grp_CreditCardPayment>().Where(x => x.Id == ccpId).FirstAsync();
  22686. string content = "";
  22687. if (dto.Status == 1) content = $"[新增-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  22688. else if (dto.Status == 2) content = $"[更新-保险费用录入({groupInfo?.TeamName ?? "-"})]一项费用:{(ccpInfo.PayMoney * ccpInfo.DayRate).ToString("#0.00")} CNY;";
  22689. await GeneralMethod.MessageIssueAndNotification(MessageTypeEnum.GroupBusinessOperations, title, content, userIds, diId);
  22690. PageParam_PriceAuditH5 h5 = new PageParam_PriceAuditH5() { diid = diId.ToString(), uid = "21", itemId = "82" };
  22691. await APNsTools.iOS_PushNotifications1("051", "保险费用审核", "", content, true, "ExpenseAuditWebView", h5);
  22692. }
  22693. catch (Exception ex)
  22694. {
  22695. }
  22696. #endregion
  22697. return Ok(JsonView(true, groupData.Msg, groupData.Data));
  22698. }
  22699. /// <summary>
  22700. /// 保险文件上传
  22701. /// </summary>
  22702. /// <param name="file"></param>
  22703. /// <returns></returns>
  22704. [HttpPost]
  22705. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22706. public async Task<IActionResult> UploadCus(IFormFile file)
  22707. {
  22708. try
  22709. {
  22710. if (file != null)
  22711. {
  22712. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  22713. //文件名称
  22714. string projectFileName = file.FileName;
  22715. //上传的文件的路径
  22716. string filePath = "";
  22717. if (!Directory.Exists(fileDir))
  22718. {
  22719. Directory.CreateDirectory(fileDir);
  22720. }
  22721. //上传的文件的路径
  22722. filePath = fileDir + $@"\保险费用文件上传\{projectFileName}";
  22723. using (FileStream fs = System.IO.File.Create(filePath))
  22724. {
  22725. file.CopyTo(fs);
  22726. fs.Flush();
  22727. }
  22728. return Ok(JsonView(true, "上传成功!", projectFileName));
  22729. }
  22730. else
  22731. {
  22732. return Ok(JsonView(false, "上传失败!"));
  22733. }
  22734. }
  22735. catch (Exception ex)
  22736. {
  22737. return Ok(JsonView(false, ex.Message));
  22738. }
  22739. }
  22740. /// <summary>
  22741. /// 保险删除指定文件
  22742. /// </summary>
  22743. /// <param name="dto"></param>
  22744. /// <returns></returns>
  22745. [HttpPost]
  22746. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22747. public async Task<IActionResult> DelFileCus(DelFileDto dto)
  22748. {
  22749. try
  22750. {
  22751. string filePath = "";
  22752. var fileDir = AppSettingsHelper.Get("GrpFileBasePath");
  22753. // 返回与指定虚拟路径相对应的物理路径即绝对路径
  22754. //int id = 0;
  22755. filePath = fileDir + "/保险费用文件上传/" + dto.fileName;
  22756. // 删除该文件
  22757. try
  22758. {
  22759. System.IO.File.Delete(filePath);
  22760. 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()
  22761. {
  22762. Attachment = "",
  22763. }).ExecuteCommandAsync();
  22764. if (result != 0)
  22765. {
  22766. return Ok(JsonView(true, "成功!"));
  22767. }
  22768. else
  22769. {
  22770. return Ok(JsonView(false, "失败!"));
  22771. }
  22772. }
  22773. catch (Exception)
  22774. {
  22775. 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()
  22776. {
  22777. Attachment = "",
  22778. }).ExecuteCommandAsync();
  22779. if (result != 0)
  22780. {
  22781. return Ok(JsonView(true, "成功!"));
  22782. }
  22783. else
  22784. {
  22785. return Ok(JsonView(false, "失败!"));
  22786. }
  22787. }
  22788. }
  22789. catch (Exception ex)
  22790. {
  22791. return Ok(JsonView(false, "程序错误!"));
  22792. throw;
  22793. }
  22794. }
  22795. /// <summary>
  22796. /// 保险费用操作(删除)
  22797. /// </summary>
  22798. /// <param name="dto"></param>
  22799. /// <returns></returns>
  22800. [HttpPost]
  22801. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22802. public async Task<IActionResult> DelCustomers(DelBaseDto dto)
  22803. {
  22804. try
  22805. {
  22806. var res = await _customersRep.SoftDeleteByIdAsync<Grp_Customers>(dto.Id.ToString(), dto.DeleteUserId);
  22807. if (!res)
  22808. {
  22809. return Ok(JsonView(false, "删除失败"));
  22810. }
  22811. var resultC = await _sqlSugar.Updateable<Grp_CreditCardPayment>().Where(a => a.CId == dto.Id && a.IsDel == 0 && a.CTable == 82).SetColumns(a => new Grp_CreditCardPayment()
  22812. {
  22813. IsDel = 1,
  22814. DeleteUserId = dto.DeleteUserId,
  22815. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  22816. }).ExecuteCommandAsync();
  22817. return Ok(JsonView(true, "删除成功!"));
  22818. }
  22819. catch (Exception ex)
  22820. {
  22821. return Ok(JsonView(false, "程序错误!"));
  22822. throw;
  22823. }
  22824. }
  22825. #endregion
  22826. #region 接团客户名单 PageId 104
  22827. /// <summary>
  22828. /// 接团客户名单
  22829. /// 迁移数据(慎用!)
  22830. /// </summary>
  22831. /// <returns></returns>
  22832. [HttpPost]
  22833. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22834. public async Task<IActionResult> PostTourClientListChange()
  22835. {
  22836. try
  22837. {
  22838. _sqlSugar.ChangeDatabase(DBEnum.OA2014DB);
  22839. //var groupClinetData1
  22840. string sql = string.Format($"Select * From DeleClient Where Isdel = 0");
  22841. var oldOAClientList = await _sqlSugar.SqlQueryable<OA2021_DeleClient>(sql).Where(it => it.Isdel == 0).ToListAsync();
  22842. int updateCount = 0;
  22843. if (oldOAClientList.Count > 0)
  22844. {
  22845. _sqlSugar.ChangeDatabase(DBEnum.OA2023DB);
  22846. _sqlSugar.BeginTran();
  22847. var clientComInfos = _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToList();
  22848. var clientInfos = _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToList();
  22849. foreach (var item in oldOAClientList)
  22850. {
  22851. int comId = 0;
  22852. string format = "yyyy-MM-dd HH:mm:ss";
  22853. string data11 = "1990-01-01 00:00";
  22854. var data1 = IsValidDate(item.OPdate, format);
  22855. if (data1) data11 = item.OPdate;
  22856. //客户公司验证
  22857. if (!string.IsNullOrEmpty(item.Company))
  22858. {
  22859. var clientComInfo = clientComInfos.Where(it => it.CompanyFullName.Equals(item.Company)).FirstOrDefault();
  22860. if (clientComInfo == null) // add
  22861. {
  22862. var addInfo = new Crm_CustomerCompany()
  22863. {
  22864. CompanyAbbreviation = "",
  22865. CompanyFullName = item.Company,
  22866. Address = "",
  22867. PostCodes = "",
  22868. LastedOpUserId = item.OPer,
  22869. LastedOpDt = Convert.ToDateTime(data11),
  22870. CreateUserId = item.OPer,
  22871. CreateTime = Convert.ToDateTime(data11),
  22872. IsDel = 0
  22873. };
  22874. var comId1 = _sqlSugar.Insertable<Crm_CustomerCompany>(addInfo).ExecuteReturnIdentity();
  22875. if (comId1 > 0) comId = comId1;
  22876. }
  22877. else comId = clientComInfo.Id;
  22878. }
  22879. //客户人员验证
  22880. int clientId = 0;
  22881. string name = item.LastName + item.Name;
  22882. if (!string.IsNullOrEmpty(name))
  22883. {
  22884. var clientInfo = clientInfos.Where(it => (it.LastName + it.FirstName).Equals(name)).FirstOrDefault();
  22885. if (clientInfo == null)
  22886. {
  22887. DateTime? dateTime = null;
  22888. var isDt = DateTime.TryParse(item.Birthday, out DateTime birthDayDt);
  22889. if (isDt) dateTime = birthDayDt;
  22890. var addInfo1 = new Crm_DeleClient()
  22891. {
  22892. CrmCompanyId = comId,
  22893. DiId = -1,
  22894. LastName = item.LastName,
  22895. FirstName = item.Name,
  22896. OldName = "",
  22897. Pinyin = item.Pinyin,
  22898. Sex = item.Sex == "男" ? 0 : item.Sex == "女" ? 1 : -1,
  22899. Marriage = 0,
  22900. Phone = item.Phone,
  22901. Job = item.Job,
  22902. BirthDay = dateTime
  22903. };
  22904. var clientId1 = _sqlSugar.Insertable<Crm_DeleClient>(addInfo1).ExecuteReturnIdentity();
  22905. if (clientId1 > 0) clientId = clientId1;
  22906. }
  22907. else clientId = clientInfo.Id;
  22908. }
  22909. if (clientId < 1)
  22910. {
  22911. continue;
  22912. }
  22913. int airType = 0;
  22914. if (item.AirType == "超经舱") airType = 459;
  22915. else if (item.AirType == "公务舱") airType = 458;
  22916. else if (item.AirType == "经济舱") airType = 460;
  22917. else if (item.AirType == "其他") airType = 565;
  22918. else if (item.AirType == "头等舱") airType = 457;
  22919. var _TourClientListEntity = new Grp_TourClientList()
  22920. {
  22921. DiId = item.Diid,
  22922. ClientId = clientId,
  22923. CreateUserId = item.OPer,
  22924. CreateTime = Convert.ToDateTime(data11),
  22925. Remark = item.Remark,
  22926. IsDel = item.Isdel,
  22927. ShippingSpaceTypeId = airType,
  22928. ShippingSpaceSpecialNeeds = item.AirRemark,
  22929. HotelSpecialNeeds = item.RoomType
  22930. };
  22931. var _TourClientList = _sqlSugar.Insertable<Grp_TourClientList>(_TourClientListEntity).ExecuteCommand();
  22932. if (_TourClientList > 0)
  22933. {
  22934. updateCount++;
  22935. }
  22936. }
  22937. _sqlSugar.CommitTran();
  22938. }
  22939. return Ok(JsonView(true, $"更新条数:{updateCount}条"));
  22940. }
  22941. catch (Exception ex)
  22942. {
  22943. _sqlSugar.RollbackTran();
  22944. return Ok(JsonView(false, ex.Message));
  22945. }
  22946. //return Ok(JsonView(true));
  22947. }
  22948. private bool IsValidDate(string dateString, string format)
  22949. {
  22950. return DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateValue);
  22951. }
  22952. /// <summary>
  22953. /// 接团客户名单
  22954. /// 根据团组Id查询List
  22955. /// </summary>
  22956. /// <param name="_dto"></param>
  22957. /// <returns></returns>
  22958. [HttpPost]
  22959. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22960. public async Task<IActionResult> PostTourClientListByDiId(TourClientListByDiIdDto _dto)
  22961. {
  22962. #region 参数验证
  22963. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId"));
  22964. if (_dto.PageId != 104) _dto.PageId = 104; //接团客户名单PageId
  22965. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId!"));
  22966. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22967. #region 页面操作权限验证
  22968. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22969. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  22970. #endregion
  22971. #endregion
  22972. var viewData = await _tourClientListRep._ItemByDiId(_dto.PortType, _dto.DiId);
  22973. if (viewData.Code != 0)
  22974. {
  22975. return Ok(JsonView(false, viewData.Msg));
  22976. }
  22977. return Ok(JsonView(viewData.Data));
  22978. }
  22979. /// <summary>
  22980. /// 接团客户名单
  22981. /// 基础数据 Init
  22982. /// </summary>
  22983. /// <param name="_dto"></param>
  22984. /// <returns></returns>
  22985. [HttpPost]
  22986. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  22987. public async Task<IActionResult> PostTourClientListBasicDataInit(TourClientListBasicDataInitDto _dto)
  22988. {
  22989. #region 参数验证
  22990. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  22991. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  22992. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  22993. #region 页面操作权限验证
  22994. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  22995. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  22996. #endregion
  22997. #endregion
  22998. return Ok(await _tourClientListRep._BasicDataInit(_dto.PortType));
  22999. }
  23000. /// <summary>
  23001. /// 接团客户名单
  23002. /// 根据 Id查询 Details
  23003. /// </summary>
  23004. /// <param name="_dto"></param>
  23005. /// <returns></returns>
  23006. [HttpPost]
  23007. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23008. public async Task<IActionResult> PostTourClientListDetails(TourClientListDetailsDto _dto)
  23009. {
  23010. #region 参数验证
  23011. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23012. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23013. if (_dto.Id < 1) return Ok(JsonView(false, "请传入有效的Id参数!"));
  23014. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23015. #region 页面操作权限验证
  23016. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23017. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限!"));
  23018. #endregion
  23019. #endregion
  23020. var viewData = await _tourClientListRep._Details(_dto.PortType, _dto.Id);
  23021. if (viewData.Code != 0)
  23022. {
  23023. return Ok(JsonView(false, viewData.Msg));
  23024. }
  23025. return Ok(JsonView(viewData.Data));
  23026. }
  23027. /// <summary>
  23028. /// 接团客户名单
  23029. /// Add Or Edit
  23030. /// </summary>
  23031. /// <param name="_dto"></param>
  23032. /// <returns></returns>
  23033. [HttpPost]
  23034. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23035. public async Task<IActionResult> PostTourClientListAddOrEdit(TourClientListAddOrEditDto _dto)
  23036. {
  23037. #region 参数验证
  23038. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23039. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23040. if (_dto.Id < 0) return Ok(JsonView(false, "请传入有效的Id参数!"));
  23041. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23042. #region 页面操作权限验证
  23043. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23044. if (_dto.Id == 0) //添加
  23045. {
  23046. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  23047. }
  23048. else if (_dto.Id >= 0) //修改
  23049. {
  23050. if (pageFunAuthView.EditAuth == 0) return Ok(JsonView(false, "您没有编辑权限!"));
  23051. }
  23052. #endregion
  23053. #endregion
  23054. var viewData = await _tourClientListRep._AddOrEdit(_dto);
  23055. if (viewData.Code != 0)
  23056. {
  23057. return Ok(JsonView(false, viewData.Msg));
  23058. }
  23059. return Ok(JsonView(true));
  23060. }
  23061. /// <summary>
  23062. /// 接团客户名单
  23063. /// json字符串 AddMultiple(添加多个)
  23064. /// </summary>
  23065. /// <param name="_dto"></param>
  23066. /// <returns></returns>
  23067. [HttpPost]
  23068. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23069. public async Task<IActionResult> PostTourClientListJsonFormatAddMultiple(PostTourClientListJsonFormatAddMultipleDto _dto)
  23070. {
  23071. #region 参数验证
  23072. string jsonLabel = _dto.JsonLabel;
  23073. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23074. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23075. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23076. #region 页面操作权限验证
  23077. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23078. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  23079. #endregion
  23080. #endregion
  23081. var request = new TourClientListAddMultipleDto();
  23082. request.DiId = _dto.DiId;
  23083. request.UserId = _dto.UserId;
  23084. if (!CommonFun.IsValidJson(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数不是合法的json格式!"));
  23085. if (string.IsNullOrEmpty(jsonLabel)) return Ok(JsonView(false, "JsonLabel参数值不能为空"));
  23086. List<TourClientListInfoCN> datas = JsonConvert.DeserializeObject<List<TourClientListInfoCN>>(jsonLabel);
  23087. if (!datas.Any()) return Ok(JsonView(false, "JsonLabel参数值不能为空!"));
  23088. var infos = new List<TourClientListInfo>();
  23089. foreach (var data in datas)
  23090. {
  23091. (string lastName, string firstName) = CommonFun.GetLastNameAndFirstName(data.Name);
  23092. string lastNameEn = CommonFun.ConvertToPinyin(lastName),
  23093. firstNameEn = CommonFun.ConvertToPinyin(lastName);
  23094. if (string.IsNullOrEmpty(lastNameEn) || string.IsNullOrEmpty(firstNameEn))
  23095. {
  23096. continue;
  23097. }
  23098. infos.Add(new TourClientListInfo()
  23099. {
  23100. IsAccompany = 1,
  23101. LastName = lastName,
  23102. FirstName = firstName,
  23103. Pinyin = lastNameEn + @"/" + firstNameEn,
  23104. Sex = data.Sex.Equals("男") ? 0 : data.Sex.Equals("女") ? 1 : 2,
  23105. CompanyFullName = data.CompanyFullName,
  23106. Job = data.Job
  23107. });
  23108. }
  23109. if (infos.Any())
  23110. {
  23111. var viewData = await _tourClientListRep._AddMultiple(request);
  23112. if (viewData.Code != 0)
  23113. {
  23114. return Ok(JsonView(false, viewData.Msg));
  23115. }
  23116. return Ok(JsonView(true));
  23117. }
  23118. return Ok(JsonView(false));
  23119. }
  23120. /// <summary>
  23121. /// 接团客户名单
  23122. /// AddMultiple(添加多个)
  23123. /// </summary>
  23124. /// <param name="_dto"></param>
  23125. /// <returns></returns>
  23126. [HttpPost]
  23127. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23128. public async Task<IActionResult> PostTourClientListAddMultiple(TourClientListAddMultipleDto _dto)
  23129. {
  23130. #region 参数验证
  23131. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23132. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23133. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23134. #region 页面操作权限验证
  23135. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23136. if (pageFunAuthView.AddAuth == 0) return Ok(JsonView(false, "您没有添加权限!"));
  23137. #endregion
  23138. #endregion
  23139. var viewData = await _tourClientListRep._AddMultiple(_dto);
  23140. if (viewData.Code != 0)
  23141. {
  23142. return Ok(JsonView(false, viewData.Msg));
  23143. }
  23144. return Ok(JsonView(true));
  23145. }
  23146. /// <summary>
  23147. /// 接团客户名单
  23148. /// Del
  23149. /// </summary>
  23150. /// <param name="_dto"></param>
  23151. /// <returns></returns>
  23152. [HttpPost]
  23153. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23154. public async Task<IActionResult> PostTourClientListDel(TourClientListDelDto _dto)
  23155. {
  23156. #region 参数验证
  23157. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23158. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23159. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23160. #region 页面操作权限验证
  23161. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23162. if (pageFunAuthView.DeleteAuth == 0) return Ok(JsonView(false, "您没有删除权限!"));
  23163. #endregion
  23164. #endregion
  23165. var viewData = await _tourClientListRep._Del(_dto.Id, _dto.UserId);
  23166. if (viewData.Code != 0)
  23167. {
  23168. return Ok(JsonView(false, viewData.Msg));
  23169. }
  23170. return Ok(JsonView(true));
  23171. }
  23172. /// <summary>
  23173. /// 接团客户名单
  23174. /// 文件下载 客户名单
  23175. /// </summary>
  23176. /// <param name="_dto"></param>
  23177. /// <returns></returns>
  23178. [HttpPost]
  23179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23180. public async Task<IActionResult> PostTourClientListDownloadFile(PostTourClientListDownloadFile _dto)
  23181. {
  23182. #region 参数验证
  23183. if (_dto.UserId < 1) return Ok(JsonView(false, "请传入有效的UserId参数"));
  23184. if (_dto.PageId < 1) _dto.PageId = 104; //接团客户名单PageId
  23185. if (_dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数"));
  23186. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  23187. #region 页面操作权限验证
  23188. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
  23189. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限!"));
  23190. #endregion
  23191. #endregion
  23192. string clientSql = string.Format(@"Select tcl.Id,tcl.DiId,temp.*,tcl.ShippingSpaceTypeId,tcl.ShippingSpaceSpecialNeeds,
  23193. tcl.HotelSpecialNeeds,tcl.MealSpecialNeeds,tcl.Remark
  23194. From Grp_TourClientList tcl
  23195. Left Join
  23196. (Select dc.Id As DcId,dc.LastName,dc.FirstName,dc.Pinyin,dc.Sex,ccom.CompanyFullName,dc.Job,
  23197. cc1.CertNo As IDCardNo,dc.Phone,dc.BirthDay,cc2.PassportType,cc2.CertNo As PassportNo,cc2.Country,
  23198. cc2.Area,cc2.IssueDt,cc2.ExpiryDt
  23199. From Crm_DeleClient dc
  23200. Left Join Crm_CustomerCompany ccom On dc.CrmCompanyId = ccom.Id And ccom.IsDel = 0
  23201. Left Join Crm_CustomerCert cc1 On dc.Id = cc1.DcId And cc1.SdId = 773 And cc1.IsDel = 0
  23202. Left Join Crm_CustomerCert cc2 On dc.Id = cc2.DcId And cc2.SdId = 774 And cc2.IsDel = 0
  23203. Where dc.IsDel = 0) temp
  23204. On temp.DcId =tcl.ClientId
  23205. Where tcl.IsDel = 0 And tcl.DiId = {0}", _dto.DiId);
  23206. List<TourClientListDetailsView> DcList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(clientSql).ToListAsync();
  23207. if (DcList.Count < 0) return Ok(JsonView(false, "该团未录入客户名单!"));
  23208. //载入模板
  23209. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/dwon_团组人员列表模板.doc";
  23210. if (_dto.Language == 1)
  23211. {
  23212. tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/EN_Down_团组人员列表模板.doc";
  23213. }
  23214. //载入模板
  23215. var doc = new Document(tempPath);
  23216. DocumentBuilder builder = new DocumentBuilder(doc);
  23217. //获取word里所有表格
  23218. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  23219. //获取所填表格的序数
  23220. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  23221. var rowStart = tableOne.Rows[0]; //获取第1行
  23222. if (_dto.Language == 0)
  23223. {
  23224. //循环赋值
  23225. for (int i = 0; i < DcList.Count; i++)
  23226. {
  23227. EncryptionProcessor.DecryptProperties(DcList[i]);
  23228. builder.MoveToCell(0, i + 1, 0, 0);
  23229. builder.Write(DcList[i].LastName + DcList[i].FirstName);
  23230. builder.MoveToCell(0, i + 1, 1, 0);
  23231. int sex = DcList[i].Sex;
  23232. string sexStr = string.Empty;
  23233. if (sex == 0) sexStr = "男";
  23234. else if (sex == 1) sexStr = "女";
  23235. else sexStr = "未设置";
  23236. builder.Write(sexStr);
  23237. builder.MoveToCell(0, i + 1, 2, 0);
  23238. string birthDay = DcList[i].BirthDay;
  23239. string birthDayStr = string.Empty;
  23240. if (!string.IsNullOrEmpty(birthDay))
  23241. {
  23242. birthDayStr = Convert.ToDateTime(birthDay).ToString("yyyy-MM-dd");
  23243. }
  23244. builder.Write(birthDayStr);
  23245. builder.MoveToCell(0, i + 1, 3, 0);
  23246. string company = "";
  23247. if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  23248. {
  23249. company = DcList[i].CompanyFullName.ToString();
  23250. }
  23251. builder.Write(company);
  23252. builder.MoveToCell(0, i + 1, 4, 0);
  23253. builder.Write(DcList[i].Job);
  23254. }
  23255. }
  23256. else if (_dto.Language == 1)
  23257. {
  23258. List<Res_PositionEnglishComparison> listPEC = _setDataRep.Query<Res_PositionEnglishComparison>(s => s.IsDel == 0).ToList();
  23259. List<Res_CompanyEnglishComparison> listCEC = _setDataRep.Query<Res_CompanyEnglishComparison>(s => s.IsDel == 0).ToList();
  23260. List<string> transArrayStr = new List<string>();
  23261. string transStrRes1 = "";
  23262. var clientEnglishs = new List<ClientEnglishView>();
  23263. for (int i = 0; i < DcList.Count; i++)
  23264. {
  23265. var dc = DcList[i];
  23266. EncryptionProcessor.DecryptProperties(dc);
  23267. if (dc.CompanyFullName.Equals("暂无")) dc.CompanyFullName = "-";
  23268. if (dc.Job.Equals("暂无")) dc.Job = "-";
  23269. string str1 = $"{i}&{dc.CompanyFullName}&{dc.Job}";
  23270. if (DcList.Count - 1 == i) transStrRes1 += str1;
  23271. else transStrRes1 += $"{str1}|";
  23272. clientEnglishs.Add(new()
  23273. {
  23274. Id = dc.Id,
  23275. LastName = dc.LastName,
  23276. FirstName = dc.FirstName,
  23277. Pinyin = dc.Pinyin,
  23278. Sex = dc.Sex,
  23279. CompanyFullName = dc.CompanyFullName,
  23280. Job = dc.Job,
  23281. IDCardNo = dc.IDCardNo,
  23282. BirthDay = dc.BirthDay,
  23283. });
  23284. }
  23285. #region AI转英文
  23286. string jsonValue = JsonConvert.SerializeObject(clientEnglishs);
  23287. string text = @"将此JSON的中文部分全部翻译为英文,然后只给出修改后的JSON数据,不要其他任何文字";
  23288. List<SeedMessages> messages = new List<SeedMessages>()
  23289. {
  23290. new SeedMessages
  23291. {
  23292. Role = KimiRole.user,
  23293. Content = jsonValue + text
  23294. }
  23295. };
  23296. KiMiApiClient client = new KiMiApiClient();
  23297. var kimiApiResult = await client.SeedMessage(messages);
  23298. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  23299. string clients = kimiApiResult_JObject["content"].ToString();
  23300. string startStr = "```json", endStr = "```";
  23301. // 判断并清除开头部分
  23302. if (clients.StartsWith(startStr))
  23303. {
  23304. clients = clients.Remove(0, startStr.Length);
  23305. }
  23306. // 判断并清除结尾部分
  23307. if (clients.EndsWith(endStr))
  23308. {
  23309. clients = clients.Remove(clients.Length - endStr.Length);
  23310. }
  23311. var en_Json = JsonConvert.DeserializeObject<List<ClientEnglishView>>(clients);
  23312. //循环赋值
  23313. for (int i = 0; i < en_Json.Count; i++)
  23314. {
  23315. var dc = en_Json[i];
  23316. var dc1 = DcList.Find(x => x.Id == dc.Id);
  23317. string PYName = dc.FirstName + " " + dc.LastName;
  23318. builder.MoveToCell(0, i + 1, 0, 0);
  23319. builder.Write(PYName);
  23320. string sex = dc.Sex == 0 ? "Male" : dc.Sex == 1 ? "Female" : "";
  23321. builder.MoveToCell(0, i + 1, 1, 0);
  23322. builder.Write(sex);
  23323. DateTime birthDt;
  23324. bool b_birth = DateTime.TryParse(dc.BirthDay, out birthDt);
  23325. string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  23326. builder.MoveToCell(0, i + 1, 2, 0);
  23327. builder.Write(birthday);
  23328. string company = string.Empty, job = string.Empty;
  23329. company = dc.CompanyFullName;
  23330. job = dc.Job;
  23331. if (dc1 != null && !string.IsNullOrEmpty(dc1.CompanyFullName))
  23332. {
  23333. //查询对照表
  23334. Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(dc1.CompanyFullName.ToString().Trim()));
  23335. if (tempCec != null)
  23336. {
  23337. company = tempCec.enName;
  23338. }
  23339. }
  23340. builder.MoveToCell(0, i + 1, 3, 0);
  23341. builder.Write(company);
  23342. if (dc1 != null && !string.IsNullOrEmpty(dc1.Job))
  23343. {
  23344. //查询对照表
  23345. Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == dc1.Job.ToString().Trim());
  23346. if (tempPec != null)
  23347. {
  23348. job = tempPec.enName;
  23349. }
  23350. }
  23351. builder.MoveToCell(0, i + 1, 4, 0);
  23352. builder.Write(job);
  23353. }
  23354. #endregion
  23355. #region 旧翻译英文处理
  23356. ////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";
  23357. //string transStrRes = "";
  23358. //if (transStrRes1.Length > 0)
  23359. //{
  23360. // transStrRes = await _juHeApi.GetTextTranslateAsync(transStrRes1);
  23361. //}
  23362. ////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
  23363. ////await _juHeApi.GetTextTranslateAsync(DcList[i].CompanyFullName.ToString().Trim()) ?? "";
  23364. ////List<string> transArray = new List<string> { };
  23365. //List<TranslateInfo> transArray = new List<TranslateInfo>();
  23366. //if (transStrRes.Contains("|"))
  23367. //{
  23368. // string[] transArray1 = transStrRes.Split('|');
  23369. // if (transArray1.Length > 0)
  23370. // {
  23371. // foreach (var item in transArray1)
  23372. // {
  23373. // if (item.Contains("&"))
  23374. // {
  23375. // string[] transArray2 = item.Split('&');
  23376. // int index = 0;
  23377. // string companyName = "", job = "";
  23378. // if (transArray2.Length > 0)
  23379. // {
  23380. // bool success = int.TryParse(transArray2[0].Trim(), out index);
  23381. // if (1 < transArray2.Length) companyName = transArray2[1];
  23382. // if (2 < transArray2.Length) job = transArray2[2];
  23383. // }
  23384. // transArray.Add(new TranslateInfo { Index = index, CompanyName = companyName, Job = job });
  23385. // }
  23386. // }
  23387. // }
  23388. //}
  23389. ////循环赋值
  23390. //for (int i = 0; i < DcList.Count; i++)
  23391. //{
  23392. // string PYName = "";
  23393. // if (DcList[i].Pinyin.Length > 0 && DcList[i].Pinyin.IndexOf('/') > -1)
  23394. // {
  23395. // string PY_Last = DcList[i].Pinyin.Split('/')[0];
  23396. // string PY_First = DcList[i].Pinyin.Split('/')[1];
  23397. // PYName = PY_First + " " + PY_Last;
  23398. // }
  23399. // else
  23400. // {
  23401. // string PY_Last = DcList[i].LastName.GetTotalPingYin().Count > 0 ? DcList[i].LastName.GetTotalPingYin()[0].ToUpper() : "";
  23402. // string PY_First = DcList[i].FirstName.GetTotalPingYin().Count > 0 ? DcList[i].FirstName.GetTotalPingYin()[0].ToUpper() : "";
  23403. // PYName = PY_First + " " + PY_Last;
  23404. // }
  23405. // builder.MoveToCell(0, i + 1, 0, 0);
  23406. // builder.Write(PYName);
  23407. // string sex = DcList[i].Sex == 0 ? "Male" : DcList[i].Sex == 1 ? "Female" : "";
  23408. // builder.MoveToCell(0, i + 1, 1, 0);
  23409. // builder.Write(sex);
  23410. // DateTime birthDt;
  23411. // bool b_birth = DateTime.TryParse(DcList[i].BirthDay, out birthDt);
  23412. // string birthday = b_birth ? birthDt.ToString("yyyy-MM-dd") : " ";
  23413. // builder.MoveToCell(0, i + 1, 2, 0);
  23414. // builder.Write(birthday);
  23415. // string company = string.Empty, job = string.Empty;
  23416. // var dcTransInfo = transArray.FirstOrDefault(s => s.Index == i);
  23417. // if (dcTransInfo != null)
  23418. // {
  23419. // company = dcTransInfo.CompanyName;
  23420. // job = dcTransInfo.Job;
  23421. // }
  23422. // if (!string.IsNullOrEmpty(DcList[i].CompanyFullName))
  23423. // {
  23424. // //查询对照表
  23425. // Res_CompanyEnglishComparison tempCec = listCEC.FirstOrDefault(s => s.zhName.Contains(DcList[i].CompanyFullName.ToString().Trim()));
  23426. // if (tempCec != null)
  23427. // {
  23428. // company = tempCec.enName;
  23429. // }
  23430. // //翻译
  23431. // else
  23432. // {
  23433. // }
  23434. // }
  23435. // builder.MoveToCell(0, i + 1, 3, 0);
  23436. // builder.Write(company);
  23437. // if (!string.IsNullOrEmpty(DcList[i].Job.ToString()))
  23438. // {
  23439. // //查询对照表
  23440. // Res_PositionEnglishComparison tempPec = listPEC.FirstOrDefault(s => s.zhName == DcList[i].Job.ToString().Trim());
  23441. // if (tempPec != null)
  23442. // {
  23443. // job = tempPec.enName;
  23444. // }
  23445. // //翻译
  23446. // else
  23447. // {
  23448. // }
  23449. // }
  23450. // builder.MoveToCell(0, i + 1, 4, 0);
  23451. // builder.Write(job);
  23452. //}
  23453. #endregion
  23454. }
  23455. //删除多余行
  23456. while (tableOne.Rows.Count > DcList.Count + 1)
  23457. {
  23458. tableOne.Rows.RemoveAt(DcList.Count + 1);
  23459. }
  23460. string fileName = "组团人员名单(" + DateTime.Now.ToString("yyyyhhddHHmmss") + ").doc";
  23461. var fileDir = AppSettingsHelper.Get("WordBasePath") + "TourClientList/" + fileName;
  23462. doc.Save(fileDir);
  23463. string Url = AppSettingsHelper.Get("WordBaseUrl") + "Office/Word/TourClientList/" + fileName;
  23464. return Ok(JsonView(true, "操作成功!", Url));
  23465. }
  23466. private class TranslateInfo
  23467. {
  23468. public int Index { get; set; }
  23469. public string CompanyName { get; set; }
  23470. public string Job { get; set; }
  23471. }
  23472. [HttpPost]
  23473. public async Task<IActionResult> FileReadClient(List<IFormFile> files)
  23474. {
  23475. if (files.Count == 0)
  23476. {
  23477. return Ok(JsonView(false, "文件为空"));
  23478. }
  23479. KiMiApiClient KiMiApi = new KiMiApiClient();
  23480. var seedConter = await KiMiApi.UploadFilesAsync(files);
  23481. if (seedConter.Count == 0)
  23482. {
  23483. return Ok(JsonView(false, "上传结果为空!"));
  23484. }
  23485. var messages = new List<SeedMessages>
  23486. {
  23487. new SeedMessages { Role = KimiRole.system, Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。同时,你会拒绝一切涉及恐怖主义,种族歧视,黄色暴力等问题的回答。Moonshot AI 为专有名词,不可翻译成其他语言。" },
  23488. new SeedMessages { Role = KimiRole.user, Content = "根据文件内容 ,按照“姓、名、姓名拼音、性别、单位、职务、出生日期”的json格式来排列整理(性别和出生日期通过身份证来识别 , 当识别到性别为男时值给0女给1 未识别到性别的情况下值给-1,出生日期按照yyyy-MM-dd来整理(若出生日期没有值则为‘-’),文件存在拼音的情况读取对应的拼音不存在则设置拼音为中文名字全拼),只输出JSON数组数据 从'['开始 到']'结尾 ,不要除JSON数据外的任何文字以及符号" }
  23489. };
  23490. messages.InsertRange(1, seedConter);
  23491. var kimiApiResult = await KiMiApi.SeedMessage(messages);
  23492. var kimiApiResult_JObject = JObject.Parse(kimiApiResult);
  23493. string clients = kimiApiResult_JObject["content"].ToString();
  23494. string startStr = "```json", endStr = "```";
  23495. // 判断并清除开头部分
  23496. if (clients.StartsWith(startStr))
  23497. {
  23498. clients = clients.Remove(0, startStr.Length);
  23499. }
  23500. // 判断并清除结尾部分
  23501. if (clients.EndsWith(endStr))
  23502. {
  23503. clients = clients.Remove(clients.Length - endStr.Length);
  23504. }
  23505. var clients_JObject = JsonConvert.DeserializeObject<List<JObject>>(clients);
  23506. Dictionary<string, string> clientFieldMap = new Dictionary<string, string>()
  23507. {
  23508. {"姓", "LastName" },
  23509. {"名", "FirstName" },
  23510. {"姓名拼音", "Pinyin" },
  23511. {"性别", "Sex" },
  23512. {"单位", "CompanyFullName" },
  23513. {"职务", "Job" },
  23514. {"出生日期", "Birthday" },
  23515. };
  23516. List<BaiduClientOCRView> crmClients = new List<BaiduClientOCRView>();
  23517. foreach (var item in clients_JObject)
  23518. {
  23519. BaiduClientOCRView cdc = new BaiduClientOCRView();
  23520. foreach (var field in clientFieldMap.Keys)
  23521. {
  23522. if (item.TryGetValue(field, out JToken value))
  23523. {
  23524. var getValue = value.ToString();
  23525. System.Type type = cdc.GetType();
  23526. PropertyInfo propertyInfo = type.GetProperty(clientFieldMap[field]);
  23527. var propertyValue = Convert.ChangeType(getValue, propertyInfo.PropertyType);
  23528. propertyInfo.SetValue(cdc, propertyValue);
  23529. }
  23530. }
  23531. crmClients.Add(cdc);
  23532. }
  23533. return Ok(JsonView(new
  23534. {
  23535. fileCount = files.Count,
  23536. UploadCount = seedConter.Count,
  23537. ApiResult = clients,
  23538. CrmClients = crmClients
  23539. }));
  23540. }
  23541. #endregion
  23542. #region 团组倒推表
  23543. /// <summary>
  23544. /// 倒推表基础数据
  23545. /// Init
  23546. /// </summary>
  23547. /// <returns></returns>
  23548. [HttpPost]
  23549. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23550. public async Task<IActionResult> PostInvertedListInit()
  23551. {
  23552. var viewData = await _invertedListRep._Init();
  23553. if (viewData.Code != 0)
  23554. {
  23555. return Ok(JsonView(false, viewData.Msg));
  23556. }
  23557. return Ok(JsonView(viewData.Data));
  23558. }
  23559. /// <summary>
  23560. /// 倒推表
  23561. /// Info
  23562. /// </summary>
  23563. /// <param name="dto"></param>
  23564. /// <returns></returns>
  23565. [HttpPost]
  23566. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23567. public async Task<IActionResult> PostInvertedListInfo(InvertedListCreateDto dto)
  23568. {
  23569. var viewData = await _invertedListRep._Info(dto.PortType, dto.DiId);
  23570. if (viewData.Code != 0)
  23571. {
  23572. return Ok(JsonView(false, viewData.Msg));
  23573. }
  23574. return Ok(JsonView(viewData.Data));
  23575. }
  23576. /// <summary>
  23577. /// 倒推表
  23578. /// Create
  23579. /// </summary>
  23580. /// <param name="dto"></param>
  23581. /// <returns></returns>
  23582. [HttpPost]
  23583. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23584. public async Task<IActionResult> PostInvertedListCreate(InvertedListCreateDto dto)
  23585. {
  23586. var viewData = await _invertedListRep._Create(dto.PortType, dto.DiId);
  23587. if (viewData.Code != 0)
  23588. {
  23589. return Ok(JsonView(false, viewData.Msg));
  23590. }
  23591. return Ok(JsonView(viewData.Data));
  23592. }
  23593. /// <summary>
  23594. /// 倒推表
  23595. /// Update
  23596. /// </summary>
  23597. /// <param name="dto"></param>
  23598. /// <returns></returns>
  23599. [HttpPost]
  23600. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23601. public async Task<IActionResult> PostInvertedListUpdate(InvertedListUpdateDto dto)
  23602. {
  23603. var viewData = await _invertedListRep._Update(dto);
  23604. if (viewData.Code != 0)
  23605. {
  23606. return Ok(JsonView(false, viewData.Msg));
  23607. }
  23608. return Ok(JsonView(viewData.Data));
  23609. }
  23610. /// <summary>
  23611. /// 倒推表
  23612. /// File Download
  23613. /// </summary>
  23614. /// <param name="dto"></param>
  23615. /// <returns></returns>
  23616. [HttpPost]
  23617. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23618. public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
  23619. {
  23620. var info2 = await _invertedListRep._Info(1, dto.DiId);
  23621. if (info2.Code != 0)
  23622. {
  23623. return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
  23624. }
  23625. var info1 = info2.Data as InvertedListInfoView;
  23626. var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
  23627. string teamName = "";
  23628. if (info != null) teamName = info.TeamName;
  23629. var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20250121.doc";
  23630. var doc = new Document();
  23631. var builder = new DocumentBuilder(doc);
  23632. #region old insert
  23633. ////载入模板
  23634. //var tempPath = $"{AppSettingsHelper.Get("WordBasePath")}Template/倒退表模板20200617.doc";
  23635. //Document doc = new Document(tempPath);
  23636. //DocumentBuilder builder = new DocumentBuilder(doc);
  23637. //利用键值对存放数据
  23638. //Dictionary<string, string> dic = new Dictionary<string, string>();
  23639. //dic.Add("TeamName", teamName);
  23640. //dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime()); //开始时间
  23641. //dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
  23642. //dic.Add("BPRemark", info1.ApprovalDataRemark);
  23643. //dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
  23644. //dic.Add("SQRemark", info1.ApprovalRemark);
  23645. //dic.Add("CPJtime", info1.IssueApprovalDt.ConvertToDatetime());
  23646. //dic.Add("CPJRemark", info1.IssueApprovalRemark);
  23647. ////dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
  23648. ////dic.Add("HZRemark", info1.ApplyPassportRemark);
  23649. //dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
  23650. //dic.Add("QZRemark", info1.VisaInformationRemark);
  23651. //dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
  23652. //dic.Add("SQQZRemark", info1.SendVisaRemark);
  23653. //dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
  23654. //dic.Add("CQRemark", info1.IssueVisaRemark);
  23655. //dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
  23656. //dic.Add("XQHRemark", info1.PreTripMeetingRemark);
  23657. //dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
  23658. //dic.Add("SJRemark", info1.AirportdDropOffRemark);
  23659. //#region 填充word模板书签内容
  23660. //foreach (var key in dic.Keys)
  23661. //{
  23662. // builder.MoveToBookmark(key);
  23663. // builder.Write(dic[key]);
  23664. //}
  23665. //#endregion
  23666. #endregion
  23667. #region New Insert
  23668. string titleFont = $"仿宋",
  23669. contentFont = $"仿宋";
  23670. var fontColor = Color.FromArgb(64, 64, 64);
  23671. //设置标题 团组名称
  23672. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  23673. builder.Font.Name = titleFont;
  23674. builder.Font.Color = fontColor;
  23675. builder.Font.Size = 12;
  23676. builder.Font.Bold = true;
  23677. builder.Writeln(teamName);
  23678. //设置副标题 团组出访时间
  23679. builder.Font.Size = 12;
  23680. builder.Writeln("出发时间:" + info1.AirportdDropOffDt.ConvertToDatetime());
  23681. builder.Writeln();
  23682. var backgroundColor = Color.FromArgb(199, 199, 199);
  23683. var table = builder.StartTable();
  23684. builder.InsertCell();
  23685. builder.CellFormat.Shading.BackgroundPatternColor = backgroundColor;
  23686. builder.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
  23687. builder.CellFormat.Borders.LineWidth = 1;
  23688. builder.CellFormat.Borders.Color = Color.FromArgb(183, 183, 183);
  23689. table.FirstRow.FirstCell.CellFormat.Width = 20; // 单位为百分比
  23690. builder.RowFormat.Height = 40;
  23691. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  23692. builder.Font.Name = contentFont;
  23693. builder.Font.Size = 12;
  23694. builder.Font.Bold = true;
  23695. builder.Font.Color = fontColor;
  23696. builder.Write("时间");
  23697. builder.InsertCell();
  23698. table.FirstRow.FirstCell.CellFormat.Width = 30; // 单位为百分比
  23699. builder.Write("流程");
  23700. builder.InsertCell();
  23701. table.FirstRow.FirstCell.CellFormat.Width = 50; // 单位为百分比
  23702. builder.Write("说明");
  23703. builder.EndRow();
  23704. //报批资料准备
  23705. if (info1.IsSelectedAirportd)
  23706. {
  23707. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDataDt.ConvertToDatetime(), "报批资料准备", info1.ApprovalDataRemark);
  23708. }
  23709. //报批/提供送签资料
  23710. if (info1.IsSelectedApprovalData)
  23711. {
  23712. InvertedListFileDownloadSetRow(builder, contentFont, info1.ApprovalDt.ConvertToDatetime(), "报批/提供送签资料", info1.ApprovalRemark);
  23713. }
  23714. //出批件护照办理
  23715. if (info1.IsSelectedIssueApproval)
  23716. {
  23717. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueApprovalDt.ConvertToDatetime(), "出批件\r\n护照办理", info1.IssueApprovalRemark);
  23718. }
  23719. //签证资料准备
  23720. if (info1.IsSelectedVisaInfo)
  23721. {
  23722. InvertedListFileDownloadSetRow(builder, contentFont, info1.VisaInformationDt.ConvertToDatetime(), "签证资料准备", info1.VisaInformationRemark);
  23723. }
  23724. //送签
  23725. if (info1.IsSelectedSendVisa)
  23726. {
  23727. InvertedListFileDownloadSetRow(builder, contentFont, info1.SendVisaDt.ConvertToDatetime(), "送签", info1.SendVisaRemark);
  23728. }
  23729. //出签
  23730. if (info1.IsSelectedIssueVisa)
  23731. {
  23732. InvertedListFileDownloadSetRow(builder, contentFont, info1.IssueVisaDt.ConvertToDatetime(), "出签", info1.IssueVisaRemark);
  23733. }
  23734. //机票
  23735. if (info1.IsSelectedAirTicket)
  23736. {
  23737. if (string.IsNullOrEmpty(info1.AirTicketDt)) info1.AirTicketDt = info1.IssueVisaDt;
  23738. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirTicketDt.ConvertToDatetime(), "机票", info1.AirTicketRemark);
  23739. }
  23740. //酒店
  23741. if (info1.IsSelectedHotel)
  23742. {
  23743. if (string.IsNullOrEmpty(info1.HotelDt)) info1.HotelDt = info1.IssueVisaDt;
  23744. InvertedListFileDownloadSetRow(builder, contentFont, info1.HotelDt.ConvertToDatetime(), "酒店", info1.HotelRemark);
  23745. }
  23746. //开行前会
  23747. if (info1.IsSelectedPreTripMeeting)
  23748. {
  23749. InvertedListFileDownloadSetRow(builder, contentFont, info1.PreTripMeetingDt.ConvertToDatetime(), "开行前会", info1.PreTripMeetingRemark);
  23750. }
  23751. //送机
  23752. if (info1.IsSelectedAirportdDropOff)
  23753. {
  23754. InvertedListFileDownloadSetRow(builder, contentFont, info1.AirportdDropOffDt.ConvertToDatetime(), "送机", info1.AirportdDropOffRemark);
  23755. }
  23756. builder.EndTable();
  23757. //table.PreferredWidth = PreferredWidth.FromPercent(100.00);
  23758. //table.AutoFit(AutoFitBehavior.FixedColumnWidths);
  23759. for (int i = 0; i < table.Rows.Count; i++)
  23760. {
  23761. var row = table.Rows[i];
  23762. //设置宽度
  23763. row.Cells[0].CellFormat.Width = 20.00;
  23764. row.Cells[1].CellFormat.Width = 30.00;
  23765. row.Cells[2].CellFormat.Width = 50.00;
  23766. if (i != 0)
  23767. {
  23768. //边框设置
  23769. InvertedListFileDownloadSetBorders(row.Cells, 0);
  23770. InvertedListFileDownloadSetBorders(row.Cells, 1);
  23771. InvertedListFileDownloadSetBorders(row.Cells, 2);
  23772. }
  23773. }
  23774. #region 页脚插入图片
  23775. // 创建页脚
  23776. Aspose.Words.HeaderFooter footer = new Aspose.Words.HeaderFooter(doc, HeaderFooterType.FooterPrimary);
  23777. doc.FirstSection.HeadersFooters.Add(footer);
  23778. Paragraph para = new Paragraph(doc);
  23779. para.ParagraphFormat.Alignment = ParagraphAlignment.Right;
  23780. footer.AppendChild(para);
  23781. builder.MoveTo(para);
  23782. string imagePath = "./Images/FMGJ_Log.png";
  23783. builder.InsertImage(imagePath);
  23784. #endregion
  23785. #endregion
  23786. var fileDir = AppSettingsHelper.Get("WordBasePath");
  23787. string fileName = $"{teamName}团出行准备流程表{CommonFun.GUID}.doc";
  23788. string filePath = fileDir + $@"InvertedList/{fileName}";
  23789. doc.Save(filePath);
  23790. string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
  23791. return Ok(JsonView(true, "操作成功!", Url));
  23792. }
  23793. private void InvertedListFileDownloadSetRow(DocumentBuilder builder, string fontName, string dateTime, string content, string reamrk)
  23794. {
  23795. var fontColor = Color.FromArgb(64, 64, 64);
  23796. builder.InsertCell();
  23797. builder.CellFormat.Shading.BackgroundPatternColor = Color.Empty;
  23798. builder.RowFormat.Height = 40;
  23799. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  23800. builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;
  23801. builder.Font.Name = fontName;
  23802. builder.Font.Size = 8;
  23803. builder.Font.Bold = true;
  23804. builder.Font.Color = fontColor;
  23805. builder.Write(dateTime);
  23806. builder.InsertCell();
  23807. builder.Font.Size = 9;
  23808. builder.Font.Bold = true;
  23809. builder.Font.Color = fontColor;
  23810. builder.Write(content);
  23811. builder.InsertCell();
  23812. builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
  23813. builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;
  23814. builder.Font.Size = 9;
  23815. builder.Font.Bold = false;
  23816. builder.Font.Color = fontColor;
  23817. builder.Write(reamrk);
  23818. builder.EndRow();
  23819. }
  23820. private void InvertedListFileDownloadSetBorders(CellCollection cell, int index)
  23821. {
  23822. cell[index].CellFormat.Borders.Top.LineStyle = Aspose.Words.LineStyle.None;
  23823. cell[index].CellFormat.Borders.Bottom.LineStyle = Aspose.Words.LineStyle.None;
  23824. cell[index].CellFormat.Borders.Left.LineStyle = Aspose.Words.LineStyle.None;
  23825. cell[index].CellFormat.Borders.Right.LineStyle = Aspose.Words.LineStyle.None;
  23826. //cell[index].CellFormat.Borders.Horizontal.LineStyle = Aspose.Words.LineStyle.None;
  23827. //cell[index].CellFormat.Borders.Vertical.LineStyle = Aspose.Words.LineStyle.None;
  23828. }
  23829. #endregion
  23830. #region 会务倒推表
  23831. /// <summary>
  23832. /// 会务倒推表
  23833. /// Init
  23834. /// </summary>
  23835. /// <returns></returns>
  23836. [HttpPost]
  23837. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23838. public async Task<IActionResult> InforRetrogressTableInit()
  23839. {
  23840. var groupData = await _groupRepository.PostShareGroupInfos(1);
  23841. if (groupData.Code == 0) return Ok(JsonView(groupData.Data));
  23842. return Ok(JsonView(false, groupData.Msg));
  23843. }
  23844. /// <summary>
  23845. /// 会务倒推表
  23846. /// ExcelDownload
  23847. /// </summary>
  23848. /// <param name="dto"></param>
  23849. /// <returns></returns>
  23850. [HttpPost]
  23851. [ApiLog("InforRetrogressTable", OperationEnum.Download)]
  23852. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23853. public async Task<IActionResult> InforRetrogressTableFileDownload(InforRetrogressTableFileDownloadDto dto)
  23854. {
  23855. var validator = new InforRetrogressTableFileDownloadDtoValidator();
  23856. var validatorRes = await validator.ValidateAsync(dto);
  23857. if (!validatorRes.IsValid)
  23858. {
  23859. StringBuilder sb = new StringBuilder();
  23860. foreach (var item in validatorRes.Errors)
  23861. {
  23862. sb.AppendLine(item.ErrorMessage);
  23863. }
  23864. return Ok(JsonView(false, sb.ToString()));
  23865. }
  23866. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().FirstAsync(x => x.Id == dto.GroupId);
  23867. if (groupInfo == null) return Ok(JsonView(false, $"该团组信息未填写!"));
  23868. //时间根据团组出访日期-接团录入日期的天数来判断用哪个模板
  23869. var days = groupInfo.VisitDate.Subtract(groupInfo.CreateTime).Days;
  23870. #region Excel
  23871. var tempPath = AppSettingsHelper.Get("ExcelTempPath");
  23872. var servicePath = AppSettingsHelper.Get("GrpFileBaseUrl");
  23873. var savePath = AppSettingsHelper.Get("ExcelBasePath") + "InforRetrogressTable/";
  23874. var ftpPath = AppSettingsHelper.Get("ExcelFtpPath") + "InforRetrogressTable/";
  23875. var fileNamePrefix = string.Empty;
  23876. if (days >= 30)
  23877. {
  23878. tempPath += $"会务工作倒推进度表(30天).xlsx";
  23879. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(30天)";
  23880. }
  23881. else if (days < 30 && days > 7)
  23882. {
  23883. tempPath += $"会务工作倒推进度表(15天).xlsx";
  23884. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(15天)";
  23885. }
  23886. else if (days <= 7)
  23887. {
  23888. tempPath += $"会务工作倒推进度表(7天).xlsx";
  23889. fileNamePrefix = $"{groupInfo.TeamName}_会务工作倒推进度表(7天)";
  23890. }
  23891. var fileName = $"{fileNamePrefix}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
  23892. fileName = CommonFun.ValidFileName(fileName);
  23893. //载入模板
  23894. WorkbookDesigner designer = new WorkbookDesigner();
  23895. designer.Workbook = new Workbook(tempPath);
  23896. designer.Process();
  23897. if (!Directory.Exists(savePath))
  23898. {
  23899. Directory.CreateDirectory(savePath);
  23900. }
  23901. string serverPath = $"{savePath}{fileName}";
  23902. designer.Workbook.Save(serverPath);
  23903. string rst = $"{servicePath}{ftpPath}{fileName}";
  23904. #endregion
  23905. return Ok(JsonView(new { url = rst }));
  23906. }
  23907. #endregion
  23908. #region 三公签证费用(签证费、代办费)
  23909. /// <summary>
  23910. /// 三公签证费用(签证费、代办费)
  23911. /// List
  23912. /// </summary>
  23913. /// <returns></returns>
  23914. [HttpPost]
  23915. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23916. public async Task<IActionResult> PostVisaFeeList(VisaFeeListDto _dto)
  23917. {
  23918. return Ok(await _visaFeeInfoRep.List(_dto.PortType, _dto.DiId));
  23919. }
  23920. /// <summary>
  23921. /// 三公签证费用(签证费、代办费)
  23922. /// Add Or Update
  23923. /// </summary>
  23924. /// <returns></returns>
  23925. [HttpPost]
  23926. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23927. public async Task<IActionResult> PostVisaFeeAddAndUpdate(VisaFeeAddAndUpdateDto _dto)
  23928. {
  23929. var _view = await _visaFeeInfoRep.Update(_dto);
  23930. if (_view.Code != 0)
  23931. {
  23932. return Ok(JsonView(false, _view.Msg));
  23933. }
  23934. return Ok(JsonView(true, _view.Msg));
  23935. }
  23936. #endregion
  23937. #region 酒店询价
  23938. /// <summary>
  23939. /// 酒店询价
  23940. /// Init
  23941. /// </summary>
  23942. /// <returns></returns>
  23943. [HttpPost]
  23944. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23945. public async Task<IActionResult> PostHotelInquiryInit()
  23946. {
  23947. var res = await _hotelInquiryRep._Init();
  23948. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23949. return Ok(JsonView(true, res.Msg, res.Data));
  23950. }
  23951. /// <summary>
  23952. /// 酒店询价
  23953. /// page Item
  23954. /// </summary>
  23955. /// <param name="_dto"></param>
  23956. /// <returns></returns>
  23957. [HttpPost]
  23958. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23959. public async Task<IActionResult> PostHotelInquiryPageItem(HotelInquiryPageItemDto _dto)
  23960. {
  23961. var res = await _hotelInquiryRep._PageItem(_dto.PageIndex, _dto.PageSize, _dto.PortType, _dto.DiId);
  23962. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23963. var view = res.Data as PageDataViewBase;
  23964. return Ok(JsonView(true, res.Msg, view.Data, view.Total));
  23965. }
  23966. /// <summary>
  23967. /// 酒店询价
  23968. /// info
  23969. /// </summary>
  23970. /// <param name="_dto"></param>
  23971. /// <returns></returns>
  23972. [HttpPost]
  23973. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23974. public async Task<IActionResult> PostHotelInquiryInfo(HotelInquiryInfoDto _dto)
  23975. {
  23976. var res = await _hotelInquiryRep._Info(_dto.PortType, _dto.Id);
  23977. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23978. return Ok(JsonView(true, res.Msg, res.Data));
  23979. }
  23980. /// <summary>
  23981. /// 酒店询价
  23982. /// Add Or Edit
  23983. /// </summary>
  23984. /// <param name="_dto"></param>
  23985. /// <returns></returns>
  23986. [HttpPost]
  23987. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  23988. public async Task<IActionResult> PostHotelInquiryAddOrEdit(HotelInquiryAddOrEditDto _dto)
  23989. {
  23990. var res = await _hotelInquiryRep._AddOrEdit(_dto);
  23991. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  23992. return Ok(JsonView(true, res.Msg, res.Data));
  23993. }
  23994. /// <summary>
  23995. /// 酒店询价
  23996. /// Del
  23997. /// </summary>
  23998. /// <param name="_dto"></param>
  23999. /// <returns></returns>
  24000. [HttpPost]
  24001. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24002. public async Task<IActionResult> PostHotelInquiryDel(HotelInquiryDelDto _dto)
  24003. {
  24004. var res = await _hotelInquiryRep._Del(_dto.Id, _dto.DeleteUserId);
  24005. if (res.Code != 0) return Ok(JsonView(false, res.Msg));
  24006. return Ok(JsonView(true, res.Msg, res.Data));
  24007. }
  24008. #endregion
  24009. #region 下载匹配op行程单
  24010. /// <summary>
  24011. /// 匹配op行程单
  24012. /// Init
  24013. /// </summary>
  24014. /// <param name="dto">团组列表请求dto</param>
  24015. /// <returns></returns>
  24016. [HttpPost]
  24017. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24018. public async Task<IActionResult> PostMateOpGroupInit(MateOpGroupInitDto dto)
  24019. {
  24020. Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  24021. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  24022. bool isDepStatus = await GeneralMethod.IsMarketingStaff(dto.CurrUserId);
  24023. List<Grp_DelegationInfo> groupInfos = new List<Grp_DelegationInfo>();
  24024. groupInfos = _sqlSugar.Queryable<Grp_DelegationInfo>()
  24025. .Where(it => it.IsDel == 0)
  24026. .WhereIF(isDepStatus, it => it.JietuanOperator == dto.CurrUserId)
  24027. .OrderByDescending(it => it.VisitStartDate)
  24028. .ToList();
  24029. if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无和你相关的团组信息!"));
  24030. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  24031. var diids = groupInfos.Select(it => it.Id).ToList();
  24032. List<string> countrys = new List<string>();
  24033. foreach (var item in country)
  24034. {
  24035. var data = _groupRepository.FormartTeamName(item);
  24036. var dataArray = _groupRepository.GroupSplitCountry(data);
  24037. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  24038. }
  24039. countrys = countrys.Where(it => !string.IsNullOrEmpty(it)).Distinct().ToList();
  24040. List<string> areaArray = new List<string>(); //GetGroupCityLine
  24041. var areaItem = GeneralMethod.GetGroupCityLineItem(diids, "-");
  24042. foreach (var item in areaItem)
  24043. {
  24044. string areaStr = item.Value;
  24045. if (!string.IsNullOrEmpty(areaStr))
  24046. {
  24047. string[] str1 = areaStr.Split("-");
  24048. if (str1.Length > 0)
  24049. {
  24050. areaArray.AddRange(str1);
  24051. }
  24052. }
  24053. }
  24054. if (areaArray.Count > 0) areaArray = areaArray.Distinct().ToList();
  24055. var cityDatas = _sqlSugar.Queryable<Sys_Cities>()
  24056. .Where(it => it.IsDel == 0 && areaArray.Contains(it.Name_CN))
  24057. .Select(it => new { id = it.Id, parentId = it.CountriesId, name = it.Name_CN })
  24058. .ToList();
  24059. List<int> countriesIds = cityDatas.Select(it => it.parentId).ToList();
  24060. var countriesDatas = _sqlSugar.Queryable<Sys_Countries>()
  24061. .Where(it => countriesIds.Contains(it.Id))
  24062. .Select(it => new { it.Id, Name = it.Name_CN })
  24063. .ToList();
  24064. var teamNames = groupInfos.Where(it => !string.IsNullOrEmpty(it.TeamName))
  24065. .Select(it => it.TeamName).ToList();
  24066. stopwatch.Stop();
  24067. return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", new { teamNames, countriesDatas, citiesDatas = cityDatas }));
  24068. }
  24069. ///// <summary>
  24070. ///// 匹配op行程单
  24071. ///// Init 查询区域数据
  24072. ///// </summary>
  24073. ///// <param name="dto">团组列表请求dto</param>
  24074. ///// <returns></returns>
  24075. //[HttpPost]
  24076. //[ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24077. //public async Task<IActionResult> PostMateOpGroupCountryChangeData(MateOpGroupCountryChangeDataDto dto)
  24078. //{
  24079. // Stopwatch stopwatch = Stopwatch.StartNew(); // 创建并启动Stopwatch
  24080. // List<Sys_Cities> cityDatas = new List<Sys_Cities>();
  24081. // string countriesDataStr = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>("CityDatas");//string 取
  24082. // if (string.IsNullOrEmpty(countriesDataStr))
  24083. // {
  24084. // cityDatas = await _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0).ToListAsync();
  24085. // TimeSpan ts = DateTime.Now.AddHours(2).TimeOfDay; //设置redis 过期时间 2
  24086. // await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync<string>("CountriesDatas", JsonConvert.SerializeObject(cityDatas), ts);//string 存
  24087. // }
  24088. // else
  24089. // {
  24090. // cityDatas = JsonConvert.DeserializeObject<List<Sys_Cities>>(countriesDataStr);
  24091. // }
  24092. // var provinceData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 1).ToList();
  24093. // var citiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 2).ToList();
  24094. // var countiesData = cityDatas.Where(it => it.CountriesId == dto.CountriesId && it.Level == 3).ToList();
  24095. // List<dynamic> childList = new List<dynamic>();
  24096. // int parentId = dto.CountriesId;
  24097. // if (provinceData.Count > 1)
  24098. // {
  24099. // foreach (var item1 in provinceData)
  24100. // {
  24101. // List<dynamic> childList1 = new List<dynamic>();
  24102. // var citiesData1 = citiesData.Where(it => it.ParentId == item1.Id).ToList();
  24103. // foreach (var item2 in citiesData1)
  24104. // {
  24105. // List<dynamic> childList2 = new List<dynamic>();
  24106. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  24107. // foreach (var item3 in countiesData1)
  24108. // {
  24109. // childList2.Add(new
  24110. // {
  24111. // id = item3.Id,
  24112. // parentId = item2.Id,
  24113. // level = "district",
  24114. // name = item3.Name_CN,
  24115. // });
  24116. // }
  24117. // childList1.Add(new
  24118. // {
  24119. // id = item2.Id,
  24120. // parentId = item1.Id,
  24121. // level = "city",
  24122. // name = item2.Name_CN,
  24123. // childList = childList2
  24124. // });
  24125. // }
  24126. // childList.Add(new
  24127. // {
  24128. // id = item1.Id,
  24129. // parentId = parentId,
  24130. // level = "province",
  24131. // name = item1.Name_CN,
  24132. // childList = childList1
  24133. // });
  24134. // }
  24135. // //城市
  24136. // var citiesData2 = citiesData.Where(it => it.ParentId == 0).ToList();
  24137. // foreach (var item2 in citiesData2)
  24138. // {
  24139. // List<dynamic> childList22 = new List<dynamic>();
  24140. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  24141. // foreach (var item3 in countiesData1)
  24142. // {
  24143. // childList22.Add(new
  24144. // {
  24145. // id = item3.Id,
  24146. // parentId = item2.Id,
  24147. // level = "district",
  24148. // name = item3.Name_CN,
  24149. // });
  24150. // }
  24151. // childList.Add(new
  24152. // {
  24153. // id = item2.Id,
  24154. // parentId = parentId,
  24155. // level = "city",
  24156. // name = item2.Name_CN,
  24157. // childList = childList22
  24158. // });
  24159. // }
  24160. // }
  24161. // else
  24162. // {
  24163. // foreach (var item2 in citiesData)
  24164. // {
  24165. // string cname = item2.Name_CN;
  24166. // List<dynamic> childList1 = new List<dynamic>();
  24167. // var countiesData1 = countiesData.Where(it => it.ParentId == item2.Id).ToList();
  24168. // foreach (var item3 in countiesData1)
  24169. // {
  24170. // childList1.Add(new
  24171. // {
  24172. // Id = item3.Id,
  24173. // parentId = item2.Id,
  24174. // level = "district",
  24175. // name = item3.Name_CN
  24176. // });
  24177. // }
  24178. // childList.Add(new
  24179. // {
  24180. // id = item2.Id,
  24181. // parentId = parentId,
  24182. // level = "city",
  24183. // name = item2.Name_CN,
  24184. // childList = childList1
  24185. // });
  24186. // }
  24187. // }
  24188. // stopwatch.Stop();
  24189. // return Ok(JsonView(true, $"操作成功,耗时{stopwatch.ElapsedMilliseconds} ms", childList));
  24190. //}
  24191. /// <summary>
  24192. /// 匹配op行程单
  24193. /// 接团信息列表 Page
  24194. /// </summary>
  24195. /// <param name="dto">团组列表请求dto</param>
  24196. /// <returns></returns>
  24197. [HttpPost]
  24198. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24199. public async Task<IActionResult> PostMateOpGroupPageList(MateOpGroupPageListDto dto)
  24200. {
  24201. var swatch = new Stopwatch();
  24202. swatch.Start();
  24203. #region 参数验证
  24204. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  24205. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  24206. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  24207. #region 页面操作权限验证
  24208. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  24209. if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
  24210. #endregion
  24211. #endregion
  24212. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  24213. {
  24214. var _view = await GeneralMethod.MateOpGroupPageListRedis();
  24215. //string sqlWhere = "";
  24216. if (!string.IsNullOrEmpty(dto.Country))
  24217. {
  24218. _view = _view.Where(x => !string.IsNullOrEmpty(x.VisitCountry) && x.VisitCountry.Contains(dto.Country)).ToList();
  24219. }
  24220. if (!string.IsNullOrEmpty(dto.Area))
  24221. {
  24222. _view = _view.Where(x => !string.IsNullOrEmpty(x.RouteCity) && x.RouteCity.Contains(dto.Area)).ToList();
  24223. }
  24224. if (!string.IsNullOrEmpty(dto.TeamName))
  24225. {
  24226. _view = _view.Where(x => !string.IsNullOrEmpty(x.TeamName) && x.TeamName.Contains(dto.TeamName)).ToList();
  24227. }
  24228. int startIndex = (dto.PageIndex - 1) * dto.PageSize; // 计算开始的索引
  24229. int endIndex = startIndex + dto.PageSize - 1; // 计算结束的索引
  24230. var _view1 = _view.Skip(startIndex).Take(endIndex).ToList();
  24231. swatch.Stop();
  24232. return Ok(JsonView(true, $"查询成功!耗时 {swatch.ElapsedMilliseconds} ms", _view1, _view.Count));
  24233. }
  24234. else
  24235. {
  24236. return Ok(JsonView(false, "查询失败"));
  24237. }
  24238. }
  24239. /// <summary>
  24240. /// 匹配op行程单
  24241. /// 行程单下载
  24242. /// </summary>
  24243. /// <param name="dto">团组列表请求dto</param>
  24244. /// <returns></returns>
  24245. [HttpPost]
  24246. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24247. public async Task<IActionResult> PostMateOpGroupDownload(MateOpGroupDownloadDto dto)
  24248. {
  24249. #region 参数验证
  24250. if (dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
  24251. if (dto.PageId < 1) return Ok(JsonView(false, "页面Id为空"));
  24252. PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
  24253. #region 页面操作权限验证
  24254. pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(dto.UserId, dto.PageId);
  24255. if (pageFunAuthView.FilesDownloadAuth == 0) return Ok(JsonView(false, "您没有文件下载权限"));
  24256. #endregion
  24257. #endregion
  24258. if (dto.PortType == 1 || dto.PortType == 2 || dto.PortType == 3) // web/Android
  24259. {
  24260. var res = ExportTravel(new ExportTravelDto() { Diid = dto.diId });
  24261. return Ok(res.GetType().GetProperty("Value").GetValue(res, null));
  24262. }
  24263. else
  24264. {
  24265. return Ok(JsonView(false, "下载失败!"));
  24266. }
  24267. }
  24268. #endregion
  24269. #region 国家信息 数据 注释
  24270. //[HttpPost]
  24271. //public async Task<IActionResult> LoadCitiesInitData(List<int> dto)
  24272. //{
  24273. // List<Grp_GroupsTaskAssignment> infos = new List<Grp_GroupsTaskAssignment>();
  24274. // foreach (var item in dto)
  24275. // {
  24276. // infos.Add(new Grp_GroupsTaskAssignment()
  24277. // {
  24278. // DIId = item,
  24279. // CTId = 82,
  24280. // UId = 248,
  24281. // IsEnable = 1,
  24282. // CreateUserId = 233,
  24283. // CreateTime = DateTime.Now,
  24284. // IsDel = 0
  24285. // });
  24286. // infos.Add(new Grp_GroupsTaskAssignment()
  24287. // {
  24288. // DIId = item,
  24289. // CTId = 82,
  24290. // UId = 286,
  24291. // IsEnable = 1,
  24292. // CreateUserId = 233,
  24293. // CreateTime = DateTime.Now,
  24294. // IsDel = 0
  24295. // });
  24296. // }
  24297. // int add = _sqlSugar.Insertable<Grp_GroupsTaskAssignment>(infos).ExecuteCommand();
  24298. // return Ok("操作成功");
  24299. //}
  24300. //public class paramJsonDto
  24301. //{
  24302. // public List<CountriesInfo> str { get; set; }
  24303. //}
  24304. //[HttpPost]
  24305. //public async Task<IActionResult> LoadCitiesInitData(paramJsonDto dto)
  24306. //{
  24307. // //List<CountriesInfo> infos = new List<CountriesInfo>();
  24308. // //infos = JsonConvert.DeserializeObject<List<CountriesInfo>>(dto.str);
  24309. // List<Sys_Cities> cities = new List<Sys_Cities>();
  24310. // List<Sys_Cities> districts = new List<Sys_Cities>();
  24311. // var counties = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  24312. // _sqlSugar.BeginTran();
  24313. // int countitiesIndex = 0;
  24314. // foreach (var item in dto.str)
  24315. // {
  24316. // dynamic data = item.c;
  24317. // int countriesId = counties.Find(it => it.Name_CN.Equals(item.cn))?.Id ?? 0;
  24318. // if (data != null)
  24319. // {
  24320. // countitiesIndex++;
  24321. // foreach (var item1 in data)
  24322. // {
  24323. // string cnname = item1.cn;
  24324. // string enname = item1.en;
  24325. // Sys_Cities provinceInfo = new Sys_Cities()
  24326. // {
  24327. // CountriesId = countriesId,
  24328. // Name_CN = cnname,
  24329. // Name_EN = enname,
  24330. // ParentId = 0,
  24331. // IsCapital = 1,
  24332. // CreateUserId = 208,
  24333. // CreateTime = DateTime.Now,
  24334. // IsDel = 0
  24335. // };
  24336. // if (item1.lv == "province") //省份
  24337. // {
  24338. // provinceInfo.Level = 1;
  24339. // int provinceId = 0;
  24340. // var provinceInfo1 = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(cnname)).First();
  24341. // if (provinceInfo1 != null) provinceId = provinceInfo1.Id;
  24342. // else provinceId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  24343. // var data1 = item1.c;
  24344. // foreach (var item2 in data1)
  24345. // {
  24346. // if (item2.lv == "city")
  24347. // {
  24348. // string citycnname = item2.cn;
  24349. // string cityenname = item2.en;
  24350. // Sys_Cities cityInfo = new Sys_Cities()
  24351. // {
  24352. // CountriesId = countriesId,
  24353. // ParentId = provinceId,
  24354. // Level = 2,
  24355. // Name_CN = citycnname,
  24356. // Name_EN = cityenname,
  24357. // IsCapital = 1,
  24358. // CreateUserId = 208,
  24359. // CreateTime = DateTime.Now,
  24360. // IsDel = 0
  24361. // };
  24362. // if (item2.c != null)
  24363. // {
  24364. // int cityId = 0;
  24365. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 2 && it.Name_CN.Equals(citycnname)).First();
  24366. // if (citiesInfo != null) cityId = citiesInfo.Id;
  24367. // else cityId = _sqlSugar.Insertable<Sys_Cities>(cityInfo).ExecuteReturnIdentity();
  24368. // foreach (var item3 in item2.c)
  24369. // {
  24370. // if (item3.lv == "district")
  24371. // {
  24372. // var districtInfo = new Sys_Cities()
  24373. // {
  24374. // CountriesId = countriesId,
  24375. // Name_CN = item3.cn,
  24376. // Name_EN = item3.en,
  24377. // Level = 3,
  24378. // ParentId = cityId,
  24379. // IsCapital = 1,
  24380. // CreateUserId = 208,
  24381. // CreateTime = DateTime.Now,
  24382. // IsDel = 0
  24383. // };
  24384. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  24385. // //{
  24386. // districts.Add(districtInfo);
  24387. // //}
  24388. // }
  24389. // }
  24390. // }
  24391. // else
  24392. // {
  24393. // //if (cities.Find(it => it.CountriesId == countriesId && it.ParentId == provinceId && it.Name_CN.Equals(citycnname)) == null)
  24394. // //{
  24395. // cities.Add(cityInfo);
  24396. // //}
  24397. // }
  24398. // }
  24399. // }
  24400. // }
  24401. // else if (item1.lv == "city")//城市
  24402. // {
  24403. // provinceInfo.Level = 2;
  24404. // if (item1.c != null)
  24405. // {
  24406. // int cityId = 0;
  24407. // var citiesInfo = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.CountriesId == countriesId && it.Level == 1 && it.Name_CN.Equals(provinceInfo.Name_CN)).First();
  24408. // if (citiesInfo != null) cityId = citiesInfo.Id;
  24409. // else cityId = _sqlSugar.Insertable<Sys_Cities>(provinceInfo).ExecuteReturnIdentity();
  24410. // foreach (var item3 in item1.c)
  24411. // {
  24412. // if (item3.lv == "district")
  24413. // {
  24414. // var districtInfo = new Sys_Cities()
  24415. // {
  24416. // CountriesId = countriesId,
  24417. // Name_CN = item3.cn,
  24418. // Name_EN = item3.en,
  24419. // Level = 3,
  24420. // ParentId = cityId,
  24421. // IsCapital = 1,
  24422. // CreateUserId = 208,
  24423. // CreateTime = DateTime.Now,
  24424. // IsDel = 0
  24425. // };
  24426. // //if (districts.Find(it => it.CountriesId == countriesId && it.ParentId == cityId && it.Name_CN.Equals(districtInfo.Name_CN)) == null)
  24427. // //{
  24428. // districts.Add(districtInfo);
  24429. // //}
  24430. // }
  24431. // }
  24432. // }
  24433. // else
  24434. // {
  24435. // //if (cities.Find(it => it.CountriesId == countriesId && it.Name_CN.Equals(provinceInfo.Name_CN)) == null)
  24436. // //{
  24437. // cities.Add(provinceInfo);
  24438. // //}
  24439. // }
  24440. // }
  24441. // }
  24442. // }
  24443. // }
  24444. // var procinceDatas = _sqlSugar.Queryable<Sys_Cities>().ToList();
  24445. // cities = cities.Distinct().ToList();
  24446. // districts = districts.Distinct().ToList();
  24447. // var citiesDatas = cities.Where(it => it.Level == 2).ToList();
  24448. // //var districtDatas = cities.Where(it => it.Level == 3).ToList();
  24449. // cities.AddRange(districts);
  24450. // var citiesAdd = _sqlSugar.Insertable<Sys_Cities>(cities).ExecuteReturnIdentity();
  24451. // //_sqlSugar.RollbackTran();
  24452. // _sqlSugar.CommitTran();
  24453. // return Ok(JsonView(false, "操作成功!"));
  24454. //}
  24455. //[HttpPost]
  24456. //public async Task<IActionResult> LoadCitiesInitInfo(CounrtiesDto dto)
  24457. //{
  24458. // List<CountitiesInfo> infos = dto.MyProperty;
  24459. // List<Sys_Cities> cityInfos = new List<Sys_Cities>();
  24460. // _sqlSugar.BeginTran();
  24461. // var countities = _sqlSugar.Queryable<Sys_Countries>().Where(it => it.IsDel == 0).ToList();
  24462. // var citities = _sqlSugar.Queryable<Sys_Cities>().Where(it => it.IsDel == 0 && it.Level == 2).ToList();
  24463. // foreach (var item in infos)
  24464. // {
  24465. // var countryInfo = countities.Where(it => it.ThreeCode.Equals(item.country_code3)).FirstOrDefault();
  24466. // if (countryInfo != null)
  24467. // {
  24468. // var cityInfo = citities.Where(it => it.CountriesId == countryInfo.Id).ToList();
  24469. // var cityInfo1 = cityInfo.Where(it => item.capital_name_chinese.Contains(it.Name_CN)).FirstOrDefault();
  24470. // if (cityInfo1 != null)
  24471. // {
  24472. // cityInfo1.IsCapital = 0;
  24473. // cityInfos.Add(cityInfo1);
  24474. // }
  24475. // }
  24476. // }
  24477. // var update = _sqlSugar.Updateable<Sys_Cities>(cityInfos)
  24478. // .UpdateColumns(it => it.IsCapital)
  24479. // .WhereColumns(it => it.Id)
  24480. // .ExecuteCommand();
  24481. // //_sqlSugar.RollbackTran();
  24482. // _sqlSugar.CommitTran();
  24483. // return Ok(JsonView(false, "操作成功!"));
  24484. //}
  24485. //public class CounrtiesDto
  24486. //{
  24487. // public List<CountitiesInfo> MyProperty { get; set; }
  24488. //}
  24489. //public class CountitiesInfo
  24490. //{
  24491. // /// <summary>
  24492. // /// 圣约翰
  24493. // /// </summary>
  24494. // public string capital_name_chinese { get; set; }
  24495. // /// <summary>
  24496. // ///
  24497. // /// </summary>
  24498. // public string capital_name { get; set; }
  24499. // /// <summary>
  24500. // ///
  24501. // /// </summary>
  24502. // public string country_type { get; set; }
  24503. // /// <summary>
  24504. // /// 安提瓜和巴布达
  24505. // /// </summary>
  24506. // public string country_name_chinese { get; set; }
  24507. // /// <summary>
  24508. // /// 安提瓜和巴布达
  24509. // /// </summary>
  24510. // public string country_name_chinese_short { get; set; }
  24511. // /// <summary>
  24512. // /// 安提瓜和巴布达
  24513. // /// </summary>
  24514. // public string country_name_chinese_UN { get; set; }
  24515. // /// <summary>
  24516. // ///
  24517. // /// </summary>
  24518. // public string country_name_english_abbreviation { get; set; }
  24519. // /// <summary>
  24520. // ///
  24521. // /// </summary>
  24522. // public string country_name_english_formal { get; set; }
  24523. // /// <summary>
  24524. // ///
  24525. // /// </summary>
  24526. // public string country_name_english_UN { get; set; }
  24527. // /// <summary>
  24528. // ///
  24529. // /// </summary>
  24530. // public string continent_name { get; set; }
  24531. // /// <summary>
  24532. // ///
  24533. // /// </summary>
  24534. // public string subregion_name { get; set; }
  24535. // /// <summary>
  24536. // ///
  24537. // /// </summary>
  24538. // public string country_code2 { get; set; }
  24539. // /// <summary>
  24540. // ///
  24541. // /// </summary>
  24542. // public string country_code3 { get; set; }
  24543. // /// <summary>
  24544. // ///
  24545. // /// </summary>
  24546. // public string phone_code { get; set; }
  24547. //}
  24548. //public class CountriesInfo : BasicInfo
  24549. //{
  24550. // public List<CitiesInfo> c { get; set; }
  24551. //}
  24552. //public class CitiesInfo : BasicInfo
  24553. //{
  24554. // public List<AreaInfo> c { get; set; }
  24555. //}
  24556. //public class AreaInfo : BasicInfo
  24557. //{
  24558. // public List<AreaInfo> c { get; set; }
  24559. //}
  24560. //public class BasicInfo
  24561. //{
  24562. // public string code { get; set; }
  24563. // public string cn { get; set; }
  24564. // public string lv { get; set; }
  24565. // public string en { get; set; }
  24566. //}
  24567. #endregion
  24568. #region 查看邀请方
  24569. /// <summary>
  24570. /// 查看邀请方
  24571. /// 邀请方信息 Init
  24572. /// </summary>
  24573. /// <param name="dto"></param>
  24574. /// <returns></returns>
  24575. [HttpPost]
  24576. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24577. public async Task<IActionResult> PostGroupLinkInvitingUnitNameInit(GroupLinkInvitingUnitNameInitDto dto)
  24578. {
  24579. string sqlWhere = string.Empty;
  24580. if (!string.IsNullOrEmpty(dto.Search))
  24581. {
  24582. sqlWhere = string.Format($@" And UnitName Like '%{dto.Search}%'");
  24583. }
  24584. string sql = string.Format($@"Select
  24585. ROW_NUMBER() Over(Order By Id desc) As Row_Number,
  24586. Id,
  24587. UnitName
  24588. From Res_InvitationOfficialActivityData
  24589. Where IsDel = 0
  24590. And (UnitName != '' Or UnitName != null) {sqlWhere}");
  24591. RefAsync<int> total = 0;
  24592. var _views = await _sqlSugar.SqlQueryable<GroupLinkInvitingUnitNameInitView>(sql).ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24593. return Ok(JsonView(true, MsgTips.Succeed, _views, total));
  24594. }
  24595. /// <summary>
  24596. /// 查看邀请方
  24597. /// 国家信息 Init
  24598. /// </summary>
  24599. /// <param name="dto"></param>
  24600. /// <returns></returns>
  24601. [HttpPost]
  24602. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24603. public async Task<IActionResult> PostGroupLinkInvitingCountryInit(GroupLinkInvitingUnitNameInitDto dto)
  24604. {
  24605. var groupInfos = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0).OrderByDescending(it => it.CreateUserId).ToListAsync();
  24606. var country = groupInfos.Select(it => it.VisitCountry).ToList();
  24607. var diids = groupInfos.Select(it => it.Id).ToList();
  24608. List<string> countrys = new List<string>();
  24609. foreach (var item in country)
  24610. {
  24611. var data = _groupRepository.FormartTeamName(item);
  24612. var dataArray = _groupRepository.GroupSplitCountry(data);
  24613. if (dataArray.Count > 0) countrys.AddRange(dataArray);
  24614. }
  24615. countrys = countrys.Distinct().ToList();
  24616. for (int i = 0; i < countrys.Count; i++)
  24617. {
  24618. string item = countrys[i];
  24619. if (string.IsNullOrEmpty(item) || item.Contains("-"))
  24620. {
  24621. countrys.Remove(item);
  24622. i--;
  24623. }
  24624. }
  24625. RefAsync<int> total = 0;
  24626. var countyDatas = await _sqlSugar.Queryable<Sys_Countries>()
  24627. .Where(it => countrys.Contains(it.Name_CN))
  24628. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  24629. .Select(it => new { id = it.Id, name = it.Name_CN })
  24630. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24631. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  24632. }
  24633. /// <summary>
  24634. /// 查看邀请方
  24635. /// 城市信息 Init
  24636. /// </summary>
  24637. /// <param name="dto"></param>
  24638. /// <returns></returns>
  24639. [HttpPost]
  24640. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24641. public async Task<IActionResult> PostGroupLinkInvitingCityInit(GroupLinkInvitingCityInitDto dto)
  24642. {
  24643. if (dto.CountiesId < 1) return Ok(JsonView(false, "请传入有效的国家Id"));
  24644. RefAsync<int> total = 0;
  24645. var countyDatas = await _sqlSugar.Queryable<Sys_Cities>()
  24646. .Where(it => it.CountriesId == dto.CountiesId)
  24647. .WhereIF(!string.IsNullOrEmpty(dto.Search), it => it.Name_CN.Contains(dto.Search))
  24648. .OrderBy(it => new { IsCapital = SqlFunc.Asc(it.IsCapital), Id = SqlFunc.Asc(it.Id) })
  24649. .Select(it => new { id = it.Id, name = it.Name_CN })
  24650. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24651. return Ok(JsonView(true, MsgTips.Succeed, countyDatas, total));
  24652. }
  24653. /// <summary>
  24654. /// 查看邀请方
  24655. /// 团组名称 Init
  24656. /// </summary>
  24657. /// <param name="dto"></param>
  24658. /// <returns></returns>
  24659. [HttpPost]
  24660. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24661. public async Task<IActionResult> PostGroupLinkInvitingGroupInit(GroupLinkInvitingDto dto)
  24662. {
  24663. var watch = new Stopwatch();
  24664. watch.Start();
  24665. RefAsync<int> total = 0;
  24666. var countyDatas = await _sqlSugar.Queryable<Res_OfficialActivities>()
  24667. .InnerJoin<Grp_DelegationInfo>((oa, di) => oa.DiId == di.Id)
  24668. .Where((oa, di) => oa.IsDel == 0)
  24669. .WhereIF(!string.IsNullOrEmpty(dto.Search), (oa, di) => di.TeamName.Contains(dto.Search))
  24670. .OrderBy((oa, di) => new { id = SqlFunc.Desc(di.Id) })
  24671. .Select((oa, di) => new { id = di.Id, name = di.TeamName })
  24672. .Distinct()
  24673. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24674. watch.Stop();
  24675. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", countyDatas, total));
  24676. }
  24677. /// <summary>
  24678. /// 查看邀请方
  24679. /// 团组 & 邀请方信息
  24680. /// </summary>
  24681. /// <param name="dto"></param>
  24682. /// <returns></returns>
  24683. [HttpPost]
  24684. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  24685. public async Task<IActionResult> PostGroupLinkInvitingPageList(GroupLinkInvitingPageListDto dto)
  24686. {
  24687. var watch = new Stopwatch();
  24688. watch.Start();
  24689. RefAsync<int> total = 0;
  24690. var infos = await _sqlSugar.Queryable<GroupLinkInvitingPageListView>()
  24691. .AS("Grp_DelegationInfo")
  24692. .Includes(x => x.InvitingInfos)
  24693. .Where(x => x.IsDel == 0 && x.InvitingInfos.Any(z => z.IsDel == 0))
  24694. .WhereIF(!string.IsNullOrEmpty(dto.Counrty), x => x.VisitCountry.Contains(dto.Counrty))
  24695. .WhereIF(!string.IsNullOrEmpty(dto.Area), x => x.InvitingInfos.Any(z => z.Area.Contains(dto.Area))) //
  24696. .WhereIF(!string.IsNullOrEmpty(dto.TeamName), x => x.TeamName.Contains(dto.TeamName)) //
  24697. .WhereIF(!string.IsNullOrEmpty(dto.UnitName), x => x.InvitingInfos.Any(z => z.Client.Contains(dto.UnitName)))
  24698. .OrderBy(x => new { JietuanTime = SqlFunc.Desc(x.VisitStartDate) })
  24699. .ToPageListAsync(dto.PageIndex, dto.PageSize, total);
  24700. var userDatas = _sqlSugar.Queryable<Sys_Users>().Where(x => x.IsDel == 0).ToList();
  24701. var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
  24702. infos.ForEach(x =>
  24703. {
  24704. x.TeamDid = setDatas.Find(y => int.Parse(x.TeamDid) == y.Id)?.Name ?? "-";
  24705. x.JietuanOperator = userDatas.Find(y => int.Parse(x.JietuanOperator) == y.Id)?.CnName ?? "-";
  24706. x.TeamLevSId = setDatas.Find(y => int.Parse(x.TeamLevSId) == y.Id)?.Name ?? "-";
  24707. x.InvitingInfos = x.InvitingInfos.Where(it => it.IsDel == 0).ToList();
  24708. });
  24709. watch.Stop();
  24710. return Ok(JsonView(true, $"{MsgTips.Succeed},耗时 {watch.ElapsedMilliseconds} ms", infos, total));
  24711. }
  24712. #endregion
  24713. #region 报批行程
  24714. /// <summary>
  24715. /// 报批行程初始化
  24716. /// </summary>
  24717. /// <param name="dto"></param>
  24718. /// <returns></returns>
  24719. [HttpPost]
  24720. public IActionResult ApprovalJourneyInit(ApprovalJourneyDto dto)
  24721. {
  24722. const int chiNumber = 5;
  24723. var jw = JsonView(false);
  24724. var groupList = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0).OrderByDescending(x => x.VisitStartDate).ToList();
  24725. var group = groupList.First();
  24726. var diid = dto.Diid == -1 ? group?.Id : dto.Diid;
  24727. group = groupList.First(x => x.Id == diid);
  24728. var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  24729. .Where(x => x.DiId == diid && x.IsDel == 0)
  24730. .ToArray();
  24731. var count = 1;
  24732. foreach (var item in blackCodeList)
  24733. {
  24734. if (string.IsNullOrWhiteSpace(item.Title))
  24735. {
  24736. item.Title = "未设置名称数据" + count;
  24737. }
  24738. count++;
  24739. }
  24740. ;
  24741. if (group == null)
  24742. {
  24743. jw.Msg = "暂无团组!";
  24744. return Ok(jw);
  24745. }
  24746. var data = new
  24747. {
  24748. groupList = groupList.Select(x => new
  24749. {
  24750. x.TeamName,
  24751. x.Id
  24752. }),
  24753. content = new ArrayList(),
  24754. groupInfo = new
  24755. {
  24756. group.VisitDays,
  24757. group.TourCode,
  24758. group.VisitPNumber,
  24759. group.TeamName,
  24760. group.Id,
  24761. visitStartDate = group.VisitStartDate.ToString("yyyy-MM-dd"),
  24762. visitEndDate = group.VisitEndDate.ToString("yyyy-MM-dd"),
  24763. group.ClientUnit
  24764. },
  24765. blackCodeList = blackCodeList.Select(x => new
  24766. {
  24767. x.Title,
  24768. x.Id
  24769. }),
  24770. FileTempList = new ArrayList()
  24771. {
  24772. new { Index = 1,FileName = "旧模板" },
  24773. new { Index = 2,FileName = "省外办" },
  24774. new { Index = 3,FileName = "市外办" },
  24775. }
  24776. };
  24777. var resultArr = new ArrayList();
  24778. var content = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == diid && x.IsDel == 0).ToList();
  24779. #region 默认不生成行程
  24780. //if (content.Count == 0)
  24781. //{
  24782. // var stay = "-";
  24783. // var cityPath = "-";
  24784. // var blackCodeList = _sqlSugar.Queryable<Air_TicketBlackCode>()
  24785. // .Where(x => x.DiId == diid && x.IsDel == 0)
  24786. // .ToList();
  24787. // //添加城市路径以及住宿地
  24788. // //黑屏代码数据
  24789. // DataTable dtBlack = GeneralMethod.GetTableByBlackCodeById(blackCodeList.FirstOrDefault());
  24790. // if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  24791. // {
  24792. // jw = JsonView(true, "黑屏代码有误!", data);
  24793. // return Ok(jw);
  24794. // }
  24795. // data = data with
  24796. // {
  24797. // blackCodeList = new ArrayList(blackCodeList.Select(x => new
  24798. // {
  24799. // x.Title,
  24800. // x.Id,
  24801. // }).ToArray())
  24802. // };
  24803. // foreach (DataRow row in dtBlack.Rows)
  24804. // {
  24805. // if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  24806. // {
  24807. // jw = JsonView(true, "黑屏代码有误!" + row["Error"].ToString(), data);
  24808. // return Ok(jw);
  24809. // }
  24810. // }
  24811. // //黑屏代码获取时间区间
  24812. // var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  24813. // string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  24814. // _sqlSugar.BeginTran();
  24815. // for (int i = 0; i < timeArr.Count; i++)
  24816. // {
  24817. // stay = "-";
  24818. // cityPath = "-";
  24819. // DateTime NewData = DateTime.Parse(timeArr[i]);
  24820. // string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  24821. // Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  24822. // var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  24823. // if (tbSelect.Length > 0)
  24824. // {
  24825. // List<string> threeCodeStr = new List<string>();
  24826. // foreach (var item in tbSelect)
  24827. // {
  24828. // var threeCode = item["Three"].ToString() ?? "";
  24829. // if (threeCode.Length == 6)
  24830. // {
  24831. // var start = threeCode.Substring(0, 3);
  24832. // var end = threeCode.Substring(3, 3);
  24833. // if (threeCodeStr.Count == 0)
  24834. // {
  24835. // threeCodeStr.Add(start);
  24836. // threeCodeStr.Add(end);
  24837. // }
  24838. // else
  24839. // {
  24840. // if (threeCodeStr[threeCodeStr.Count - 1] == start)
  24841. // {
  24842. // threeCodeStr.Add(end);
  24843. // }
  24844. // else
  24845. // {
  24846. // threeCodeStr.Add(start);
  24847. // threeCodeStr.Add(end);
  24848. // }
  24849. // }
  24850. // }
  24851. // }
  24852. // var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  24853. // var last = threeCodeStr.Last();
  24854. // foreach (var item in threeCodeStr)
  24855. // {
  24856. // cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  24857. // if (item.Equals(last))
  24858. // {
  24859. // stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  24860. // }
  24861. // }
  24862. // cityPath = cityPath.Trim('-');
  24863. // }
  24864. // appro.Date = "第" + intToString(i + 1) + "天 " + NewData.Month + "月" + NewData.Day + "日(" + week + ") " + cityPath + " 宿:" + stay;
  24865. // appro.Diid = diid ?? -1;
  24866. // var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  24867. // appro.Id = thisId;
  24868. // appro.CreateUserId = dto.UserId;
  24869. // appro.CreateTime = DateTime.Now;
  24870. // content.Add(appro);
  24871. // }
  24872. // _sqlSugar.CommitTran();
  24873. //}
  24874. #endregion
  24875. foreach (var x in content)
  24876. {
  24877. var chiList = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x1 => x1.ParentId == x.Id && x1.IsDel == 0).ToList();
  24878. if (chiList.Count < chiNumber)
  24879. {
  24880. for (int i = chiList.Count; i < chiNumber; i++)
  24881. {
  24882. chiList.Add(new Grp_ApprovalTravelDetails());
  24883. }
  24884. }
  24885. resultArr.Add(new
  24886. {
  24887. x.Id,
  24888. x.Date,
  24889. x.Diid,
  24890. chiList = chiList.Select(x1 => new
  24891. {
  24892. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  24893. x1.Details,
  24894. x1.ParentId,
  24895. x1.Id
  24896. })
  24897. });
  24898. }
  24899. data = data with
  24900. {
  24901. content = resultArr,
  24902. };
  24903. jw = JsonView(true, "获取成功!", data);
  24904. return Ok(jw);
  24905. }
  24906. /// <summary>
  24907. /// 报批行程删除
  24908. /// </summary>
  24909. /// <param name="dto"></param>
  24910. /// <returns></returns>
  24911. [HttpPost]
  24912. public IActionResult DeleteApprovalJourney(DeleteApprovalJourney dto)
  24913. {
  24914. var jw = JsonView(false);
  24915. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  24916. if (group == null)
  24917. {
  24918. jw.Msg = "团组参数有误!";
  24919. return Ok(jw);
  24920. }
  24921. try
  24922. {
  24923. _sqlSugar.BeginTran();
  24924. var arr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.Diid == dto.Diid && x.IsDel == 0).Select(x => x.Id).ToList();
  24925. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().SetColumns(x => new Grp_ApprovalTravelDetails
  24926. {
  24927. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  24928. DeleteUserId = dto.uesrId,
  24929. IsDel = 1
  24930. }).Where(x => arr.Contains(x.ParentId) && x.IsDel == 0).ExecuteCommand();
  24931. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>().SetColumns(x => new Grp_ApprovalTravel
  24932. {
  24933. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  24934. DeleteUserId = dto.uesrId,
  24935. IsDel = 1
  24936. }).Where(x => arr.Contains(x.Id)).ExecuteCommand();
  24937. _sqlSugar.CommitTran();
  24938. jw = JsonView(true, "删除成功");
  24939. }
  24940. catch (Exception ex)
  24941. {
  24942. jw = JsonView(false, ex.Message);
  24943. }
  24944. return Ok(jw);
  24945. }
  24946. /// <summary>
  24947. /// 报批行程保存
  24948. /// </summary>
  24949. /// <param name="dto"></param>
  24950. /// <returns></returns>
  24951. [HttpPost]
  24952. public IActionResult SaveApprovalJourney(SaveApprovalJourney dto)
  24953. {
  24954. var jw = JsonView(false);
  24955. var Find = dto.Arr.Find(x => x.id == 0);
  24956. if (Find != null)
  24957. {
  24958. jw.Msg = "生成的ID为0!";
  24959. return Ok(jw);
  24960. }
  24961. foreach (var item in dto.Arr)
  24962. {
  24963. foreach (var chi in item.chiList)
  24964. {
  24965. if (chi.parentId == 0)
  24966. {
  24967. chi.parentId = item.id;
  24968. }
  24969. }
  24970. }
  24971. var chiArr = dto.Arr.SelectMany(x => x.chiList).ToList();
  24972. _sqlSugar.BeginTran();
  24973. if (chiArr.Where(x => x.id == 0).Count() == chiArr.Count)
  24974. {
  24975. var parentIds = dto.Arr.Select(x => x.id).ToList();
  24976. _sqlSugar.Updateable<Grp_ApprovalTravelDetails>().Where(x => parentIds.Contains(x.ParentId) && x.IsDel == 0).SetColumns(x => new Grp_ApprovalTravelDetails
  24977. {
  24978. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
  24979. DeleteUserId = dto.UserId,
  24980. IsDel = 1
  24981. }).ExecuteCommand();
  24982. }
  24983. try
  24984. {
  24985. _ = _sqlSugar.Insertable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id == 0).Select(x => new Grp_ApprovalTravelDetails
  24986. {
  24987. CreateTime = DateTime.Now,
  24988. CreateUserId = dto.UserId,
  24989. Details = x.details,
  24990. ParentId = x.parentId,
  24991. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  24992. Remark = "",
  24993. IsDel = 0
  24994. }).ToList()).ExecuteCommand();
  24995. _ = _sqlSugar.Updateable<Grp_ApprovalTravelDetails>(chiArr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravelDetails
  24996. {
  24997. Id = x.id,
  24998. Details = x.details,
  24999. ParentId = x.parentId,
  25000. Time = x.timeInterval.Where(x => !string.IsNullOrWhiteSpace(x)).Count() > 1 ? x.timeInterval[0] + "-" + x.timeInterval[1] : "",
  25001. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravelDetails
  25002. {
  25003. Details = x.Details,
  25004. ParentId = x.ParentId,
  25005. Time = x.Time
  25006. }).ExecuteCommand();
  25007. _ = _sqlSugar.Updateable<Grp_ApprovalTravel>(dto.Arr.Where(x => x.id != 0).Select(x => new Grp_ApprovalTravel
  25008. {
  25009. Id = x.id,
  25010. Date = x.date,
  25011. }).ToList()).UpdateColumns(x => new Grp_ApprovalTravel
  25012. {
  25013. Date = x.Date
  25014. }).ExecuteCommand();
  25015. _sqlSugar.CommitTran();
  25016. jw = JsonView(true, "保存成功!");
  25017. }
  25018. catch (Exception ex)
  25019. {
  25020. _sqlSugar.RollbackTran();
  25021. jw = JsonView(false, "保存失败!" + ex.Message);
  25022. }
  25023. return Ok(jw);
  25024. }
  25025. /// <summary>
  25026. /// 报批行程生成
  25027. /// </summary>
  25028. /// <param name="dto"></param>
  25029. /// <returns></returns>
  25030. [HttpPost]
  25031. public IActionResult CreateApprovalJourney(CreateApprovalJourneyDto dto)
  25032. {
  25033. var jw = JsonView(false);
  25034. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  25035. if (group == null)
  25036. {
  25037. jw.Msg = "暂无该团组!";
  25038. return Ok(jw);
  25039. }
  25040. var blackCode = _sqlSugar.Queryable<Air_TicketBlackCode>().First(x => x.Id == dto.BlackCodeId && x.IsDel == 0);
  25041. //黑屏代码数据
  25042. DataTable dtBlack = GeneralMethod.GetTableByBlackCodeBySingle(blackCode);
  25043. if (dtBlack.Rows.Count == 0 || string.IsNullOrWhiteSpace(dtBlack.Rows[0][1].ToString()))
  25044. {
  25045. jw.Msg = "黑屏代码有误!";
  25046. return Ok(jw);
  25047. }
  25048. foreach (DataRow row in dtBlack.Rows)
  25049. {
  25050. if (!string.IsNullOrWhiteSpace(row["Error"].ToString()))
  25051. {
  25052. jw.Msg = "黑屏代码有误!" + row["Error"].ToString();
  25053. return Ok(jw);
  25054. }
  25055. }
  25056. //var officialActivitiesArr = _sqlSugar.Queryable<Res_OfficialActivities>().Where(x => x.DiId == dto.Diid && x.IsDel == 0).ToList();
  25057. var resultArr = new ArrayList();
  25058. //if (officialActivitiesArr.Count == 0)
  25059. //{
  25060. // jw.Msg = "暂无公务出访信息!";
  25061. // return Ok(jw);
  25062. //}
  25063. try
  25064. {
  25065. _sqlSugar.BeginTran();
  25066. DeleteApprovalJourney(new
  25067. Domain.Dtos.Groups.DeleteApprovalJourney
  25068. {
  25069. Diid = dto.Diid,
  25070. uesrId = dto.Userid
  25071. });
  25072. var stay = "-";
  25073. var cityPath = "-";
  25074. var arriveCountry = string.Empty;
  25075. //添加城市路径以及住宿地
  25076. //黑屏代码获取时间区间
  25077. var timeArr = GeneralMethod.GetTimeListByDataTable(dtBlack);
  25078. var empty = "【未收入该三字码!请机票同事录入】";
  25079. string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
  25080. #region 配置公务活动时间
  25081. List<Tuple<int, string, string>> Times = new List<Tuple<int, string, string>>();
  25082. Times.Add(new Tuple<int, string, string>(9, "9:00", "10:30"));
  25083. Times.Add(new Tuple<int, string, string>(11, "11:00", "12:00"));
  25084. Times.Add(new Tuple<int, string, string>(14, "14:00", "15:30"));
  25085. Times.Add(new Tuple<int, string, string>(16, "16:00", "17:00"));
  25086. List<Tuple<DateTime, List<string>>> fallTimesCheckCountry = new List<Tuple<DateTime, List<string>>>()
  25087. {
  25088. 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" }),
  25089. 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"}),
  25090. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  25091. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,13,30,0), new List<string>{"16:30-17:30"}),
  25092. };
  25093. List<Tuple<DateTime, List<string>>> fallTimesNotCheckCountry = new List<Tuple<DateTime, List<string>>>()
  25094. {
  25095. 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" }),
  25096. 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"}),
  25097. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,11,30,0), new List<string>{"14:00-15:30","16:00-17:00"}),
  25098. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,30,0), new List<string>{"16:30-17:30"}),
  25099. };
  25100. List<Tuple<DateTime, List<string>>> takeoffTimes = new List<Tuple<DateTime, List<string>>>()
  25101. {
  25102. 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" }),
  25103. 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"}),
  25104. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,14,00,0), new List<string>{"9:00-10:30", "11:00-12:00",}),
  25105. new Tuple<DateTime, List<string>>(new DateTime(1900,1,1,12,00,0), new List<string>{"09:00-10:00"}),
  25106. };
  25107. #endregion
  25108. var nextDayNum = 0;
  25109. for (int i = 0; i < timeArr.Count; i++)
  25110. {
  25111. stay = "-";
  25112. cityPath = "-";
  25113. var chiarr = new List<Grp_ApprovalTravelDetails>();
  25114. DateTime NewData = DateTime.Parse(timeArr[i]);
  25115. //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();
  25116. var tbSelect = dtBlack.Select(string.Format("Day = '{0}'", NewData.ToString("yyyy-MM-dd")));
  25117. if (nextDayNum > 0)
  25118. {
  25119. nextDayNum--;
  25120. }
  25121. if (tbSelect.Length > 0)
  25122. {
  25123. List<string> threeCodeStr = new List<string>();
  25124. bool isTrade = false;
  25125. string trip = string.Empty;
  25126. foreach (var item in tbSelect)
  25127. {
  25128. if (nextDayNum == 0)
  25129. {
  25130. nextDayNum = Convert.ToInt32(item["Sign"]);
  25131. }
  25132. var airStartTime = item["StartTime"].ToString() ?? "0000";
  25133. var airEndTime = item["EndTime"].ToString() ?? "0000";
  25134. var takeOffTime = DateTime.Parse(timeArr[i]);
  25135. var fallToTime = DateTime.Parse(timeArr[i]);
  25136. takeOffTime = takeOffTime.AddHours(int.Parse(airStartTime.Substring(0, 2)));
  25137. takeOffTime = takeOffTime.AddMinutes(int.Parse(airStartTime.Substring(2, 2)));
  25138. fallToTime = fallToTime.AddHours(int.Parse(airEndTime.Substring(0, 2)));
  25139. fallToTime = fallToTime.AddMinutes(int.Parse(airEndTime.Substring(2, 2)));
  25140. if (nextDayNum > 0)
  25141. {
  25142. fallToTime = fallToTime.AddDays(nextDayNum);
  25143. }
  25144. trip = string.Empty;
  25145. var start = string.Empty;
  25146. var end = string.Empty;
  25147. var threeCode = item["Three"].ToString() ?? "";
  25148. if (threeCode.Length == 6)
  25149. {
  25150. start = threeCode.Substring(0, 3);
  25151. end = threeCode.Substring(3, 3);
  25152. if (threeCodeStr.Count == 0)
  25153. {
  25154. threeCodeStr.Add(start);
  25155. threeCodeStr.Add(end);
  25156. }
  25157. else
  25158. {
  25159. if (threeCodeStr[threeCodeStr.Count - 1] == start)
  25160. {
  25161. threeCodeStr.Add(end);
  25162. }
  25163. else
  25164. {
  25165. threeCodeStr.Add(start);
  25166. threeCodeStr.Add(end);
  25167. }
  25168. }
  25169. }
  25170. //处理机票信息
  25171. var start_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == start.ToUpper());
  25172. var end_Object = _sqlSugar.Queryable<Res_ThreeCode>().First(x => x.Three.ToUpper() == end.ToUpper());
  25173. if (start_Object == null)
  25174. {
  25175. start_Object = new Res_ThreeCode()
  25176. {
  25177. AirPort = empty,
  25178. AirPort_En = empty,
  25179. City = empty,
  25180. Country = empty,
  25181. Four = empty,
  25182. Three = empty,
  25183. };
  25184. }
  25185. if (end_Object == null)
  25186. {
  25187. end_Object = new Res_ThreeCode()
  25188. {
  25189. AirPort = empty,
  25190. AirPort_En = empty,
  25191. City = empty,
  25192. Country = empty,
  25193. Four = empty,
  25194. Three = empty,
  25195. };
  25196. }
  25197. //机型判断
  25198. string airModel = item["AirModel"].ToString();
  25199. airModel = GeneralMethod.GetLonger(airModel!.Substring(0, 1)) + airModel;
  25200. string flightTime = item["FlightTime"].ToString();
  25201. flightTime = ParseBlackTime(flightTime);
  25202. //航班号
  25203. string flightcode = item["Fliagtcode"].ToString();
  25204. var aircompany = _sqlSugar.Queryable<Res_AirCompany>().First(x => x.ShortCode.ToUpper() == flightcode!.Substring(0, 2).ToUpper() && x.IsDel == 0);
  25205. var hsEmpty = "【此航司" + flightcode!.Substring(0, 2).ToUpper() + "未收录,请机票同事录入】";
  25206. if (aircompany == null)
  25207. {
  25208. aircompany = new Res_AirCompany
  25209. {
  25210. CnName = hsEmpty,
  25211. EnName = hsEmpty,
  25212. ShortCode = hsEmpty,
  25213. };
  25214. }
  25215. //航班前公务安排
  25216. if (tbSelect.First().Equals(item) && i != 0)
  25217. {
  25218. foreach (var takeoff in takeoffTimes)
  25219. {
  25220. var takeoffItem1 = NewData.AddHours(takeoff.Item1.Hour).AddMinutes(takeoff.Item1.Minute);
  25221. if (DateTime.Compare(takeOffTime, takeoffItem1) > 0)
  25222. {
  25223. foreach (var addTime in takeoff.Item2)
  25224. {
  25225. chiarr.Add(new Grp_ApprovalTravelDetails
  25226. {
  25227. Time = addTime,
  25228. CreateTime = DateTime.Now,
  25229. CreateUserId = dto.Userid,
  25230. ParentId = 0,
  25231. Details = "公务活动"
  25232. });
  25233. }
  25234. break;
  25235. }
  25236. }
  25237. }
  25238. //从成都天府国际机场搭乘四川航空公司3U3961飞往东京
  25239. //trip += $"从{start_Object.AirPort}搭乘{aircompany.CnName}{flightcode}飞往{end_Object.City}。\r\n({start_Object.AirPort}/{end_Object.AirPort} 机型:{airModel} 飞行时间{flightTime});\r\n";
  25240. //乘坐四川航空3U3901次航班由成都飞往加德满都,3小时25分钟
  25241. trip += $"乘坐{aircompany.CnName}{flightcode}次航班由{start_Object.City}飞往{end_Object.City},{flightTime}";
  25242. isTrade = Convert.ToBoolean(item["isTransitShipment"]);
  25243. if (isTrade)
  25244. {
  25245. //trip += $"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼(中转 行李直达)\r\n";
  25246. trip += "(转机不出机场)。";
  25247. }
  25248. //else
  25249. //{
  25250. // trip += "\r\n"; //$"抵达{end_Object.AirPort}{item["EndBuilding"].ToString().Trim()}航站楼,办理入境手续,之后前往提取行李\r\n";
  25251. //}
  25252. chiarr.Add(new Grp_ApprovalTravelDetails
  25253. {
  25254. Time = takeOffTime.ToString("HH:mm") + "-" + fallToTime.ToString("HH:mm"),
  25255. CreateTime = DateTime.Now,
  25256. CreateUserId = dto.Userid,
  25257. ParentId = 0,
  25258. Details = trip
  25259. });
  25260. //最后一条到达的时间安排公务
  25261. if (tbSelect.Last().Equals(item) && i != timeArr.Count - 1)
  25262. {
  25263. bool isCheckCountry = false;
  25264. if (end_Object.Country != arriveCountry)
  25265. {
  25266. arriveCountry = end_Object.Country;
  25267. isCheckCountry = true;
  25268. }
  25269. if (nextDayNum == 0)
  25270. {
  25271. //需要入境的情况
  25272. if (isCheckCountry)
  25273. {
  25274. foreach (var fallTime in fallTimesCheckCountry)
  25275. {
  25276. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  25277. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  25278. {
  25279. foreach (var addTime in fallTime.Item2)
  25280. {
  25281. chiarr.Add(new Grp_ApprovalTravelDetails
  25282. {
  25283. Time = addTime,
  25284. CreateTime = DateTime.Now,
  25285. CreateUserId = dto.Userid,
  25286. ParentId = 0,
  25287. Details = "公务活动"
  25288. });
  25289. }
  25290. break;
  25291. }
  25292. }
  25293. }
  25294. else
  25295. {
  25296. foreach (var fallTime in fallTimesNotCheckCountry)
  25297. {
  25298. var fallTimeItem1 = NewData.AddHours(fallTime.Item1.Hour).AddMinutes(fallTime.Item1.Minute);
  25299. if (DateTime.Compare(fallToTime, fallTimeItem1) < 0)
  25300. {
  25301. foreach (var addTime in fallTime.Item2)
  25302. {
  25303. chiarr.Add(new Grp_ApprovalTravelDetails
  25304. {
  25305. Time = addTime,
  25306. CreateTime = DateTime.Now,
  25307. CreateUserId = dto.Userid,
  25308. ParentId = 0,
  25309. Details = "公务活动"
  25310. });
  25311. }
  25312. break;
  25313. }
  25314. }
  25315. }
  25316. }
  25317. }
  25318. }
  25319. //添加乘车语句
  25320. //chiarr.Add(new Grp_ApprovalTravelDetails
  25321. //{
  25322. // Time = (fallToTime.AddHours(2.5).ToString("HH:mm") + "-" + fallToTime.AddHours(3).ToString("HH:mm")),
  25323. // CreateTime = DateTime.Now,
  25324. // CreateUserId = dto.Userid,
  25325. // ParentId = 0,
  25326. // Details = "乘车前往市区(约xx公里,大约需要xx分钟)"
  25327. //});
  25328. //if (i != timeArr.Count - 1)
  25329. //{
  25330. // fallToTime = fallToTime.AddHours(2.5);
  25331. // foreach (var item in Times)
  25332. // {
  25333. // //排列公务时间
  25334. // if (fallToTime.Hour < item.Item1)
  25335. // {
  25336. // chiarr.Add(new Grp_ApprovalTravelDetails
  25337. // {
  25338. // Time = $"{item.Item2} - {item.Item3}",
  25339. // CreateTime = DateTime.Now,
  25340. // CreateUserId = dto.Userid,
  25341. // ParentId = 0,
  25342. // Details = "公务活动"
  25343. // });
  25344. // }
  25345. // }
  25346. //}
  25347. var threeCodeList = _threeCodeRepository.QueryThreeCodeArray(threeCodeStr);
  25348. var last = threeCodeStr.Last();
  25349. foreach (var item in threeCodeStr)
  25350. {
  25351. cityPath += (threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】") + "-";
  25352. if (item.Equals(last))
  25353. {
  25354. stay = threeCodeList.Keys.Contains(item) ? threeCodeList[item].City : "【未知三字码】";
  25355. }
  25356. }
  25357. cityPath = cityPath.Trim('-');
  25358. }
  25359. else
  25360. {
  25361. foreach (var item in Times)
  25362. {
  25363. chiarr.Add(new Grp_ApprovalTravelDetails
  25364. {
  25365. Time = $"{item.Item2} - {item.Item3}",
  25366. CreateTime = DateTime.Now,
  25367. CreateUserId = dto.Userid,
  25368. ParentId = 0,
  25369. Details = "公务活动"
  25370. });
  25371. }
  25372. }
  25373. string week = Day[Convert.ToInt32(NewData.DayOfWeek.ToString("d"))].ToString();
  25374. Grp_ApprovalTravel appro = new Grp_ApprovalTravel();
  25375. appro.Date = NewData.Month + "月" + NewData.Day + "日(" + week + ")" + "第" + intToString(i + 1) + "天 ";
  25376. appro.Diid = dto.Diid;
  25377. appro.CreateUserId = dto.Userid;
  25378. appro.CreateTime = DateTime.Now;
  25379. var thisId = _sqlSugar.Insertable<Grp_ApprovalTravel>(appro).ExecuteReturnIdentity();
  25380. appro.Id = thisId;
  25381. //foreach (var item in gwinfo)
  25382. //{
  25383. // Grp_ApprovalTravelDetails chi = new Grp_ApprovalTravelDetails();
  25384. // chi.Details = "拜访" + item.Client;
  25385. // if (!string.IsNullOrWhiteSpace(item.ReqSample))
  25386. // {
  25387. // chi.Details += "," + item.ReqSample;
  25388. // }
  25389. // chi.ParentId = thisId;
  25390. // chi.Time = item.Time;
  25391. // chiarr.Add(chi);
  25392. //}
  25393. if (chiarr.Count < 6)
  25394. {
  25395. for (int j = chiarr.Count; j < 6; j++)
  25396. {
  25397. chiarr.Add(new
  25398. Grp_ApprovalTravelDetails());
  25399. }
  25400. }
  25401. resultArr.Add(new
  25402. {
  25403. appro.Id,
  25404. appro.Date,
  25405. appro.Diid,
  25406. chiList = chiarr.Select(x1 => new
  25407. {
  25408. timeInterval = string.IsNullOrWhiteSpace(x1.Time) ? new string[1] : x1.Time.Split('-'),
  25409. x1.Details,
  25410. x1.ParentId,
  25411. x1.Id
  25412. })
  25413. });
  25414. }
  25415. _sqlSugar.CommitTran();
  25416. jw = JsonView(true, "生成成功!", resultArr);
  25417. }
  25418. catch (Exception ex)
  25419. {
  25420. jw.Code = 400;
  25421. jw.Msg = "生成失败!" + ex.Message;
  25422. }
  25423. return Ok(jw);
  25424. }
  25425. /// <summary>
  25426. /// 报批行程word导出
  25427. /// </summary>
  25428. /// <param name="dto"></param>
  25429. /// <returns></returns>
  25430. [HttpPost]
  25431. public IActionResult ExportApprovalJourneyWord(ExportApprovalJourneyWord dto)
  25432. {
  25433. var jw = JsonView(false);
  25434. var group = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
  25435. if (group == null)
  25436. {
  25437. jw.Msg = "暂无该团组!";
  25438. return Ok(jw);
  25439. }
  25440. //模板路径
  25441. string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/";
  25442. var fileName = string.Empty;
  25443. string titleFont = string.Empty, timeFont = string.Empty, contentFont = string.Empty;
  25444. bool bold = false;
  25445. if (dto.FileIndex == 1)
  25446. {
  25447. fileName = "公务行程导出模板.docx"; //"C:\\Server\\File\\OA2023\\Office\\Word\\Template/公务行程导出模板.docx"
  25448. }
  25449. else if (dto.FileIndex == 2)
  25450. {
  25451. fileName = "省外办-报批.docx";
  25452. bold = false;
  25453. titleFont = "方正黑体简体";
  25454. timeFont = "Times New Roman";
  25455. contentFont = "方正仿宋_GBK";
  25456. }
  25457. else if (dto.FileIndex == 3)
  25458. {
  25459. fileName = "市外办-报批.docx";
  25460. titleFont = "方正黑体简体";
  25461. timeFont = "Times New Roman";
  25462. contentFont = "方正仿宋简体";
  25463. }
  25464. tempPath = tempPath + fileName;
  25465. //载入模板
  25466. Document doc = new Document(tempPath);
  25467. NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
  25468. //获取所填表格的序数
  25469. Aspose.Words.Tables.Table tableOne = allTables[0] as Aspose.Words.Tables.Table;
  25470. Aspose.Words.Tables.Row titleRowClone = null;
  25471. Aspose.Words.Tables.Row CenterRowClone = null;
  25472. int index = 0;
  25473. int indexChi = 0;
  25474. int SetIndex = 0;
  25475. var ApprovalTravelArr = _sqlSugar.Queryable<Grp_ApprovalTravel>().Where(x => x.IsDel == 0 && x.Diid == dto.Diid).ToList();
  25476. //获取数据,放到datatable
  25477. foreach (var item in ApprovalTravelArr)
  25478. {
  25479. if (index > 0)
  25480. {
  25481. titleRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[0].Clone(true);
  25482. tableOne.AppendChild(titleRowClone);
  25483. }
  25484. var textTime = item.Date;
  25485. var ChiRep = _sqlSugar.Queryable<Grp_ApprovalTravelDetails>().Where(x => x.IsDel == 0 && x.ParentId == item.Id).ToList();
  25486. SetCells(tableOne, doc, SetIndex, 0, textTime, titleFont, bold);
  25487. SetIndex++;
  25488. if (ChiRep.Count > 0)
  25489. {
  25490. foreach (var itemChi in ChiRep)
  25491. {
  25492. var txtTime = itemChi.Time;
  25493. var txtDetail = itemChi.Details;
  25494. if (string.IsNullOrEmpty(txtTime) && string.IsNullOrEmpty(txtDetail))
  25495. {
  25496. //SetCells(tableOne, doc, SetIndex, 0, "", timeFont, bold);
  25497. //SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  25498. //indexChi++;
  25499. //SetIndex++;
  25500. break;
  25501. }
  25502. if (indexChi > 0)
  25503. {
  25504. CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  25505. tableOne.AppendChild(CenterRowClone);
  25506. }
  25507. SetCells(tableOne, doc, SetIndex, 0, txtTime, timeFont, bold);
  25508. SetCells(tableOne, doc, SetIndex, 1, txtDetail, contentFont, bold);
  25509. indexChi++;
  25510. SetIndex++;
  25511. }
  25512. }
  25513. //else
  25514. //{
  25515. // if (indexChi > 0)
  25516. // {
  25517. // CenterRowClone = (Aspose.Words.Tables.Row)tableOne.Rows[1].Clone(true);
  25518. // tableOne.AppendChild(CenterRowClone);
  25519. // }
  25520. // SetCells(tableOne, doc, SetIndex, 0, "",timeFont, bold);
  25521. // SetCells(tableOne, doc, SetIndex, 1, "", contentFont, bold);
  25522. // indexChi++;
  25523. // SetIndex++;
  25524. //}
  25525. index++;
  25526. }
  25527. string strFileName = "/Travel/ExportApprovalJourneyWord/" + group.TeamName + fileName;
  25528. doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName, Aspose.Words.SaveFormat.Docx); //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  25529. jw.Data = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName; //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
  25530. jw.Code = 200;
  25531. jw.Msg = "";
  25532. return Ok(jw);
  25533. }
  25534. private string ParseBlackTime(string time)
  25535. {
  25536. // 匹配可能只有分钟的情况
  25537. string pattern = @"(?:(\d+)H)?(?:(\d+)M)?";
  25538. System.Text.RegularExpressions.Match match = Regex.Match(time, pattern);
  25539. if (match.Success)
  25540. {
  25541. string hours = match.Groups[1].Value;
  25542. string minutes = match.Groups[2].Value;
  25543. // 如果小时部分为空,则只显示分钟
  25544. if (string.IsNullOrEmpty(hours))
  25545. {
  25546. return $"{minutes}分钟";
  25547. }
  25548. // 如果分钟部分为空,则只显示小时
  25549. else if (string.IsNullOrEmpty(minutes))
  25550. {
  25551. return $"{hours}小时";
  25552. }
  25553. // 否则显示完整格式
  25554. else
  25555. {
  25556. return $"{hours}小时{minutes}分钟";
  25557. }
  25558. }
  25559. else
  25560. {
  25561. return "未知时长";
  25562. }
  25563. }
  25564. private string intToString(int numberVal)
  25565. {
  25566. string numberval = numberVal.ToString();
  25567. Dictionary<char, string> Number = new Dictionary<char, string>();
  25568. Number.Add('1', "一");
  25569. Number.Add('2', "二");
  25570. Number.Add('3', "三");
  25571. Number.Add('4', "四");
  25572. Number.Add('5', "五");
  25573. Number.Add('6', "六");
  25574. Number.Add('7', "七");
  25575. Number.Add('8', "八");
  25576. Number.Add('9', "九");
  25577. string stringNumberVal = string.Empty;
  25578. for (int i = 0; i < numberval.Length; i++)
  25579. {
  25580. if (i == 0)
  25581. {
  25582. stringNumberVal += Number[numberval[i]];
  25583. }
  25584. else if (i >= 1)
  25585. {
  25586. if (numberval[i] == '0')
  25587. {
  25588. stringNumberVal = "十";
  25589. }
  25590. else
  25591. {
  25592. stringNumberVal += "十" + Number[numberval[i]];
  25593. }
  25594. }
  25595. }
  25596. return stringNumberVal;
  25597. }
  25598. private void SetCells(Aspose.Words.Tables.Table table, Document doc, int rows, int cells, string val, string font, bool bold)
  25599. {
  25600. //获取table中的某个单元格,从0开始
  25601. Cell lshCell = table.Rows[rows].Cells[cells];
  25602. //将单元格中段落移除
  25603. foreach (Paragraph item in lshCell.Paragraphs)
  25604. {
  25605. lshCell.Paragraphs.Remove(item);
  25606. }
  25607. if (val.Contains("\r\n"))
  25608. {
  25609. var spArr = val.Split("\r\n").Where(x => !string.IsNullOrWhiteSpace(x));
  25610. foreach (var item in spArr)
  25611. {
  25612. //新建一个段落
  25613. Paragraph p = new Paragraph(doc);
  25614. var r = new Run(doc, item);
  25615. //设置字体
  25616. if (!string.IsNullOrEmpty(font))
  25617. {
  25618. r.Font.Name = font;
  25619. }
  25620. r.Font.Bold = bold;
  25621. //把设置的值赋给之前新建的段落
  25622. p.AppendChild(r);
  25623. //将此段落加到单元格内
  25624. lshCell.AppendChild(p);
  25625. }
  25626. }
  25627. else
  25628. {
  25629. //新建一个段落
  25630. Paragraph p = new Paragraph(doc);
  25631. var r = new Run(doc, val);
  25632. //设置字体
  25633. if (!string.IsNullOrEmpty(font))
  25634. {
  25635. r.Font.Name = font;
  25636. }
  25637. r.Font.Bold = bold;
  25638. //把设置的值赋给之前新建的段落
  25639. p.AppendChild(r);
  25640. //将此段落加到单元格内
  25641. lshCell.AppendChild(p);
  25642. }
  25643. }
  25644. /// <summary>
  25645. /// 报批行程AI续写
  25646. /// </summary>
  25647. /// <returns></returns>
  25648. [HttpPost]
  25649. public async Task<IActionResult> ApprovalJourneyAiWrite(ApprovalJourneyAiWriteDto dto)
  25650. {
  25651. var jw = JsonView(false);
  25652. if (dto.ClientPurpose.IsNullOrWhiteSpace() || dto.ClientName.IsNullOrWhiteSpace())
  25653. {
  25654. jw.Msg = "参数有误!";
  25655. return Ok(jw);
  25656. }
  25657. KiMiApiClient kiMi = new KiMiApiClient();
  25658. List<SeedMessages> messages = new List<SeedMessages>() {
  25659. new SeedMessages
  25660. {
  25661. Role = KimiRole.system,
  25662. Content = "你是 Kimi,由 Moonshot AI 提供的人工智能助手,你更擅长中文和英文的对话。你会为用户提供安全,有帮助,准确的回答。"
  25663. },
  25664. new SeedMessages
  25665. {
  25666. Role = KimiRole.user,
  25667. Content = $@"参考这个模板格式来编写一份{dto.ClientName}拜访{dto.ClientPurpose},结合{dto.ClientName}的业务,描述拜访目的,字数在200字内(直接给出拜访目的,不输出其他内容)"
  25668. }
  25669. };
  25670. var kimi_result = await kiMi.SeedMessageByFullConterObject(messages);
  25671. string data = kimi_result.Choices[0]?.Message.Content;
  25672. if (string.IsNullOrWhiteSpace(data))
  25673. {
  25674. jw.Data = "Ai续写失败!";
  25675. }
  25676. else
  25677. {
  25678. jw = JsonView(true, "success!", data);
  25679. }
  25680. return Ok(jw);
  25681. }
  25682. #endregion
  25683. #region 团组接待意见调查
  25684. /// <summary>
  25685. /// 团组接待意见调查 - 信息管理
  25686. /// 基础数据(团组)
  25687. /// </summary>
  25688. /// <returns></returns>
  25689. [HttpGet]
  25690. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25691. public async Task<IActionResult> OpinionaireInit()
  25692. {
  25693. var groupData = await _groupRepository.Query(x => x.IsDel == 0)
  25694. .Select(x => new
  25695. {
  25696. x.Id,
  25697. GroupName = $"[{x.VisitDate.ToString("yyyy-MM-dd")}]{x.TeamName}"
  25698. })
  25699. .OrderByDescending(x => x.Id)
  25700. .ToListAsync();
  25701. return Ok(JsonView(groupData, groupData.Count));
  25702. }
  25703. /// <summary>
  25704. /// 团组接待意见调查 - 信息管理
  25705. /// 列表
  25706. /// </summary>
  25707. /// <param name="groupId"></param>
  25708. /// <returns></returns>
  25709. [HttpGet("{groupId}")]
  25710. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25711. public async Task<IActionResult> OpinionaireManageList(int groupId)
  25712. {
  25713. if (groupId < 1) Ok(JsonView(false, "请传入有效的diId"));
  25714. var data = await _opinionaireRep.Query(x => x.DiId == groupId)
  25715. .Select(x => new
  25716. {
  25717. x.Id,
  25718. x.TourGuideName,
  25719. x.CityName,
  25720. CreateUserName = SqlFunc.Subqueryable<Sys_Users>().Where(x1 => x.CreateUserId == x1.Id).Select(x1 => x1.CnName),
  25721. x.CreateTime
  25722. })
  25723. .OrderBy(x => x.Id)
  25724. .ToListAsync();
  25725. return Ok(JsonView(data));
  25726. }
  25727. /// <summary>
  25728. /// 团组接待意见调查 - 信息管理
  25729. /// 保存
  25730. /// </summary>
  25731. /// <param name="dto"></param>
  25732. /// <returns></returns>
  25733. [HttpPost]
  25734. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25735. public async Task<IActionResult> OpinionaireManageSave(OpinionaireManageSaveDto dto)
  25736. {
  25737. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  25738. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  25739. if (dto.DiId < 1) Ok(JsonView(false, "请传入有效的diId"));
  25740. if (dto.Items.Length < 1) Ok(JsonView(false, "请传入需要保存的信息"));
  25741. var addData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id == 0).ToList());
  25742. var updData = _mapper.Map<List<Grp_Opinionaire>>(dto.Items.Where(x => x.Id > 0).ToList());
  25743. _opinionaireRep.BeginTran();
  25744. if (addData != null && addData.Count > 0)
  25745. {
  25746. foreach (var item in addData)
  25747. {
  25748. item.CreateUserId = currUserInfo.UserId;
  25749. item.DiId = dto.DiId;
  25750. }
  25751. var add = await _opinionaireRep._sqlSugar.Insertable(addData).ExecuteCommandAsync();
  25752. }
  25753. if (updData != null && updData.Count > 0)
  25754. {
  25755. var upd = await _opinionaireRep._sqlSugar
  25756. .Updateable(updData)
  25757. .UpdateColumns(x => new { x.CityName, x.TourGuideName })
  25758. .WhereColumns(x => new { x.Id })
  25759. .ExecuteCommandAsync();
  25760. }
  25761. _opinionaireRep.CommitTran();
  25762. return Ok(JsonView("操作成功!"));
  25763. }
  25764. /// <summary>
  25765. /// 团组接待意见调查 - 信息管理
  25766. /// 删除
  25767. /// </summary>
  25768. /// <param name="id"></param>
  25769. /// <returns></returns>
  25770. [HttpDelete("{id}")]
  25771. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25772. public async Task<IActionResult> OpinionaireManageDel(int id)
  25773. {
  25774. var currUserInfo = JwtHelper.SerializeJwt(HttpContext.Request.Headers.Authorization);
  25775. if (currUserInfo == null) return Ok(JsonView(false, "请传入token!"));
  25776. if (id < 1) Ok(JsonView(false, "请传入有效的id"));
  25777. var del = await _opinionaireRep.SoftDeleteAsync(x => x.Id == id, currUserInfo.UserId);
  25778. if (!del) return Ok(JsonView("操作失败!"));
  25779. return Ok(JsonView("操作成功!"));
  25780. }
  25781. /// <summary>
  25782. /// 团组接待意见调查 - 用户
  25783. /// 列表
  25784. /// </summary>
  25785. /// <param name="diId"></param>
  25786. /// <returns></returns>
  25787. [HttpGet("{diId}")]
  25788. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25789. public async Task<IActionResult> OpinionaireUserList(int diId)
  25790. {
  25791. if (diId < 1) Ok(JsonView(false, "请传入有效的diId"));
  25792. var sql = string.Format(@"
  25793. SELECT
  25794. o.Id,
  25795. o.DiId,
  25796. di.TeamName AS 'GroupName',
  25797. di.VisitPNumber AS 'PeopleNumber',
  25798. di.ClientName AS 'LeadGroup',
  25799. di.VisitCountry AS 'Travel',
  25800. di.VisitDays AS 'Days',
  25801. o.CityName,
  25802. o.TourGuideName,
  25803. o.Catering,
  25804. o.CateringReason,
  25805. o.Stay,
  25806. o.StayReason,
  25807. o.[Route],
  25808. o.RouteReason,
  25809. o.OfficialActivity,
  25810. o.OfficialActivityReason,
  25811. o.TourGuide,
  25812. o.TourGuideReason,
  25813. o.[Translate],
  25814. o.TranslateReason,
  25815. o.Trip,
  25816. o.TripReason,
  25817. o.ESFileName,
  25818. o.SignatureDate,
  25819. o.Remark
  25820. FROM
  25821. Grp_Opinionaire o
  25822. LEFT JOIN Grp_DelegationInfo di ON o.DiId = di.Id
  25823. WHERE
  25824. o.IsDel = 0
  25825. AND o.DiId = {0}
  25826. ORDER BY
  25827. o.Id ASC", diId);
  25828. var data = await _sqlSugar.SqlQueryable<OpinionaireUserListView>(sql).ToListAsync();
  25829. if (data.Count < 1) return Ok(JsonView(false, "暂无数据"));
  25830. return Ok(JsonView(data));
  25831. }
  25832. /// <summary>
  25833. /// 团组接待意见调查 - 用户
  25834. /// 保存
  25835. /// </summary>
  25836. /// <param name="dto"></param>
  25837. /// <returns></returns>
  25838. [HttpPost]
  25839. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25840. public async Task<IActionResult> OpinionaireUserSave([FromForm] OpinionaireUserSaveInfo[] dto)
  25841. {
  25842. if (dto.Length < 1) Ok(JsonView(false, "请传入有效的参数"));
  25843. foreach (var item in dto)
  25844. {
  25845. if (string.IsNullOrEmpty(item.Catering)) Ok(JsonView(false, "请选择餐饮评分!"));
  25846. if (string.IsNullOrEmpty(item.Stay)) Ok(JsonView(false, "请选择住宿评分!"));
  25847. if (string.IsNullOrEmpty(item.Route)) Ok(JsonView(false, "请选择行程评分!"));
  25848. if (string.IsNullOrEmpty(item.OfficialActivity)) Ok(JsonView(false, "请选择公务活动评分!"));
  25849. if (string.IsNullOrEmpty(item.Translate)) Ok(JsonView(false, "请选择翻译评分!"));
  25850. if (string.IsNullOrEmpty(item.Trip)) Ok(JsonView(false, "请选择行程评分!"));
  25851. if (string.IsNullOrEmpty(item.SignatureDate)) Ok(JsonView(false, "请填写签名日期!"));
  25852. if (item.File.Length < 1) Ok(JsonView(false, "请上传签名图片!"));
  25853. }
  25854. var filePathBase = $"{AppSettingsHelper.Get("GrpFileBasePath")}OpinionaireElectronicSignature";
  25855. if (!Directory.Exists(filePathBase))
  25856. {
  25857. Directory.CreateDirectory(filePathBase);
  25858. }
  25859. #region 上传文件
  25860. var filePaths = new List<string>();
  25861. foreach (var item in dto)
  25862. {
  25863. var file = item.File;
  25864. // 将文件保存到指定位置
  25865. var filePath = Path.Combine(filePathBase, file.FileName);
  25866. using (var stream = new FileStream(filePath, FileMode.Create))
  25867. {
  25868. await file.CopyToAsync(stream);
  25869. }
  25870. //验证文件是否上传成功
  25871. if (!System.IO.File.Exists(filePath))
  25872. {
  25873. foreach (var filePathStr in filePaths)
  25874. {
  25875. System.IO.File.Delete(filePathStr);
  25876. }
  25877. return Ok(JsonView(false, "文件上传失败!"));
  25878. }
  25879. item.ESFileName = file.FileName;
  25880. }
  25881. #endregion
  25882. var infos = _mapper.Map<List<Grp_Opinionaire>>(dto);
  25883. var upd = await _sqlSugar.Updateable<Grp_Opinionaire>(infos)
  25884. .UpdateColumns(x => new
  25885. {
  25886. x.Catering,
  25887. x.CateringReason,
  25888. x.Stay,
  25889. x.StayReason,
  25890. x.Route,
  25891. x.RouteReason,
  25892. x.OfficialActivity,
  25893. x.OfficialActivityReason,
  25894. x.TourGuide,
  25895. x.TourGuideReason,
  25896. x.Translate,
  25897. x.TranslateReason,
  25898. x.Trip,
  25899. x.TripReason,
  25900. x.ESFileName,
  25901. x.SignatureDate,
  25902. x.Remark
  25903. })
  25904. .WhereColumns(x => new { x.Id })
  25905. .ExecuteCommandAsync();
  25906. if (upd < 1)
  25907. {
  25908. foreach (var filePathStr in filePaths)
  25909. {
  25910. System.IO.File.Delete(filePathStr);
  25911. }
  25912. return Ok(JsonView(false));
  25913. }
  25914. return Ok(JsonView(true));
  25915. }
  25916. #endregion
  25917. #region 团组餐厅相关信息
  25918. /// <summary>
  25919. /// 团组相关餐厅信息
  25920. /// 基础数据(团组)
  25921. /// </summary>
  25922. /// <returns></returns>
  25923. [HttpGet]
  25924. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25925. public async Task<IActionResult> RestaurantInit()
  25926. {
  25927. return Ok(await _restaurantRep.InitAsync());
  25928. }
  25929. /// <summary>
  25930. /// 团组相关餐厅信息
  25931. /// Item
  25932. /// </summary>
  25933. /// <param name="dto"></param>
  25934. /// <returns></returns>
  25935. [HttpPost]
  25936. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25937. public async Task<IActionResult> RestaurantItem(RestaurantItemDto dto)
  25938. {
  25939. int portType = dto.PortType,
  25940. groupId = dto.GroupId;
  25941. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  25942. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  25943. return Ok(await _restaurantRep.ItemAsync(portType, groupId));
  25944. }
  25945. /// <summary>
  25946. /// 团组相关餐厅信息
  25947. /// List
  25948. /// </summary>
  25949. /// <param name="dto"></param>
  25950. /// <returns></returns>
  25951. [HttpPost]
  25952. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25953. public async Task<IActionResult> RestaurantList(RestaurantItemDto dto)
  25954. {
  25955. int portType = dto.PortType,
  25956. groupId = dto.GroupId;
  25957. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  25958. if (groupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  25959. var sql = string.Format(@" SELECT
  25960. ri.Id,
  25961. ri.GroupId,
  25962. ri.Date,
  25963. ri.StartTime,
  25964. ri.EndTime,
  25965. CASE WHEN ri.Type = 1 THEN '早餐'
  25966. WHEN ri.Type = 2 THEN '午餐'
  25967. WHEN ri.Type = 3 THEN '晚餐'
  25968. ELSE '其他'
  25969. END AS 'Type',
  25970. ri.Name,
  25971. ri.Address,
  25972. ri.Tel,
  25973. ri.Remark,
  25974. ri.CreateTime,
  25975. u.CnName AS CreateUserName
  25976. FROM
  25977. Grp_RestaurantInfo ri
  25978. LEFT JOIN Sys_Users u ON ri.CreateUserId = u.Id
  25979. WHERE
  25980. ri.IsDel = 0
  25981. AND ri.GroupId = {0}
  25982. ORDER BY
  25983. ri.Date ASC
  25984. ", groupId);
  25985. var infos = await _sqlSugar.SqlQueryable<RestaurantItemView>(sql).ToListAsync();
  25986. if (!infos.Any()) Ok(JsonView(false, "数据未填写!"));
  25987. return Ok(JsonView(infos));
  25988. }
  25989. /// <summary>
  25990. /// 团组相关餐厅信息
  25991. /// Info
  25992. /// </summary>
  25993. /// <param name="dto"></param>
  25994. /// <returns></returns>
  25995. [HttpPost]
  25996. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  25997. public async Task<IActionResult> RestaurantInfo(RestaurantInfoDto dto)
  25998. {
  25999. int portType = dto.PortType,
  26000. id = dto.Id;
  26001. if (!SharingStaticData.PortTypes.Contains(portType)) return Ok(JsonView(false, MsgTips.Port));
  26002. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  26003. return Ok(await _restaurantRep.InfoAsync(portType, id));
  26004. }
  26005. /// <summary>
  26006. /// 团组相关餐厅信息
  26007. /// Op
  26008. /// </summary>
  26009. /// <param name="dto"></param>
  26010. /// <returns></returns>
  26011. [HttpPost]
  26012. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  26013. public async Task<IActionResult> RestaurantOp(RestaurantOpDto dto)
  26014. {
  26015. if (dto.CurrUserId < 1) return Ok(JsonView(false, MsgTips.UserId));
  26016. if (dto.GroupId < 1) return Ok(JsonView(false, MsgTips.DiId));
  26017. if (string.IsNullOrEmpty(dto.Name)) return Ok(JsonView(false, "餐厅名称为空!"));
  26018. return Ok(await _restaurantRep.OpAsync(dto));
  26019. }
  26020. /// <summary>
  26021. /// 团组相关餐厅信息
  26022. /// Del
  26023. /// </summary>
  26024. /// <param name="dto"></param>
  26025. /// <returns></returns>
  26026. [HttpPost]
  26027. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  26028. public async Task<IActionResult> RestaurantDel(RestaurantDelDto dto)
  26029. {
  26030. int userId = dto.DeleteUserId;
  26031. var id = dto.Id;
  26032. if (userId < 1) return Ok(JsonView(false, MsgTips.UserId));
  26033. if (id < 1) return Ok(JsonView(false, MsgTips.Id));
  26034. return Ok(await _restaurantRep.DelAsync(dto));
  26035. }
  26036. #endregion
  26037. #region 团组会务成本
  26038. /// <summary>
  26039. /// 团组会务成本数据初始化
  26040. /// </summary>
  26041. /// <returns></returns>
  26042. [HttpPost]
  26043. public async Task<IActionResult> ConferenceAffairsInIt(ConferenceAffairsInItDto Dto)
  26044. {
  26045. var expr = _sqlSugar.Queryable<Grp_DelegationInfo>()
  26046. .OrderByDescending(x => x.CreateTime)
  26047. .Where(x => x.IsDel == 0)
  26048. .Select<DelegationEasyView>();
  26049. DelegationEasyView di = Dto.GroupId == 0 ?
  26050. expr.First() :
  26051. expr.First(x => x.Id == Dto.GroupId);
  26052. if (di == null)
  26053. {
  26054. return Ok(JsonView(false, "团组信息不存在!"));
  26055. }
  26056. var typeData = await _sqlSugar.Queryable<Sys_SetData>()
  26057. .Where(x => x.IsDel == 0 && x.STid == 21)
  26058. .Select(x => new { x.Id, Text = x.Name })
  26059. .ToListAsync();
  26060. var hwids = _sqlSugar.Queryable<Sys_SetData>()
  26061. .Where(x => x.IsDel == 0 && x.STid == 10 && x.Name.Contains("会务活动"))
  26062. .Select(x => x.Id)
  26063. .ToList();
  26064. //仅检索会务团组
  26065. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26066. .Where(x => x.IsDel == 0 && hwids.Contains(x.TeamDid))
  26067. .OrderByDescending(x => x.VisitDate)
  26068. .Select(x => new { x.Id, x.TeamName })
  26069. .ToListAsync();
  26070. var currenyList = await GeneralMethod.PostGroupTeamRateByDiIdAndCTableId(1, di.Id, 98);
  26071. var userList = await _sqlSugar.Queryable<Sys_Users>()
  26072. .Where(x => x.IsDel == 0)
  26073. .Select(x => new { x.Id, x.CnName })
  26074. .ToListAsync();
  26075. var units = await _sqlSugar.Queryable<Sys_SetData>()
  26076. .Where(x => x.IsDel == 0 && x.STid == 119)
  26077. .Select(x => new { x.Id, Text = x.Name })
  26078. .ToListAsync();
  26079. var FileType = new[]
  26080. {
  26081. new { Id = 0 , Name = "成本下载" },
  26082. new { Id = 1 , Name = "报价下载" },
  26083. new { Id = 2 , Name = "总表下载" },
  26084. };
  26085. var GM = new List<int>();
  26086. var permissionControlDB = _sqlSugar.Queryable<Sys_SetData>().First(x => x.Id == 1448)?.Remark;
  26087. try
  26088. {
  26089. GM = JsonConvert.DeserializeObject<List<int>>(permissionControlDB);
  26090. }
  26091. catch (Exception ex)
  26092. {
  26093. GM = new List<int>() { 21 };
  26094. }
  26095. var isReview = Dto.UserId == 21;
  26096. var isGM = GM.Contains(Dto.UserId);
  26097. var ConferenceAffairsCost = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  26098. .Where(x => x.IsDel == 0)
  26099. .Select<ConferenceAffairsCostView>()
  26100. .First(x => x.Diid == di.Id);
  26101. if (ConferenceAffairsCost == null)
  26102. {
  26103. ConferenceAffairsCost = new ConferenceAffairsCostView();
  26104. ConferenceAffairsCost.Diid = di.Id;
  26105. }
  26106. #region 权限校验
  26107. var ids = _sqlSugar.Queryable<Grp_ConferenceAffairsCostControl>()
  26108. .Where(x => x.Diid == di.Id && x.IsDel == 0)
  26109. .Select(x => x.UserId)
  26110. .Distinct()
  26111. .ToList();
  26112. if (!ids.Contains(Dto.UserId) && !isGM)
  26113. {
  26114. return Ok(JsonView(201, "暂无权限!", new
  26115. {
  26116. typeData,
  26117. groupList,
  26118. currenyList,
  26119. isGM,
  26120. userList,
  26121. units,
  26122. isReview,
  26123. operatorUser = ids,
  26124. di,
  26125. FileType
  26126. }));
  26127. }
  26128. #endregion
  26129. var ConferenceAffairsCostChi = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>()
  26130. .Where(x => x.IsDel == 0 && x.Diid == di.Id)
  26131. .Select<ConferenceAffairsCostChildView>()
  26132. .OrderBy(x => x.Index)
  26133. .ToList();
  26134. for (int i = 1; i <= ConferenceAffairsCostChi.Count; i++)
  26135. {
  26136. ConferenceAffairsCostChi[i - 1].Index = i;
  26137. }
  26138. var backData = new
  26139. {
  26140. ConferenceAffairsCost,
  26141. ConferenceAffairsCostChi,
  26142. typeData,
  26143. groupList,
  26144. currenyList,
  26145. isGM,
  26146. userList,
  26147. units,
  26148. isReview,
  26149. operatorUser = ids,
  26150. di,
  26151. FileType
  26152. };
  26153. return Ok(JsonView(true, "SUCCESS", backData));
  26154. }
  26155. /// <summary>
  26156. /// 会务成本保存
  26157. /// </summary>
  26158. /// <returns></returns>
  26159. [HttpPost]
  26160. public async Task<IActionResult> ConferenceAffairsSave(ConferenceAffairsSaveDto Dto)
  26161. {
  26162. _sqlSugar.BeginTran();
  26163. var data = _mapper.Map<Grp_ConferenceAffairsCost>(Dto.ConferenceAffairsCost);
  26164. var childResult = new
  26165. {
  26166. success = 0,
  26167. error = 0
  26168. };
  26169. try
  26170. {
  26171. if (data.Id == 0)
  26172. {
  26173. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  26174. .Where(x => x.Diid == Dto.GroupId)
  26175. .SetColumns(x => new Grp_ConferenceAffairsCost
  26176. {
  26177. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26178. DeleteUserId = Dto.UserId
  26179. })
  26180. .ExecuteCommand();
  26181. data.Diid = Dto.GroupId;
  26182. data.CreateTime = DateTime.Now;
  26183. data.CreateUserId = Dto.UserId;
  26184. data.Id = _sqlSugar.Insertable<Grp_ConferenceAffairsCost>(data)
  26185. .ExecuteReturnIdentity();
  26186. }
  26187. else
  26188. {
  26189. _sqlSugar.Updateable<Grp_ConferenceAffairsCost>(data)
  26190. .ExecuteCommand();
  26191. data.Id = data.Id;
  26192. }
  26193. if (Dto.ConferenceAffairsCostChild.Any())
  26194. {
  26195. var datas = _mapper.Map<List<Grp_ConferenceAffairsCostChild>>(Dto.ConferenceAffairsCostChild);
  26196. var insertArr = datas.Where(x => x.Id == 0).ToList();
  26197. var updateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus != 1).ToList();
  26198. var notUpdateArr = datas.Where(x => x.Id != 0 && x.ReviewStatus == 1).ToList();
  26199. insertArr.ForEach(x => { x.Diid = Dto.GroupId; x.ConferenceAffairsCostId = data.Id; });
  26200. var inrsetCount = insertArr.Any() ? _sqlSugar.Insertable<Grp_ConferenceAffairsCostChild>(insertArr).ExecuteCommand() : 0;
  26201. var updateCount = updateArr.Any() ? _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>(updateArr)
  26202. .IgnoreColumns(x => new { x.ConferenceAffairsCostId })
  26203. .ExecuteCommand() : 0;
  26204. childResult = childResult with
  26205. {
  26206. error = notUpdateArr.Count(),
  26207. success = inrsetCount + updateCount
  26208. };
  26209. }
  26210. _sqlSugar.CommitTran();
  26211. }
  26212. catch (Exception ex)
  26213. {
  26214. _sqlSugar.RollbackTran();
  26215. return Ok(JsonView(false, "失败!" + ex.Message));
  26216. }
  26217. return Ok(JsonView(true, "操作成功!", childResult));
  26218. }
  26219. [HttpPost]
  26220. public async Task<IActionResult> ConferenceAffairsAudit(ConferenceAffairsAuditDto Dto)
  26221. {
  26222. var count = 0;
  26223. if (Dto.ConferenceAffairsCostChildids.Any())
  26224. {
  26225. count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>().
  26226. Where(x => Dto.ConferenceAffairsCostChildids.Contains(x.Id)).
  26227. SetColumns(x => new Grp_ConferenceAffairsCostChild
  26228. {
  26229. ReviewStatus = Dto.ReviewStatus
  26230. }).
  26231. ExecuteCommand();
  26232. }
  26233. return Ok(JsonView(true, "操作成功!", count));
  26234. }
  26235. /// <summary>
  26236. /// 会务成本所有数据清除
  26237. /// </summary>
  26238. /// <param name="Dto"></param>
  26239. /// <returns></returns>
  26240. [HttpPost]
  26241. public async Task<IActionResult> ConferenceAffairsDelete(ConferenceAffairsDeleteDto Dto)
  26242. {
  26243. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  26244. if (Dto.UserId < 1) return Ok(JsonView(false, "请传入有效的用户Id"));
  26245. _sqlSugar.BeginTran();
  26246. try
  26247. {
  26248. var delCount = _sqlSugar.Updateable<Grp_ConferenceAffairsCost>()
  26249. .Where(x => x.Diid == Dto.GroupId)
  26250. .SetColumns(x => new Grp_ConferenceAffairsCost
  26251. {
  26252. IsDel = 1,
  26253. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26254. DeleteUserId = Dto.UserId
  26255. })
  26256. .ExecuteCommand();
  26257. if (delCount > 0)
  26258. {
  26259. _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  26260. .Where(x => x.Diid == Dto.GroupId)
  26261. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  26262. {
  26263. IsDel = 1,
  26264. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26265. DeleteUserId = Dto.UserId
  26266. })
  26267. .ExecuteCommand();
  26268. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  26269. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  26270. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  26271. {
  26272. IsDel = 1,
  26273. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26274. DeleteUserId = Dto.UserId
  26275. })
  26276. .ExecuteCommand();
  26277. }
  26278. _sqlSugar.CommitTran();
  26279. }
  26280. catch (Exception ex)
  26281. {
  26282. _sqlSugar.RollbackTran();
  26283. return Ok(JsonView(false, "操作失败!" + ex.Message));
  26284. }
  26285. return Ok(JsonView(true, "操作成功!"));
  26286. }
  26287. /// <summary>
  26288. /// 子项数据删除
  26289. /// </summary>
  26290. /// <param name="Dto"></param>
  26291. /// <returns></returns>
  26292. [HttpPost]
  26293. public async Task<IActionResult> ConferenceAffairSinglesDelete(ConferenceAffairsDeleteSingleDto Dto)
  26294. {
  26295. var isAudit = _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && Dto.ids.Contains(x.Id))
  26296. .Any(x => x.ReviewStatus == 1);
  26297. if (isAudit) return Ok(JsonView(false, "包含已审核数据无法删除!"));
  26298. var count = _sqlSugar.Updateable<Grp_ConferenceAffairsCostChild>()
  26299. .Where(x => Dto.ids.Contains(x.Id) && x.IsDel == 0)
  26300. .SetColumns(x => new Grp_ConferenceAffairsCostChild
  26301. {
  26302. IsDel = 1,
  26303. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26304. DeleteUserId = Dto.UserId
  26305. })
  26306. .ExecuteCommand();
  26307. return Ok(JsonView(true, "SUCCESS!", count));
  26308. }
  26309. /// <summary>
  26310. /// 会务成本权限分配
  26311. /// </summary>
  26312. /// <param name="Dto"></param>
  26313. /// <returns></returns>
  26314. [HttpPost]
  26315. public async Task<IActionResult> PermissionSetting(PermissionSettingDto Dto)
  26316. {
  26317. _sqlSugar.BeginTran();
  26318. var count = 0;
  26319. try
  26320. {
  26321. _sqlSugar.Updateable<Grp_ConferenceAffairsCostControl>()
  26322. .Where(x => x.Diid == Dto.GroupId && x.IsDel == 0)
  26323. .SetColumns(x => new Grp_ConferenceAffairsCostControl
  26324. {
  26325. IsDel = 1,
  26326. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26327. DeleteUserId = Dto.CreateUserId
  26328. })
  26329. .ExecuteCommand();
  26330. count = _sqlSugar.Insertable<Grp_ConferenceAffairsCostControl>(Dto.UserIds.Select(x => new Grp_ConferenceAffairsCostControl
  26331. {
  26332. CreateTime = DateTime.Now,
  26333. CreateUserId = Dto.CreateUserId,
  26334. UserId = x,
  26335. Diid = Dto.GroupId,
  26336. }).ToList()).ExecuteCommand();
  26337. _sqlSugar.CommitTran();
  26338. }
  26339. catch (Exception ex)
  26340. {
  26341. _sqlSugar.RollbackTran();
  26342. return Ok(JsonView(false, "操作失败!" + ex.Message));
  26343. }
  26344. return Ok(JsonView(true, "操作成功!", count));
  26345. }
  26346. /// <summary>
  26347. /// 团组会务成本文件下载
  26348. /// </summary>
  26349. /// <returns></returns>
  26350. [HttpPost]
  26351. public async Task<IActionResult> ConferenceAffairsFileDown(ConferenceAffairsFileDownDto Dto)
  26352. {
  26353. var FileType = new[]
  26354. {
  26355. new { Id = 0 , Name = "成本下载" },
  26356. new { Id = 1 , Name = "报价下载" },
  26357. new { Id = 2 , Name = "总表下载" },
  26358. };
  26359. if (Dto.GroupId < 1) return Ok(JsonView(false, "请传入有效的Id"));
  26360. if (Dto.FileTypeId < 0 || Dto.FileTypeId > 2) return Ok(JsonView(false, "请传入有效的文件类型"));
  26361. var di = _sqlSugar.Queryable<Grp_DelegationInfo>()
  26362. .Where(x => x.IsDel == 0 && x.Id == Dto.GroupId)
  26363. .Select<DelegationEasyView>()
  26364. .First();
  26365. var main = _sqlSugar.Queryable<Grp_ConferenceAffairsCost>()
  26366. .First(x => x.Diid == Dto.GroupId && x.IsDel == 0);
  26367. if (main == null)
  26368. {
  26369. return Ok(JsonView(false, "团组会务成本信息不存在!"));
  26370. }
  26371. JsonView jw = JsonView(false);
  26372. //总表下载
  26373. var loadPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/template/";
  26374. var outputPath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceAffairs/output/total/";
  26375. var networkPath = outputPath.Replace(AppSettingsHelper.Get("ExcelBasePath"), AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  26376. var field = string.Empty;
  26377. var fileTypeName = string.Empty;
  26378. field = @$"
  26379. a.[Index],a.PriceName,a.CostPrice,a.Count,a.Coefficient,a.BaoJiaPrice,a.AddedValue,a.Details,a.Remark,a.Rate,
  26380. b.Name as PriceTypeStr ,
  26381. c.Name as CurrencyStr ,
  26382. d.Name as UnitStr ,
  26383. case a.ReviewStatus
  26384. WHEN 1 THEN '已通过'
  26385. WHEN 0 THEN '未审核'
  26386. WHEN -1 THEN '未通过'
  26387. ELSE '未审核'
  26388. END AS ReviewStatusStr
  26389. ";
  26390. if (Dto.FileTypeId == 0)
  26391. {
  26392. fileTypeName = "会务成本成本表";
  26393. loadPath += $"{fileTypeName}.xlsx";
  26394. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26395. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26396. }
  26397. else if (Dto.FileTypeId == 1)
  26398. {
  26399. fileTypeName = "会务成本报价表";
  26400. loadPath += $"{fileTypeName}.xlsx";
  26401. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26402. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26403. }
  26404. else if (Dto.FileTypeId == 2)
  26405. {
  26406. fileTypeName = "会务成本总表";
  26407. loadPath += $"{fileTypeName}.xlsx";
  26408. outputPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26409. networkPath += $"{di.TeamName}_{fileTypeName}.xlsx";
  26410. }
  26411. var chiExcelContent = _sqlSugar.SqlQueryable<ConferenceAffairsExcelContent>(@$"
  26412. SELECT
  26413. {field}
  26414. FROM Grp_ConferenceAffairsCostChild a
  26415. LEFT JOIN Sys_SetData b on b.IsDel = 0 AND b.Id = a.PriceType
  26416. LEFT JOIN Sys_SetData c on c.IsDel = 0 AND c.Id = a.Currency
  26417. LEFT JOIN Sys_SetData d on d.IsDel = 0 AND d.Id = a.Unit
  26418. WHERE a.isdel = 0
  26419. AND a.Diid = {main.Diid}
  26420. AND a.ConferenceAffairsCostId = {main.Id}
  26421. ").ToList();
  26422. var currLists = chiExcelContent.Select(x => new CurrList
  26423. {
  26424. CurrName = x.CurrencyStr,
  26425. CurrRate = x.Rate
  26426. })
  26427. .Distinct()
  26428. .ToList();
  26429. var designer = new WorkbookDesigner
  26430. {
  26431. Workbook = new Workbook(loadPath)
  26432. };
  26433. var MostCurr = _sqlSugar.Queryable<Sys_SetData>().First(x => x.IsDel == 0 && x.Id == main.MostCurr);
  26434. MostCurr ??= new Sys_SetData { Name = "暂无!" };
  26435. designer.SetDataSource("TeamName", di.TeamName);
  26436. designer.SetDataSource("City", main.City);
  26437. designer.SetDataSource("AllCost", main.CostAll);
  26438. designer.SetDataSource("AllBaoJia", main.BaoJiaAll);
  26439. designer.SetDataSource("Curr", MostCurr.Name);
  26440. designer.SetDataSource("Curr1", MostCurr.Name);
  26441. DataTable dt = CommonFun.GetDataTableFromIList<ConferenceAffairsExcelContent>(chiExcelContent);
  26442. dt.TableName = "TB";
  26443. designer.SetDataSource(dt);
  26444. DataTable dt1 = CommonFun.GetDataTableFromIList<CurrList>(currLists);
  26445. dt1.TableName = "currTb";
  26446. designer.SetDataSource(dt1);
  26447. designer.Process();
  26448. designer.Workbook.Save(outputPath);
  26449. jw = JsonView(true, "操作成功!", new
  26450. {
  26451. FileName = $"{di.TeamName}_{fileTypeName}.xlsx",
  26452. FilePath = networkPath
  26453. });
  26454. return Ok(jw);
  26455. }
  26456. [HttpPost]
  26457. public async Task<IActionResult> QueryConferenceAffairsChild(QueryConferenceAffairsChildDto Dto)
  26458. {
  26459. return Ok(JsonView(true, "SUCCESS", _sqlSugar.Queryable<Grp_ConferenceAffairsCostChild>().Where(x => x.IsDel == 0 && x.Diid == Dto.GroupId)
  26460. .Select(x => x.PriceName).ToList()));
  26461. }
  26462. #endregion
  26463. #region 会务流程
  26464. /// <summary>
  26465. /// 会务流程 - 团组列表
  26466. /// </summary>
  26467. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  26468. [HttpGet]
  26469. public async Task<IActionResult> ConferenceProceduresGroupNames()
  26470. {
  26471. var conferenceTypeIds = new List<int>() {
  26472. 302, // 成都-会务活动
  26473. 691 // 四川-会务活动
  26474. };
  26475. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26476. .Where(x => x.IsDel == 0)
  26477. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  26478. .OrderByDescending(x => x.VisitDate)
  26479. .Select(x => new
  26480. {
  26481. x.Id,
  26482. x.TeamName,
  26483. HasChildData = SqlFunc.Subqueryable<Grp_ConferenceProcedures>()
  26484. .Where(child => child.DiId == x.Id) // 替换关联条件
  26485. .Any() // 判断子表是否存在数据
  26486. })
  26487. .ToListAsync();
  26488. return Ok(JsonView(true, "SUCCESS", groupList));
  26489. }
  26490. /// <summary>
  26491. /// 会务流程 - 数据初始化
  26492. /// </summary>
  26493. /// <param name="dto"></param>
  26494. /// <returns>团组基本信息、团组列表和会务基本信息列表</returns>
  26495. [HttpPost]
  26496. public async Task<IActionResult> ConferenceProceduresInit(ConferenceProceduresInitDto dto)
  26497. {
  26498. try
  26499. {
  26500. var conferenceTypeIds = new List<int>() {
  26501. 302, // 成都-会务活动
  26502. 691 // 四川-会务活动
  26503. };
  26504. Grp_DelegationInfo targetGroup = null;
  26505. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26506. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  26507. .FirstAsync();
  26508. if (targetGroup == null)
  26509. {
  26510. targetGroup = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26511. .Where(x => x.IsDel == 0)
  26512. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  26513. .OrderByDescending(x => x.VisitDate)
  26514. .FirstAsync();
  26515. }
  26516. if (targetGroup == null)
  26517. {
  26518. return Ok(JsonView(false, "未找到任何团组信息"));
  26519. }
  26520. var groupList = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26521. .Where(x => x.IsDel == 0)
  26522. .Where(x => conferenceTypeIds.Contains(x.TeamDid))
  26523. .OrderByDescending(x => x.VisitDate)
  26524. .Select(x => new
  26525. {
  26526. x.Id,
  26527. x.TeamName,
  26528. HasChildData = SqlFunc.Subqueryable<Grp_ConferenceProcedures>()
  26529. .Where(child => child.DiId == x.Id)
  26530. .Any() // 判断子表是否存在数据
  26531. })
  26532. .ToListAsync();
  26533. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  26534. .Where(x => x.DiId == targetGroup.Id && x.IsDel == 0)
  26535. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  26536. .ToListAsync();
  26537. if (!conferenceProceduresList.Any())
  26538. {
  26539. conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  26540. .Where(x => x.DiId == -1 && x.IsDel == 0)
  26541. .Select(x => new { x.Id, x.Title, x.DataDetails, x.Details, x.Remark })
  26542. .ToListAsync();
  26543. }
  26544. var conferenceProceduresGroupByTitle = conferenceProceduresList
  26545. .GroupBy(x => x.Title)
  26546. .Select(x => new
  26547. {
  26548. title = x.Key,
  26549. itmes = x.Select(y => new
  26550. {
  26551. y.Id,
  26552. y.DataDetails,
  26553. y.Details,
  26554. y.Remark
  26555. }).ToList()
  26556. })
  26557. .ToList();
  26558. var response = new
  26559. {
  26560. GroupInfo = new
  26561. {
  26562. targetGroup.Id,
  26563. targetGroup.TeamName,
  26564. targetGroup.VisitDate,
  26565. targetGroup.VisitDays,
  26566. targetGroup.VisitPNumber,
  26567. targetGroup.VisitCountry,
  26568. targetGroup.VisitStartDate,
  26569. targetGroup.VisitEndDate,
  26570. targetGroup.ClientName,
  26571. targetGroup.ClientUnit
  26572. },
  26573. GroupList = groupList,
  26574. ConferenceProceduresList = conferenceProceduresList,
  26575. conferenceProceduresGroupByTitle = conferenceProceduresGroupByTitle
  26576. };
  26577. return Ok(JsonView(true, "SUCCESS", response));
  26578. }
  26579. catch (Exception ex)
  26580. {
  26581. _logger.LogError(ex, "数据初始化失败");
  26582. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  26583. }
  26584. }
  26585. /// <summary>
  26586. /// 会务流程 - 保存
  26587. /// </summary>
  26588. /// <param name="dto"></param>
  26589. /// <returns></returns>
  26590. [HttpPost]
  26591. public async Task<IActionResult> ConferenceProceduresSave(ConferenceProceduresSaveDto dto)
  26592. {
  26593. _sqlSugar.BeginTran();
  26594. try
  26595. {
  26596. //删除旧数据
  26597. _sqlSugar.Updateable<Grp_ConferenceProcedures>()
  26598. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  26599. .SetColumns(x => new Grp_ConferenceProcedures
  26600. {
  26601. IsDel = 1,
  26602. DeleteTime = DateTime.Now.ToString("yyyy-MM-dd"),
  26603. DeleteUserId = dto.UserId
  26604. })
  26605. .ExecuteCommand();
  26606. //添加新数据
  26607. var newData = new List<Grp_ConferenceProcedures>();
  26608. foreach (var item in dto.ConferenceProceduresSaveItem)
  26609. {
  26610. foreach (var item2 in item.itmes)
  26611. {
  26612. newData.Add(new Grp_ConferenceProcedures
  26613. {
  26614. DiId = dto.GroupId,
  26615. Title = item.title,
  26616. DataDetails = item2.DataDetails,
  26617. Details = item2.details,
  26618. Remark = item2.Remark,
  26619. CreateTime = DateTime.Now,
  26620. CreateUserId = dto.UserId
  26621. });
  26622. }
  26623. }
  26624. _sqlSugar.Insertable(newData).ExecuteCommand();
  26625. _sqlSugar.CommitTran();
  26626. }
  26627. catch (Exception ex)
  26628. {
  26629. _sqlSugar.RollbackTran();
  26630. return Ok(JsonView(false, $"ERROR:{ex.Message}"));
  26631. }
  26632. return Ok(JsonView(true, "SUCCESS"));
  26633. }
  26634. [HttpPost]
  26635. public async Task<IActionResult> ConferenceProceduresFileDown(ConferenceProceduresFileDownDto dto)
  26636. {
  26637. var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26638. .Where(x => x.Id == dto.GroupId && x.IsDel == 0)
  26639. .FirstAsync();
  26640. if (groupInfo == null)
  26641. {
  26642. return Ok(JsonView(false, "团组信息不存在"));
  26643. }
  26644. var conferenceProceduresList = await _sqlSugar.Queryable<Grp_ConferenceProcedures>()
  26645. .Where(x => x.DiId == dto.GroupId && x.IsDel == 0)
  26646. .ToListAsync();
  26647. if (!conferenceProceduresList.Any())
  26648. {
  26649. return Ok(JsonView(false, "会务流程信息不存在"));
  26650. }
  26651. var filePath = $"{AppSettingsHelper.Get("ExcelBasePath")}Template/会务流程.xlsx";
  26652. if (!System.IO.File.Exists(filePath))
  26653. {
  26654. return Ok(JsonView(false, "模板文件不存在"));
  26655. }
  26656. var designer = new WorkbookDesigner();
  26657. designer.Workbook = new Workbook(filePath);
  26658. designer.SetDataSource("TB", conferenceProceduresList);
  26659. designer.Process();
  26660. var sheet = designer.Workbook.Worksheets[0];
  26661. var cells = sheet.Cells;
  26662. int col = 0; // 第一列
  26663. int startRow = 2; // 若第0行为表头,则从第1行开始;无表头请改为0
  26664. int endRow = cells.MaxDataRow;
  26665. if (endRow >= startRow)
  26666. {
  26667. int mergeStart = startRow;
  26668. string prev = cells[mergeStart, col].StringValue?.Trim() ?? string.Empty;
  26669. for (int r = startRow + 1; r <= endRow; r++)
  26670. {
  26671. string cur = cells[r, col].StringValue?.Trim() ?? string.Empty;
  26672. if (!string.Equals(cur, prev, StringComparison.Ordinal))
  26673. {
  26674. int count = r - mergeStart;
  26675. if (count > 1)
  26676. cells.Merge(mergeStart, col, count, 1);
  26677. mergeStart = r;
  26678. prev = cur;
  26679. }
  26680. }
  26681. int tailCount = endRow - mergeStart + 1;
  26682. if (tailCount > 1)
  26683. cells.Merge(mergeStart, col, tailCount, 1);
  26684. }
  26685. // byte[] bytes = null;
  26686. // using (MemoryStream stream = new MemoryStream())
  26687. // {
  26688. // designer.Workbook.Save(stream, Aspose.Cells.SaveFormat.Xlsx);
  26689. // bytes = stream.ToArray();
  26690. // }
  26691. // return File(bytes, "application/excel", $"{groupInfo.TeamName}_会务流程.xlsx");
  26692. string savePath = $"{AppSettingsHelper.Get("ExcelBasePath")}ConferenceProcedures";
  26693. if (!System.IO.Directory.Exists(savePath))
  26694. {
  26695. System.IO.Directory.CreateDirectory(savePath);
  26696. }
  26697. designer.Workbook.Save($"{savePath}/{groupInfo.TeamName}_会务流程.xlsx");
  26698. string rst = savePath.replace(AppSettingsHelper.Get("ExcelBasePath"),
  26699. AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath"));
  26700. return Ok(JsonView(true, "SUCCESS", $"{rst}/{groupInfo.TeamName}_会务流程.xlsx"));
  26701. }
  26702. #endregion
  26703. #region 团组签证流程
  26704. /// <summary>
  26705. /// 团组签证流程 - 团组列表(分页)
  26706. /// </summary>
  26707. /// <returns></returns>
  26708. [HttpPost]
  26709. public async Task<IActionResult> VisaProcessGroupNames(VisaProcessGroupNamesDto dto)
  26710. {
  26711. int currUserId = dto.CurrUserId <= 0 ? 1 : dto.CurrUserId;
  26712. string groupName = dto.GroupName.Trim();
  26713. int pageIndex = dto.PageIndex <= 0 ? 1 : dto.PageIndex;
  26714. int pageSize = dto.PageSize <= 0 ? 10 : dto.PageSize;
  26715. int portType = dto.PortType;
  26716. RefAsync<int> total = 0;
  26717. var query = _sqlSugar.Queryable<Grp_GroupsTaskAssignment>()
  26718. .InnerJoin<Grp_DelegationInfo>((x, y) => x.DIId == y.Id)
  26719. .InnerJoin<Grp_VisaProcessSteps>((x, y, z) => x.DIId == z.GroupId)
  26720. .Where((x, y, z) => x.IsDel == 0 && x.CTId == 80 && x.UId == currUserId && z.IsDel == 0);
  26721. //构建单字模糊查询
  26722. if (!string.IsNullOrEmpty(groupName))
  26723. {
  26724. var characters = groupName.ToCharArray();
  26725. foreach (var character in characters)
  26726. {
  26727. var charString = character.ToString();
  26728. query = query.Where((x, y) =>
  26729. SqlFunc.Contains(y.TeamName, charString));
  26730. }
  26731. }
  26732. var groups = await query
  26733. .OrderByDescending((x, y) => y.VisitDate)
  26734. .Select((x, y) => new
  26735. {
  26736. y.Id,
  26737. GroupName = y.TeamName,
  26738. y.VisitDate,
  26739. // 加入子查询统计子表条数
  26740. CompletedCount = SqlFunc.Subqueryable<Grp_VisaProcessSteps>()
  26741. .Where(sub => sub.GroupId == y.Id && sub.IsCompleted && sub.IsDel == 0)
  26742. .Count()
  26743. })
  26744. .Distinct()
  26745. .ToPageListAsync(pageIndex, pageSize, total);
  26746. var msg = "SUCCESS";
  26747. if (total <= 0) msg = "暂无可操作的团组,请联系经理分配团组!";
  26748. var groups1 = groups.Select(x => new
  26749. {
  26750. x.Id,
  26751. x.GroupName,
  26752. x.CompletedCount
  26753. }).ToList();
  26754. return Ok(JsonView(true, msg, groups1, total));
  26755. }
  26756. /// <summary>
  26757. /// 团组签证流程 - 详情
  26758. /// </summary>
  26759. /// <returns></returns>
  26760. [HttpPost]
  26761. public async Task<IActionResult> VisaProcessInfoByGroupId(VisaProcessInfoByGroupIdDto dto)
  26762. {
  26763. var res = await _visaProcessRep.Info(dto);
  26764. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  26765. return Ok(JsonView(true, res.Msg, res.Data));
  26766. }
  26767. /// <summary>
  26768. /// 团组签证流程 - 流程创建测试
  26769. /// </summary>
  26770. /// <returns></returns>
  26771. [HttpPost]
  26772. public async Task<IActionResult> VisaProcessAdd(int groupId, int currUserId)
  26773. {
  26774. return Ok(await _visaProcessRep.Create(currUserId, groupId));
  26775. }
  26776. /// <summary>
  26777. /// 团组签证流程 - 流程Top4Init 测试
  26778. /// </summary>
  26779. /// <returns></returns>
  26780. [HttpPost]
  26781. public async Task<IActionResult> VisaProcessTop4StepInit(int groupId, int currUserId)
  26782. {
  26783. return Ok(await _visaProcessRep.UpdateBatchTop4Step(groupId, currUserId));
  26784. }
  26785. /// <summary>
  26786. /// 团组签证流程 - 设置状态 完成/未完成
  26787. /// </summary>
  26788. /// <returns></returns>
  26789. [HttpPost]
  26790. public async Task<IActionResult> VisaProcessSetCompleted(VisaProcessSetCompletedDto dto)
  26791. {
  26792. //参数验证
  26793. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).AnyAsync();
  26794. if (!stepValid) return Ok(JsonView(false, "签证流程ID无效。"));
  26795. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  26796. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26797. var res = await _visaProcessRep.SetCompleted(dto.StepId, dto.CurrUserId, dto.IsCompleted);
  26798. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  26799. return Ok(JsonView(true, res.Msg));
  26800. }
  26801. /// <summary>
  26802. /// 团组签证流程 - 修改各步骤内容
  26803. /// </summary>
  26804. /// <returns></returns>
  26805. [HttpPost]
  26806. public async Task<IActionResult> VisaProcessSetContent(VisaProcessSetContent dto)
  26807. {
  26808. //参数验证
  26809. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  26810. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  26811. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  26812. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26813. if (dto.StepContents == null && dto.StepContents.Count < 1)
  26814. {
  26815. return Ok(JsonView(false, "步骤内容无效。"));
  26816. }
  26817. //各步骤值处理
  26818. object stepVal;
  26819. if (stepValid.Step == 7) stepVal = dto.StepContents;
  26820. else stepVal = dto.StepContents[0].ToString();
  26821. var stepInfo = new Grp_VisaProcessSteps
  26822. {
  26823. Id = dto.StepId,
  26824. DataType = stepValid.DataType,
  26825. TypedValue = stepVal,
  26826. LastUpdateUserId = dto.CurrUserId
  26827. };
  26828. var res = await _visaProcessRep.Update(stepInfo);
  26829. if (res.Code != 200) return Ok(JsonView(false, res.Msg));
  26830. return Ok(JsonView(true, res.Msg));
  26831. }
  26832. /// <summary>
  26833. /// 团组签证流程 - 上传文件
  26834. /// </summary>
  26835. /// <returns></returns>
  26836. [HttpPost]
  26837. public async Task<IActionResult> VisaProcessUploadFiles([FromForm] VisaProcessUploadFilesDto dto)
  26838. {
  26839. //参数验证
  26840. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == dto.StepId && x.IsDel == 0).FirstAsync();
  26841. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  26842. var before = stepValid;
  26843. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == dto.CurrUserId && x.IsDel == 0).AnyAsync();
  26844. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26845. //验证文件是否存在
  26846. if (dto.Files == null || dto.Files.Count < 1) return Ok(JsonView(false, "请选择文件。"));
  26847. //验证该步骤是否可以上传文件
  26848. var uploadSteps = new List<int>() {
  26849. 5, //实际出签时间
  26850. 6, //是否需要开出境证明
  26851. 7, //是否需要办理电子入境卡手续
  26852. };
  26853. if (!uploadSteps.Contains(stepValid.Step))
  26854. {
  26855. return Ok(JsonView(false, $"该步骤不可上传附件。可上传附件步骤({string.Join("、", uploadSteps)})"));
  26856. }
  26857. //验证根目录
  26858. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  26859. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  26860. if (!System.IO.Directory.Exists(rootPath))
  26861. {
  26862. System.IO.Directory.CreateDirectory(rootPath);
  26863. }
  26864. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  26865. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26866. .Where(x => x.IsDel == 0 && x.Id == stepValid.GroupId)
  26867. .Select(x => $"{x.TeamName}({x.Id})")
  26868. .FirstAsync();
  26869. //创建团组文件夹
  26870. var groupPath = rootPath + "GrpFile/VisaProcessFiles/" + groupName;
  26871. if (!System.IO.Directory.Exists(groupPath))
  26872. {
  26873. System.IO.Directory.CreateDirectory(groupPath);
  26874. }
  26875. List<string> filePaths = new List<string>();
  26876. //保存文件
  26877. foreach (var file in dto.Files)
  26878. {
  26879. // 生成存储文件名
  26880. var fileName = CommonFun.GenerateStoredFileName($"Step{stepValid.Step}.{file.FileName.Split(".")[1]}");
  26881. var filePath = Path.Combine(groupPath, fileName);
  26882. // 保存文件到磁盘
  26883. using (var stream = new FileStream(filePath, FileMode.Create))
  26884. {
  26885. await file.CopyToAsync(stream);
  26886. }
  26887. filePaths.Add($"GrpFile/VisaProcessFiles/{groupName}/{fileName}");
  26888. }
  26889. //数据库存储
  26890. stepValid.TypedFileNameValue = filePaths;
  26891. stepValid.LastUpdateUserId = dto.CurrUserId;
  26892. stepValid.LastUpdateTime = DateTime.Now;
  26893. var res = await _sqlSugar.Updateable(stepValid)
  26894. .UpdateColumns(it => new { it.TypedFileNameValue, it.LastUpdateUserId, it.LastUpdateTime })
  26895. .Where(s => s.Id == dto.StepId && s.IsDel == 0)
  26896. .ExecuteCommandAsync();
  26897. if (res < 1) Ok(JsonView(false, "文件上传失败。"));
  26898. //记录上传文件
  26899. await _visaProcessRep.LogOperationAsync(before, stepValid, "Upload", dto.CurrUserId);
  26900. return Ok(JsonView(true));
  26901. }
  26902. /// <summary>
  26903. /// 团组签证流程 - step 7 资料下载
  26904. /// </summary>
  26905. /// <returns></returns>
  26906. [HttpGet]
  26907. public async Task<IActionResult> VisaProcessDownload(int groupId, int currUserId)
  26908. {
  26909. var userValid = await _sqlSugar.Queryable<Sys_Users>().Where(x => x.Id == currUserId && x.IsDel == 0).AnyAsync();
  26910. if (!userValid) return Ok(JsonView(false, "用户ID无效。"));
  26911. //验证根目录
  26912. string rootRrl = AppSettingsHelper.Get("OfficeBaseUrl");
  26913. string rootPath = AppSettingsHelper.Get("OfficeTempBasePath");
  26914. if (!System.IO.Directory.Exists(rootPath))
  26915. {
  26916. System.IO.Directory.CreateDirectory(rootPath);
  26917. }
  26918. //验证签证流程上传文件夹 //按照团组名称存储文件夹 GrpFile/VisaProcessFiles/
  26919. var groupName = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  26920. .Where(x => x.IsDel == 0 && x.Id == groupId)
  26921. .Select(x => $"{x.TeamName}({x.Id})")
  26922. .FirstAsync();
  26923. //创建团组文件夹
  26924. var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
  26925. var randomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  26926. var dirName = $"{groupName}_相关资料_{timestamp}";
  26927. var sourceDirectoryPath = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}";
  26928. var path = $"{rootPath}/GrpFile/VisaProcessFiles/{groupName}/{dirName}";
  26929. if (!System.IO.Directory.Exists(path))
  26930. {
  26931. System.IO.Directory.CreateDirectory(path);
  26932. }
  26933. //验证接团客户名单
  26934. string sql = string.Format(@"
  26935. SELECT
  26936. tcl.Id,
  26937. tcl.DiId,
  26938. tcl.IsAccompany,
  26939. temp.*,
  26940. u.CnName AS Operator,
  26941. tcl.CreateTime AS OperatingTime,
  26942. ssd.name AS ShippingSpaceType
  26943. FROM
  26944. Grp_TourClientList tcl
  26945. LEFT JOIN (
  26946. SELECT
  26947. dc.Id AS DcId,
  26948. dc.LastName,
  26949. dc.FirstName,
  26950. ccom.CompanyFullName,
  26951. dc.Job,
  26952. cc.CertNo AS IDCardNo,
  26953. dc.Sex,
  26954. dc.BirthDay
  26955. FROM
  26956. Crm_DeleClient dc
  26957. LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
  26958. AND ccom.IsDel = 0
  26959. LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
  26960. AND cc.SdId = 773
  26961. AND cc.IsDel = 0
  26962. WHERE
  26963. dc.IsDel = 0
  26964. ) temp ON temp.DcId = tcl.ClientId
  26965. LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
  26966. LEFT JOIN sys_setdata ssd ON ssd.isdel = 0 AND ssd.id = tcl.ShippingSpaceTypeid
  26967. WHERE
  26968. tcl.IsDel = 0
  26969. AND tcl.DiId = {0}", groupId);
  26970. var groupClientList = await _sqlSugar.SqlQueryable<TourClientInfosView>(sql).ToListAsync();
  26971. //解密
  26972. foreach (var item in groupClientList)
  26973. {
  26974. EncryptionProcessor.DecryptProperties(item);
  26975. }
  26976. if (groupClientList == null || groupClientList.Count < 1)
  26977. {
  26978. return Ok(JsonView(false, $"团组客户名单未录入客户信息,不可生成相关资料。"));
  26979. }
  26980. #region 生成文件
  26981. //酒店信息
  26982. var hotelInfos = await _sqlSugar.Queryable<Grp_HotelReservations>()
  26983. .Where(x => x.IsDel == 0 && x.DiId == groupId)
  26984. .OrderBy(x => x.CheckInDate)
  26985. .ToListAsync();
  26986. //航班信息
  26987. var airInfos = await _sqlSugar.Queryable<Grp_AirTicketReservations>()
  26988. .Where(x => x.IsDel == 0 && x.DIId == groupId)
  26989. .OrderBy(x => x.FlightsDate)
  26990. .ToListAsync();
  26991. foreach (var clientInfo in groupClientList)
  26992. {
  26993. var clientId = clientInfo.DcId;
  26994. var guestName = $"{clientInfo.LastName}{clientInfo.FirstName}";
  26995. #region 个人信息资料
  26996. #endregion
  26997. #region 机票航班信息
  26998. var clientAirInfos = airInfos.Where(x => x.ClientName.Contains(clientId.ToString())).ToList();
  26999. if (clientAirInfos != null && clientAirInfos.Count > 0)
  27000. {
  27001. //创建表格
  27002. Document airDoc = new Document();
  27003. DocumentBuilder airBuilder = new DocumentBuilder(airDoc);
  27004. GeneralMethod.SetupDocumentStyles(airBuilder);
  27005. GeneralMethod.AddTitle(airBuilder, $"{guestName} - 机票信息");
  27006. GeneralMethod.AddAirInfoSections(airBuilder, clientAirInfos, "机票航班信息");
  27007. var airRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  27008. var airFileName = $"{guestName}_机票信息_{airRandomStr}.docx";
  27009. airDoc.Save($"{path}/{airFileName}");
  27010. }
  27011. #endregion
  27012. #region 酒店信息
  27013. var clientHotelInfos = hotelInfos.Where(x => x.GuestName.Contains(clientId.ToString())).ToList();
  27014. if (clientHotelInfos != null && clientHotelInfos.Count > 0)
  27015. {
  27016. //创建表格
  27017. Document hotelDoc = new Document();
  27018. DocumentBuilder HotelBuilder = new DocumentBuilder(hotelDoc);
  27019. GeneralMethod.SetupDocumentStyles(HotelBuilder);
  27020. GeneralMethod.AddTitle(HotelBuilder, $"{guestName} - 酒店信息");
  27021. GeneralMethod.AddHotelInfoSections(HotelBuilder, clientHotelInfos, "酒店信息");
  27022. var hotelRandomStr = Guid.NewGuid().ToString("N").Substring(0, 8);
  27023. var hotelFileName = $"{guestName}_酒店信息_{hotelRandomStr}.docx";
  27024. hotelDoc.Save($"{path}/{hotelFileName}");
  27025. }
  27026. #endregion
  27027. }
  27028. #endregion
  27029. //打包文件夹
  27030. var sourceDirectory = $"{sourceDirectoryPath}/{dirName}";
  27031. var zipFilePath = $"{sourceDirectoryPath}/{dirName}.zip";
  27032. if (System.IO.File.Exists(zipFilePath))
  27033. {
  27034. System.IO.File.Delete(zipFilePath);
  27035. }
  27036. ZipFile.CreateFromDirectory(sourceDirectory, zipFilePath, CompressionLevel.Fastest, false);
  27037. // 等待并验证
  27038. await Task.Delay(100); // 给系统时间完成文件操作
  27039. if (System.IO.File.Exists(zipFilePath))
  27040. {
  27041. var fileInfo = new FileInfo(zipFilePath);
  27042. var url = $"{rootRrl}Office/GrpFile/VisaProcessFiles/{groupName}/{dirName}.zip";
  27043. //记录下载日志
  27044. await _visaProcessRep.LogOperationAsync(null, null, "Download", currUserId);
  27045. return Ok(JsonView(StatusCodes.Status200OK, "操作成功!", url));
  27046. }
  27047. return Ok(JsonView(false));
  27048. }
  27049. /// <summary>
  27050. /// 团组签证流程 - 根据步骤记录ID获取该步骤的所有操作日志
  27051. /// </summary>
  27052. /// <returns></returns>
  27053. [HttpGet]
  27054. public async Task<IActionResult> VisaProcessLogByStepId(int stepId)
  27055. {
  27056. //参数验证
  27057. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.Id == stepId && x.IsDel == 0).FirstAsync();
  27058. if (stepValid == null) return Ok(JsonView(false, "签证流程ID无效。"));
  27059. var logs = await _visaProcessRep.GetStepLogsAsync(stepId);
  27060. return Ok(JsonView(logs));
  27061. }
  27062. /// <summary>
  27063. /// 团组签证流程 - 根据团组ID获取该团组下所有步骤的操作日志
  27064. /// </summary>
  27065. /// <returns></returns>
  27066. [HttpGet]
  27067. public async Task<IActionResult> VisaProcessLogByGroupId(int groupId)
  27068. {
  27069. //参数验证
  27070. var stepValid = await _sqlSugar.Queryable<Grp_VisaProcessSteps>().Where(x => x.GroupId == groupId && x.IsDel == 0).FirstAsync();
  27071. if (stepValid == null) return Ok(JsonView(false, "团组ID无效。"));
  27072. var logs = await _visaProcessRep.GetGroupStepLogsAsync(groupId);
  27073. return Ok(JsonView(logs));
  27074. }
  27075. #endregion
  27076. #region 团组总览进程
  27077. /// <summary>
  27078. /// 团组总览进程 - 流程创建测试
  27079. /// </summary>
  27080. /// <returns></returns>
  27081. [HttpGet]
  27082. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27083. public async Task<IActionResult> GroupProcessInitTest(int groupId, int currUserId)
  27084. {
  27085. return Ok(await _processOverviewRep.ProcessInitAsync(groupId, currUserId));
  27086. }
  27087. /// <summary>
  27088. /// 团组总览进程 - 团组名称集合
  27089. /// </summary>
  27090. /// <returns></returns>
  27091. [HttpGet]
  27092. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27093. public async Task<IActionResult> GroupProcessGroupNames()
  27094. {
  27095. var groupNames = await _sqlSugar.Queryable<Grp_DelegationInfo>()
  27096. .Where(x => x.IsDel == 0)
  27097. .OrderByDescending(x => x.VisitDate)
  27098. .Select(x => new
  27099. {
  27100. x.Id,
  27101. GroupName = x.TeamName,
  27102. HasProcess = SqlFunc.Subqueryable<Grp_ProcessOverview>()
  27103. .Where(po => po.GroupId == x.Id && po.IsDel == 0)
  27104. .Any()
  27105. })
  27106. .ToListAsync();
  27107. return Ok(JsonView(groupNames));
  27108. }
  27109. /// <summary>
  27110. /// 团组总览进程 - 流程详情
  27111. /// </summary>
  27112. /// <returns></returns>
  27113. [HttpGet]
  27114. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27115. public async Task<IActionResult> GroupProcessDetails(int groupId)
  27116. {
  27117. var res = await _processOverviewRep.ProcessesDetailsAsync(groupId);
  27118. if (res.Code == StatusCodes.Status200OK)
  27119. {
  27120. return Ok(JsonView(res.Data));
  27121. }
  27122. return Ok(JsonView(false, res.Msg));
  27123. }
  27124. /// <summary>
  27125. /// 团组总览进程 - 更新节点状态
  27126. /// </summary>
  27127. /// <returns></returns>
  27128. [HttpPost]
  27129. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27130. public async Task<IActionResult> GroupProcessUpdateNodeStatus(GroupProcessUpdateNodeStatusDto dto)
  27131. {
  27132. var res = await _processOverviewRep.UpdateNodeStatusAsync(dto.NodeId, dto.CurrUserId);
  27133. if (res.Code == StatusCodes.Status200OK)
  27134. {
  27135. return Ok(JsonView(res.Data));
  27136. }
  27137. return Ok(JsonView(false, res.Msg));
  27138. }
  27139. /// <summary>
  27140. /// 团组总览进程 - 更新签证节点信息
  27141. /// </summary>
  27142. /// <returns></returns>
  27143. [HttpPost]
  27144. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27145. public async Task<IActionResult> GroupProcessUpdateVisaNodeDetails(GroupProcessUpdateVisaNodeDetailsDto dto)
  27146. {
  27147. //验证签证信息
  27148. if (dto.VisaSubNodes.Count < 1) return Ok(JsonView(false, "请传入有效的签证节点信息。"));
  27149. var res = await _processOverviewRep.UpdateVisaNodeDetailsAsync(dto);
  27150. if (res.Code == StatusCodes.Status200OK)
  27151. {
  27152. return Ok(JsonView(res.Data));
  27153. }
  27154. return Ok(JsonView(false, res.Msg));
  27155. }
  27156. /// <summary>
  27157. /// 团组总览进程 - 设置实际完成时间
  27158. /// </summary>
  27159. /// <returns></returns>
  27160. [HttpPost]
  27161. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27162. public async Task<IActionResult> GroupProcessSetActualDone(GroupProcessSetActualDoneDto dto)
  27163. {
  27164. //验证签证信息
  27165. var res = await _processOverviewRep.SetActualDoneAsync(dto);
  27166. if (res.Code == StatusCodes.Status200OK)
  27167. {
  27168. return Ok(JsonView(res.Data));
  27169. }
  27170. return Ok(JsonView(false, res.Msg));
  27171. }
  27172. #endregion
  27173. /// <summary>
  27174. /// 123132123
  27175. /// </summary>
  27176. /// <param name="_dto"></param>
  27177. /// <returns></returns>
  27178. [HttpPost]
  27179. [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
  27180. public async Task<IActionResult> Test_DataChange(PostTourClientListDownloadFile _dto)
  27181. {
  27182. _airTicketResRep.ChangeDataBase(DBEnum.OA2014DB);
  27183. string sql = string.Format(@" Select * From grouopExceed where id > 20 And id not in (26,27) ");
  27184. List<OA2014_grouopExceed> list_visa = _airTicketResRep._sqlSugar.SqlQueryable<OA2014_grouopExceed>(sql).ToList();
  27185. _airTicketResRep.ChangeDataBase(DBEnum.OA2023DB);
  27186. Dictionary<int, int> dicDetail = new Dictionary<int, int>();
  27187. dicDetail.Add(789, 1034);
  27188. dicDetail.Add(790, 1035);
  27189. dicDetail.Add(791, 1036);
  27190. dicDetail.Add(792, 1037);
  27191. dicDetail.Add(793, 1038);
  27192. dicDetail.Add(794, 1039);
  27193. dicDetail.Add(795, 1040);
  27194. dicDetail.Add(796, 1041);
  27195. dicDetail.Add(797, 1042);
  27196. dicDetail.Add(798, 1043);
  27197. dicDetail.Add(801, 1044);
  27198. dicDetail.Add(802, 1045);
  27199. dicDetail.Add(803, 1046);
  27200. Dictionary<int, int> dic = new Dictionary<int, int>();
  27201. dic.Add(806, 1027);
  27202. dic.Add(807, 1028);
  27203. dic.Add(808, 1029);
  27204. dic.Add(809, 1030);
  27205. dic.Add(810, 1031);
  27206. dic.Add(811, 1032);
  27207. dic.Add(812, 1033);
  27208. foreach (var item in list_visa)
  27209. {
  27210. Fin_GroupExtraCost temp = new Fin_GroupExtraCost();
  27211. temp.Coefficient = item.coefficient;
  27212. DateTime dtCrt;
  27213. bool b1 = DateTime.TryParse(item.OperatorsDate, out dtCrt);
  27214. if (b1)
  27215. {
  27216. temp.CreateTime = dtCrt;
  27217. }
  27218. else
  27219. {
  27220. temp.CreateTime = DateTime.Now;
  27221. }
  27222. temp.CreateUserId = item.Operators;
  27223. temp.DeleteTime = "";
  27224. temp.DeleteUserId = 0;
  27225. temp.DiId = int.Parse(item.DIID);
  27226. temp.FilePath = item.FilePath;
  27227. temp.IsDel = item.IsDel;
  27228. temp.Price = item.Price;
  27229. temp.PriceCount = 1;
  27230. temp.PriceCurrency = item.Currency;
  27231. int detailId = 0;
  27232. if (dicDetail.ContainsKey(item.PriceTypeDetail))
  27233. {
  27234. detailId = dicDetail[item.PriceTypeDetail];
  27235. }
  27236. temp.PriceDetailType = detailId;
  27237. temp.PriceDt = DateTime.Now;
  27238. temp.PriceName = item.PriceName;
  27239. temp.PriceSum = item.Price;
  27240. int tid = 0;
  27241. if (dic.ContainsKey(item.PriceType))
  27242. {
  27243. tid = dic[item.PriceType];
  27244. }
  27245. temp.PriceType = tid;
  27246. temp.Remark = item.Remark;
  27247. await _airTicketResRep.AddAsync<Fin_GroupExtraCost>(temp);
  27248. }
  27249. return Ok(JsonView(true, "操作成功!"));
  27250. }
  27251. [HttpPost]
  27252. public IActionResult TimeTest()
  27253. {
  27254. var jw = JsonView(false, "error");
  27255. _sqlSugar.BeginTran();
  27256. try
  27257. {
  27258. var clientList = _sqlSugar.Queryable<Crm_NewClientData>()
  27259. .Select(x => new Crm_NewClientData
  27260. {
  27261. Id = x.Id,
  27262. Client = x.Client,
  27263. Contact = x.Contact,
  27264. Location = x.Location,
  27265. })
  27266. .ToList();
  27267. var ids = clientList.Where(x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains("重庆")).Select(x => x.Id).ToList();
  27268. _sqlSugar.Queryable<Crm_NewClientData>().Where(x => ids.Contains(x.Id)).ToList();
  27269. Stopwatch stopwatch = new Stopwatch();
  27270. // 开始计时
  27271. stopwatch.Start();
  27272. foreach (var item in clientList)
  27273. {
  27274. EncryptionProcessor.DecryptProperties(item);
  27275. }
  27276. stopwatch.Stop();
  27277. jw.Code = 200;
  27278. jw.Data = stopwatch.ElapsedMilliseconds;
  27279. jw.Msg = "运算耗时: " + stopwatch.ElapsedMilliseconds + " 毫秒,解密条数: " + clientList.Count;
  27280. }
  27281. catch (Exception ex)
  27282. {
  27283. jw.Code = 400;
  27284. jw.Msg = ex.Message;
  27285. }
  27286. return Ok(jw);
  27287. }
  27288. [HttpPost]
  27289. public async Task<IActionResult> TimeTest1()
  27290. {
  27291. var infos = await _sqlSugar.Queryable<Crm_DeleClient>().ToListAsync();
  27292. return Ok(infos);
  27293. }
  27294. }
  27295. }